Skip to content

Allow trimming NativeRuntimeEventSource#130663

Open
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:eventtracecond
Open

Allow trimming NativeRuntimeEventSource#130663
MichalStrehovsky wants to merge 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants