Skip to content
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

Handle NativeOverlapped* coming from both the Windows or Portable thread pool in NativeRuntimeEventSource #97365

Merged
merged 9 commits into from
Feb 9, 2024

Conversation

eduardo-vp
Copy link
Member

@eduardo-vp eduardo-vp commented Jan 23, 2024

Fix ThreadPoolIOEnqueue, ThreadPoolIODequeue, ThreadPoolIOPack in Native Runtime Event Source which are based on the assumption that the NativeOverlapped* comes from the Portable thread pool implementation but it can come from the Windows thread pool implementation as well.

@ghost
Copy link

ghost commented Jan 23, 2024

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: eduardo-vp
Assignees: eduardo-vp
Labels:

area-System.Diagnostics.Tracing

Milestone: -

@eduardo-vp eduardo-vp marked this pull request as draft January 23, 2024 07:05
@eduardo-vp eduardo-vp marked this pull request as draft January 23, 2024 07:05
@eduardo-vp eduardo-vp changed the title Handle NativeOverlapped* coming from both the Windows or Portable thread pool in NativeRuntimeEventSource.ThreadPoolIOEnque Handle NativeOverlapped* coming from both the Windows or Portable thread pool in NativeRuntimeEventSource Jan 23, 2024
Copy link
Member

@kouvel kouvel left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -254,7 +259,7 @@ public void ThreadPoolIOEnqueue(RegisteredWaitHandle registeredWaitHandle)
[Event(64, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IODequeue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)]
private unsafe void ThreadPoolIODequeue(
IntPtr NativeOverlapped,
IntPtr Overlapped,
IntPtr Overlapped, // 0 if the Windows thread pool is used, the relevant info could be obtained from the NativeOverlapped* if necessary
Copy link
Member

Choose a reason for hiding this comment

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

How do diagnostic tools use this value? Is 0 the best option to make them work seamlessly?

Copy link
Member

Choose a reason for hiding this comment

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

As far as I know it's not used for anything specific, just additional info. We used to pass in the actual Overlapped object pointer and later switched to a hash code since that's not a stable value. I'm not sure how useful it is actually, since the NativeOverlapped* is stable, maybe a hash code is not very useful. For the Windows thread pool implementation there is an OverlappedData object that could be used, though it could also be obtained from the NativeOverlapped* if debugging side-by-side with a heap dump.

@tommcdon
Copy link
Member

tommcdon commented Feb 6, 2024

Adding @noahfalk @davmason for additional review

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

Looks fine to me

@eduardo-vp eduardo-vp force-pushed the fix-nres-threadpool-io-enqueue branch from e0dc456 to a3c111c Compare February 8, 2024 23:31
@eduardo-vp
Copy link
Member Author

Removing the test as it could be improved and it should be configured to run with the Windows thread pool. I'll add it separately in another PR and merge this one with the fix only

@eduardo-vp eduardo-vp merged commit 38a23c9 into dotnet:main Feb 9, 2024
172 of 178 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2024
@eduardo-vp
Copy link
Member Author

/backport to release/8.0-staging

@github-actions github-actions bot unlocked this conversation Mar 13, 2024
Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/8257670127

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2024
@eduardo-vp eduardo-vp deleted the fix-nres-threadpool-io-enqueue branch May 29, 2024 20:38
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.

5 participants