Reasons for C# inlining are (a bit) more complex than you think.
The Twitter sometimes can serve as a place of unexpected insights and very interesting technical questions! For example, the question asked in a tweet here: https://twitter.com/EgorBo/status/1236324907723771904
Apparently, in the following code, C# compiler will inline Test1 and not Test2
12345678910111213141516171819using System;public static class C{ public static void Test1() { Validate(42, 42); } public static void Test2(int a, int b) { ...
Local variables vs properties. No suprises here?
Can the benchmark that compares array iteration vs. pointer based iteration be optimized further? Yep!In a post I wrote earlier about performance comparison between array access with pointers and the usual C#’s way, I saw an interesting comment that suggested a way to squeeze some more performance out of the scenario.Using a local variable instead of a call to a property (which is in fact a method call) made sense, though I wondered, just how much of a performance boost it would provide.So I de ...
Is it faster to access arrays with pointer arithmetics?
After seeing the results of my previous post where I tested performance impact of data locality, one of my collegues theorized that perhaps the huge difference between C++ and C# performance (assuming adjacent memory iteration) is due to boundary checks of C# arrays - he said that if I would use pointers to access arrays, the code will be much faster. I was curious if he was right, so I tested it.
The testI used the following test to try and see how much performance usage of pointers over simple ...
Easy way to configure SOS in LLDB
I don’t have much experience in using LLDB to debug .Net Core, so when I stumbled upon this little gem while looking at dotnet/diagnostics GitHub repository, I was instantly curious to try it: up to this point, in order to load the SOS plugin, I had to manually look up its folder, then specify it inside LLDB (via the load plugin command).This tool, however, should configure LLDB to load SOS plugin automatically!How? First install the tool via .Net Core CLI:
1dotnet tool install -g dotnet-so ...
Sequential memory access is... faster?
In gamedev articles about Entity-Component-System, data locality is often mentioned as a big reason to use such design pattern. The underlying data structures of the ECS are cache friendly, thus allowing much better performance for iterations of large amount of game objects.I knew that cache-friendly usage of memory (sequential memory access, for example) would yield better performance, but I was curious, how much better it would be?
In case you never heard about Entity-Component-System, this a ...
Nice little gotcha when loading SOS after launching .Net executable
When you launch .Net executable with WinDBG, in order to “catch” something nasty like AccessViolationExcetion, the application will stop after loading with a “debugger break”, and you will see something like this:
123(6b8.37dc): Break instruction exception - code 80000003 (first chance)ntdll!LdrpDoDebuggerBreak+0x30:00007ffc`391d121c cc int 3
At this point, if you try to load SOS, you will see an error.
120:000> .loadby sos coreclrUnable to find module 'coreclr'
Th ...
Setting up WinDBG for analyzing memory dumps
When I needed to investigate a memory dump for a first time, I stared at WinDBG window, not knowing how to begin. My google-fu yielded mixed results - I had to sift through lots of information, sometimes incorrect, sometimes outdated, only after some experimentation, I was able to actually understand what was going on.Though, in a hindsight, WinDBG is much less complex than it seemed in the first place.
A word (or three) on WinDBGWinDBG wikipedia article states that WinDbg is a multipurpose deb ...
Segmentation faults when using P/Invoke = pointer issues? Not necessarily
When debugging new RavenDB’s 32-bit pager for Linux-based ARM environments, which has platform specific functionality implemented in C and P/Invoked from C# code, I ran into an issue: when starting, RavenDB was throwing a segmentation fault and crashing. Since the C# code didn’t change much, my immediate suspect was some sort of pointer issue in C code, such as trying to dereference a null pointer.
GDB is awesome for handling segfaultsThe GNU Debugger or GDB is very good at tracing such is ...
Hunter, C++ package management made easy
In a previous post, I detailed involved and frustrating process I needed to go through to compile OpenCV as part of my application. You can see the post in this link.All the trouble I describe there could have been avoided by using Hunter - a CMake based package manager for C++ projects. The idea is to have a sort-of repository of configuration and install scripts for different packages that would handle configuring 3rd-party dependencies (and their dependencies) for your project. Kinda like NuG ...
OpenCV + Visual Studio + CMake = Adventure time
In theory, configuring a popular library like OpenCV in CMake should be easy. In practice, sadly, it is anything BUT easy. Why? Let me show you…
Note that I am not very knowledgeable in CMake, so it is possible I am doing something stupid. If so, it is even worse - as far as I understand the intent behind CMake, it should make developers lives easier, not harder.
This post is documentation of a frustrating journey of performing what should have been a trivial task - make dependency compile as ...