Bring new cpu.requests formula from Kubernetes#7239
Merged
amadeuszl merged 7 commits intodotnet:mainfrom Feb 3, 2026
Merged
Conversation
amadeuszl
commented
Jan 29, 2026
.../Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationParserCgroupV2.cs
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the CPU weight to CPU shares conversion formula for cgroup v2 in the ResourceMonitoring library. The change implements a new, more accurate conversion formula from Kubernetes that better reflects actual CPU allocations in modern container environments.
Changes:
- Implemented new mathematical formula for converting cgroup v2 cpu.weight to cgroup v1 cpu.shares
- Updated documentation in SystemResources.cs to reflect the new formula and reference Kubernetes blog post
- Updated all affected tests with correct expected values based on the new formula
- Updated verified test snapshots to reflect changed stack traces and calculation results
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationParserCgroupV2.cs | Replaced old linear conversion formula with new logarithmic formula in ConvertCpuWeightToShares method |
| src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/SystemResources.cs | Updated XML documentation to describe new formula with reference to Kubernetes blog post |
| test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV2Tests.cs | Updated test cases with new expected values; added new test method with proper formula documentation; removed duplicate test |
| test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs | Updated test data (cpu.weight values) to match expected CPU units under new formula |
| test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Verified/*.verified.txt | Updated verified test outputs for changed cpuRequest values and stack trace display class numbers |
evgenyfedorov2
approved these changes
Feb 3, 2026
This was referenced Feb 11, 2026
Merged
Bump Microsoft.Extensions.ServiceDiscovery from 10.2.0 to 10.3.0
askpt/openfeature-aspire-sample#351
Merged
Open
chore: Bump Microsoft.Extensions.ServiceDiscovery from 10.2.0 to 10.3.0
JerrettDavis/PokManagerUI#23
Open
This was referenced Feb 16, 2026
Bump Microsoft.Extensions.Http.Resilience from 10.2.0 to 10.3.0
dotnet-presentations/ai-workshop#342
Open
Open
Open
Open
Open
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #7202
Microsoft Reviewers: Open in CodeFlow
Observations
for 1CPU, when it equals to weight 102, it will result in baseline for calculations on around ~1.0253, which means that previously reported utilization at 20% will be reported now as <20%, suggesting that we are getting more CPU