[9.0] Make counting of IO completion work items more precise on Windows#112794
Merged
kouvel merged 3 commits intodotnet:release/9.0-stagingfrom Mar 7, 2025
kouvel:PreciseIoWiCounting9
Merged
[9.0] Make counting of IO completion work items more precise on Windows#112794kouvel merged 3 commits intodotnet:release/9.0-stagingfrom kouvel:PreciseIoWiCounting9
kouvel merged 3 commits intodotnet:release/9.0-stagingfrom
kouvel:PreciseIoWiCounting9
Conversation
…Pool.CompletedWorkItemCount (#106854) * Stop counting work items from ThreadPoolTypedWorkItemQueue as completed work items * Fix CompletedWorkItemCount * Update src/libraries/System.Threading.ThreadPool/tests/ThreadPoolTests.cs Co-authored-by: Koundinya Veluri <kouvel@users.noreply.github.com> * Run CompletedWorkItemCountTest on Windows only --------- Co-authored-by: Eduardo Manuel Velarde Polar <evelardepola@microsoft.com> Co-authored-by: Koundinya Veluri <kouvel@users.noreply.github.com>
- Follow-up to #106854. Issue: #104284. - Before the change, the modified test case often yields 5 or 6 completed work items, due to queue-processing work items that happen to not process any user work items. After the change, it always yields 4. - Looks like it doesn't hurt to have more-precise counting, and there was a request to backport a fix to .NET 8, where it's more necessary to fix the issue
Contributor
|
Tagging subscribers to this area: @mangod9 |
Contributor
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/libraries/System.Threading.ThreadPool/tests/ThreadPoolTests.cs:1467
- The test case ThreadPoolCompletedWorkItemCountTest should include scenarios where the counter is decremented to ensure the Decrement method is tested.
[PlatformSpecific(TestPlatforms.Windows)]
eduardo-vp
approved these changes
Feb 21, 2025
jeffschwMSFT
approved these changes
Feb 28, 2025
Member
jeffschwMSFT
left a comment
There was a problem hiding this comment.
lgtm. we will take for consideration in 9.0.x
This was referenced Feb 28, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Customer Impact
While upgrading a service from .NET 6 to 8, a 1p customer noticed that on Windows, the "Thread Pool Completed Work Item Count" counter values roughly doubled for the service. This is due to .NET 8 also counting queue-processing work items that were introduced in .NET 7. So, for each IO completion callback run to completion, the completed work item count may change by 1-3 or more depending on the situation. Especially in services that take small amounts of periodic traffic, the completed work item count can appear to double or triple per IO completion callback run to completion. The metric is monitored closely by the customer to monitor service health, and they would like to be able to use a more representative count that reflects actual user work items that are completed, for that purpose.
Regression?
Yes, in .NET 7 on Windows
Testing
Validated in a small test case that for IO completion handling, the count reflects the actual number of IO completion callbacks run to completion.
Risk
Low, the count after the change is similar to what it used to be in .NET 6