Skip to content

Make ETW rundown operate more effectively with JIT #116354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jul 14, 2025

Conversation

AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Jun 5, 2025

Fixes #102858

Make the EECodeGenManager API surface narrower.
Rename some locals removing critical section notion and replace with lock.

Rework the CodeHeapIterator.
Rename members to more accurately reflect their purpose. Generally move to more canonical C++.

EECodeGenManager now has an iterator counter. This is used to track the number of outstanding iterators and can be used to defer deletes. Adds are still valid since the iterator will only operate on the state at the time the iterator was created.

Always emit UnwindInfo for methods. This was previously only enabled when the Runtime provider was enabled and a rundown triggered.

Rename some locals removing critical section notion
and replace with lock.

Rework the CodeHeapIterator.
Rename members to more accurately reflect their purpose.
Generally move to more canonical C++.

EECodeGenManager now has a iterator counter. This is
used to track the number of outstanding iterators and
can be used to defer deletes. Adds are still valid since
the iterator will only operate on the state at the time the
iterator was created.
@AaronRobinsonMSFT AaronRobinsonMSFT marked this pull request as ready for review June 6, 2025 17:43
@AaronRobinsonMSFT AaronRobinsonMSFT requested a review from Copilot June 6, 2025 22:39
Copilot

This comment was marked as outdated.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failures look related:

20:03:09.305 Running test: tracing/runtimeeventsource/nativeruntimeeventsource/nativeruntimeeventsource.cmd
ASSERT FAILED
	Expression: codeLength > 0
	Location:   line 1866 in /Users/runner/work/1/s/src/coreclr/vm/eetwain.cpp

@jkotas jkotas added the tenet-performance Performance related issue label Jun 8, 2025
@AaronRobinsonMSFT
Copy link
Member Author

AaronRobinsonMSFT commented Jun 8, 2025

Test failures look related:

20:03:09.305 Running test: tracing/runtimeeventsource/nativeruntimeeventsource/nativeruntimeeventsource.cmd
ASSERT FAILED
	Expression: codeLength > 0
	Location:   line 1866 in /Users/runner/work/1/s/src/coreclr/vm/eetwain.cpp

Yep. I'm trying to root it out on macOS. I tried on Windows and did find a contract violation that I needed to fix. I pushed up that fix and will see where we are.

possible due to MethodDesc iteration.
Rework how DynamicMethodDesc and LCGMethodResolver
destruction works. This was needed due to Crst lock inversion.
Remove CrstIbcProfile
Rework allocation order for recording of code pointer.
@AaronRobinsonMSFT AaronRobinsonMSFT requested a review from Copilot July 9, 2025 20:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request modernizes the code heap management in the CLR's ETW integration to improve JIT rundown operations. The PR simplifies the EECodeGenManager API surface, reworks the CodeHeapIterator to be more robust, and ensures all methods emit unwind information for better ETW stack tracing.

Key changes include:

  • Refactored ETW rundown and JIT manager interfaces for better code heap iteration
  • Improved dynamic method destruction workflow with deferred cleanup
  • Enhanced thread safety for code heap operations during iteration

Reviewed Changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/coreclr/vm/threads.h Removes finalizer-related methods from Thread class
src/coreclr/vm/threads.cpp Removes finalizer work methods moved to FinalizerThread
src/coreclr/vm/finalizerthread.h Adds delayed dynamic method destruction support
src/coreclr/vm/finalizerthread.cpp Implements delayed dynamic method cleanup functionality
src/coreclr/vm/runtimehandles.cpp Updates dynamic method destruction to use delayed cleanup
src/coreclr/vm/codeman.h Modernizes CodeHeapIterator and UnwindInfoTable APIs
src/coreclr/vm/codeman.cpp Major refactoring of code heap management and iteration
src/coreclr/vm/dynamicmethod.h Restructures LCGMethodResolver for better lifecycle management
src/coreclr/vm/dynamicmethod.cpp Implements staged destruction with iterator-safe cleanup
src/coreclr/vm/jitinterface.h Removes obsolete BackoutJitData methods
src/coreclr/vm/jitinterface.cpp Simplifies JIT compilation error handling

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 9c0555e into dotnet:main Jul 14, 2025
95 of 97 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the runtime_102858 branch July 14, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Very Long JIT Times During ETW Rundown
2 participants