Fix YieldProcessorMeasurement running continuously due to timestamp truncation#122293
Fix YieldProcessorMeasurement running continuously due to timestamp truncation#122293
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.
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.
LGTM. Also think it's appropriate for backport
|
/ba-g dead letter |
|
/backport to release/10.0 |
|
Started backporting to |
… to timestamp truncation (#122317) Backport of #122293 to release/10.0 /cc @agocke @Copilot The background process responsible for periodic updates of processor yield instruction costs consumes 100% of a single core on a machine with 50+ day uptime or non-standard OS timer configuration. ## Customer Impact - [x] Customer reported - [ ] Found internally ## Regression - [x] Yes - [ ] No ## Testing Standard test pass, no testing specific to the fix - the bug requires machine with 50 day uptime to test ## Risk Low. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jkotas <[email protected]> Co-authored-by: agocke <[email protected]> Co-authored-by: Steve Pfister <[email protected]>
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.