Repository navigation
Listen to JIT events - #3169
Merged
Merged
Listen to JIT events#3169
Conversation
This was referenced Jun 3, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Simplify WaitForInitialTieringActive.
Reduce event noise from the framework.
timcassell
force-pushed
the
jit-stage-determinism
branch
from
June 20, 2026 18:48
610e77d to
02e7826
Compare
timcassell
marked this pull request as ready for review
June 20, 2026 18:48
timcassell
force-pushed
the
jit-stage-determinism
branch
from
June 20, 2026 20:09
6250266 to
ae07d7b
Compare
Conflict resolved in DeclarationsProvider.cs: keep both master's GetLoadArguments/GetPassArguments and the branch's GetWorkloadMethodParameterTypes/GetTypeOfExpression resolver helpers. Master reintroduced FileCleanupHelper (it now has call sites in BenchmarkRunnerClean/GeneratorBase), overriding the branch's tangential deletion of it. Bumped SyncTaskCoreEmitter's no-arg async-method ordinals +1 to track the branch's +1 shift of the base map: the generated __ResolveWorkloadMethods member shifts every Roslyn declaration-order ordinal by one, and master's sync-task override (added independently) hadn't accounted for it, breaking InProcessEmitTest's ConsumeTasksSynchronously case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
timcassell
force-pushed
the
jit-stage-determinism
branch
from
June 27, 2026 22:54
54e01a3 to
80765b9
Compare
Collaborator
Author
Identify watched methods exactly instead of by metadata token + name, which collide both across modules (tokens are only unique within one, and every module numbers them from 0x06000001) and across generic instantiations: - Non-canonicalized methods (all non-generic ones, plus value-type generic instantiations) match on the event's MethodID, the MethodDesc pointer that the public RuntimeMethodHandle.Value exposes. Exact and module-proof, and one integer compare instead of the name payloads. - Canonicalized methods (any reference-type generic argument, at any depth) can't use it: CoreCLR compiles one shared body for them and publishes it against the __Canon MethodDesc, which reflection cannot hand back. They match on ModuleID + token + name + the canonicalized declaring type name, which is how the events spell the instantiation. ModuleID is best-effort; unresolved simply means "don't compare". - Generic methods are now rejected. The events name only the declaring type and the bare method name, so a canonicalized instantiation cannot be told from any other. BDN has never supported them as benchmark methods, so this is a contract violation rather than something to half-support. Dispose the listener when the stage is abandoned. EngineStage is IDisposable and the engine's stage loop disposes it, so an exception or cancellation mid jit stage no longer leaks the Jit keyword — an event for every method jitted process-wide — into the measurement stages. Don't enable events from OnEventSourceCreated. The base EventListener ctor calls it before our ctor body runs, so enabling there let the EventPipe dispatcher thread reach OnEventWritten while watchedMethods was still null. Fix JitStage_MultipleMethodsUnevenInvocationRates, whose sleep counted invocations where it meant tier crossings, making its condition unsatisfiable so it never staggered the two methods it was written to stagger. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
|
Dismayed that it is so complicated. I don't believe we have any better solution to offer. |
Collaborator
Author
Right, it's the consequence of having to compensate for racing with the JIT and event dispatcher threads. Dedicated APIs would vastly simplify it (dotnet/runtime#129020). |
2 tasks done
This was referenced Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves the JIT stage by listening to events instead of waiting 250ms per tier. It's still not 100% deterministic, but it's much better than before.
Master: ~750ms + benchmark time
PR: ~90ms + benchmark time + compilation time