Skip to content

Commit db0546d

Browse files
fuguiKztimcassell
andauthored
docs: mention Jitting phase in How it works (#2942)
* docs: mention Jitting phase in How it works * docs: add JittingStage to pseudocode * Update docs/articles/guides/how-it-works.md --------- Co-authored-by: Tim Cassell <[email protected]>
1 parent b4f3f18 commit db0546d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/articles/guides/how-it-works.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ BenchmarkDotNet follows the following steps to run your benchmarks:
66
2. Next, we take each method/job/params combination and try to measure its performance by launching benchmark process several times (`LaunchCount`).
77
3. An invocation of the workload method is an *operation*. A bunch of operation is an *iteration*. If you have an `IterationSetup` method, it will be invoked before each iteration,
88
but not between operations. We have the following type of iterations:
9+
* `Jitting`: The overhead/workload methods are invoked to ensure they are JIT-compiled (and on tiered runtimes, to promote them when possible). These iterations are not used for measurements.
910
* `Pilot`: The best operation count will be chosen.
1011
* `OverheadWarmup`, `OverheadWorkload`: BenchmarkDotNet overhead will be evaluated.
1112
* `ActualWarmup`: Warmup of the workload method.
@@ -35,6 +36,7 @@ IEnumerable<Results> Run(Benchmark benchmark)
3536
Result ActualRun(Method method, Job job)
3637
{
3738
GlobalSetup();
39+
JittingStage(method); // triggers JIT compilation (and tiering if enabled) before Pilot/Warmup
3840
3941
int unrollFactor = job.Run.UnrollFactor; // 16 by default
4042
@@ -54,6 +56,19 @@ Result ActualRun(Method method, Job job)
5456
return (result - Median(overhead), gcStats);
5557
}
5658

59+
void JittingStage(Method method)
60+
{
61+
RunIteration(method, invokeCount: 1, unrollFactor: 1);
62+
if (JitInfo.IsTiered)
63+
{
64+
for (int i = 0; i < JitInfo.MaxTierPromotions; i++)
65+
{
66+
RunIteration(method, invokeCount: JitInfo.TieredCallCountThreshold, unrollFactor: 1);
67+
Thread.Sleep(250);
68+
}
69+
}
70+
}
71+
5772
long Pilot(Method method, int unrollFactor)
5873
{
5974
// invokeCount is the equivalent of InnerIterationCount from xunit-performance

0 commit comments

Comments
 (0)