Sample: IntroTailcall
You need to use the TailcallDiagnoser
attribute to configure it. The available options are:
- logFailuresOnly: Track only the methods that failed to get tail called. True by default.
- filterByNamespace : Track only the methods from declaring type's namespace. Set to false if you want to see all Jit tail events. True by default.
Restrictions
- Windows only
- x64
Source code
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.Samples
{
[Diagnostics.Windows.Configs.TailCallDiagnoser]
[LegacyJitX86Job, LegacyJitX64Job, RyuJitX64Job]
public class IntroTailcall
{
[Benchmark]
public long Calc()
=> FactorialWithoutTailing(7) - FactorialWithTailing(7);
private static long FactorialWithoutTailing(int depth)
=> depth == 0 ? 1 : depth * FactorialWithoutTailing(depth - 1);
private static long FactorialWithTailing(int pos, int depth)
=> pos == 0 ? depth : FactorialWithTailing(pos - 1, depth * pos);
private static long FactorialWithTailing(int depth)
=> FactorialWithTailing(depth - 1, depth);
}
}
Output
// * Diagnostic Output - TailCallDiagnoser *
--------------------
--------------------
Jit_TailCalling.Calc: LegacyJitX64(Jit=LegacyJit, Platform=X64, Runtime=Clr)
--------------------
--------------------
Jit_TailCalling.Calc: LegacyJitX86(Jit=LegacyJit, Platform=X86, Runtime=Clr)
--------------------
--------------------
Jit_TailCalling.Calc: RyuJitX64(Jit=RyuJit, Platform=X64)
--------------------
Caller: <null>.<null> - <null>
Callee: BenchmarkDotNet.Samples.JIT.Jit_TailCalling.FactorialWithTailing - int64 (int32,int32)
Tail prefix: False
Tail call type: RecursiveLoop
-------------------
Links
- Diagnosers
- The permanent link to this sample: BenchmarkDotNet.Samples.IntroTailcall