Is there a way to work around the donet jit compile inliner time budget?

28 views Asked by At

I have an application (a chess engine) written in C#. Because the strength of the engine is correlated with its speed it is important that the engine run as fast as possible.

To make the code more expressive and easy to read I used multiple shorts methods/properties to hide some complexity behind an explicit name. I marked most of theses method/properties with the an attributes to encourage inlining ([MethodImpl(MethodImplOptions.AggressiveInlining)]).

Now that I have enough functionality code to benchmark my engine and compared it to other written in C# it is much slower than what I expected (about 10x slower). I used the DOTNET_JitDisasm environment variable to see the assembly generated by the jit compiler for some of the more critical method and to my surprises and in some places most method/properties are not inlined. I understand that the MethodImplOptions.AggressiveInlining is just a suggestion, but some method that should be a single assembly instruction are not inlined.

During my research I learned that the .net JIT compiler has something called the "inliner time budget" and that when this "buget" runs out, methods are no longer inlined even if they are marked with MethodImplOptions.AggressiveInlining.

Is there a way to increase this "budget" or in an other way make sure that method that would benefit from inlining are indeed inlined?

0

There are 0 answers