Skip to content

Allow trimming NativeRuntimeEventSource - #130663

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:eventtracecond
Jul 15, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:eventtracecond

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Constant propagation cannot see through the local assignments/reassignments.

Matches the existing patterns at

// Also check NativeRuntimeEventSource.Log.IsEnabled() to enable trimming
if (areContentionEventsEnabled && NativeRuntimeEventSource.Log.IsEnabled())

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates CoreLib’s threading event emission sites to include an additional NativeRuntimeEventSource.Log.IsEnabled() guard so the ILLink substitutions for EventSource.IsEnabled() (when EventSource.IsSupported is feature-switched off) can more reliably trim away the NativeRuntimeEventSource-dependent code, even when existing boolean locals are reassigned.

Changes:

  • Add && NativeRuntimeEventSource.Log.IsEnabled() to WaitHandle wait start/stop event emission guards.
  • Add && NativeRuntimeEventSource.Log.IsEnabled() to Lock contention event emission guards (start/stop/created).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs Adds an extra IsEnabled() guard around wait ETW/EventPipe event writes to improve trim-friendliness under EventSource.IsSupported=false.
src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs Adds an extra IsEnabled() guard around contention event writes to match existing trim-friendly patterns in this file.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g the helix badexit is #130678 that was fixed.

@MichalStrehovsky
MichalStrehovsky enabled auto-merge (squash) July 15, 2026 13:06
@MichalStrehovsky
MichalStrehovsky merged commit 051c1fd into dotnet:main Jul 15, 2026
142 of 147 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the eventtracecond branch July 15, 2026 13:07
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants