-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix YieldProcessorMeasurement running continuously due to timestamp truncation #122293
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
Conversation
Co-authored-by: jkotas <[email protected]>
|
Is there any way to reasonably test this? I assume the timer would have to overflow, meaning we'd need to run the tests for ~50 days? |
Right. Or artificially bump the timer so that it starts at more than UInt32.MaxValue. Also, it would have to be a perf test. This fix does not affect functionality. We have actually seen a regression that was attributed to this change #115408 (comment) . I suspect that it might have been caused by this bug. Nobody was able to repro the regression, and so it was won't fixed unfortunately. |
There was a problem hiding this 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 PR fixes a critical bug in YieldProcessorMeasurement where timestamp truncation caused continuous measurement execution instead of the intended 4-second interval, resulting in elevated CPU usage and increased GC pressure in ASP.NET Core applications on .NET 10.0.
Key Changes:
- Removed incorrect cast from
int64_ttounsigned intwhen assigning the return value ofminipal_lowres_ticks()tos_previousNormalizationTimeMs
Co-authored-by: agocke <[email protected]>
agocke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Also think it's appropriate for backport
|
/ba-g dead letter |
|
/backport to release/10.0 |
|
Started backporting to |
Summary
Fixed high CPU utilization in .NET 10.0 by removing an incorrect
(unsigned int)cast that was causing YieldProcessorMeasurement to run continuously instead of every 4 seconds. The variables_previousNormalizationTimeMsis declared asint64_tbut was being assigned with a truncated 32-bit value, leading to incorrect time comparisons and excessive measurements.Added parentheses around subtraction operations to make operator precedence explicit.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.