Skip to content

Add resiliency to Resource Monitoring in Linux #6489

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

amadeuszl
Copy link
Contributor

@amadeuszl amadeuszl commented Jun 3, 2025

Partially fixes #6478

This PR address Linux RM for Disk and Networking. To make PR smaller CPU and Memory will be addressed in separated ones. Later I will check what we can do for Windows.

Microsoft Reviewers: Open in CodeFlow

{
return [];
}

try
{
List<DiskStats> diskStatsList = _diskStatsReader.ReadAll();
Copy link
Member

Choose a reason for hiding this comment

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

I am sorry, I did not have time to review previous PRs, but here we have two List<> allocations - first inside the .ReadAll() method and second with .ToList() on line 160.

  1. Can we fold it into one allocation?
  2. Can we avoid allocations at all and use object pooling for the List<>?
  3. Can we do .ToArray() on line 160 instead of .ToList() because we don't really need it to be List<> further in the flow?

Copy link
Member

Choose a reason for hiding this comment

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

If you feel like it is not in scope of this PR, please address in a follow-up PR, of course

Copy link
Contributor Author

@amadeuszl amadeuszl Jun 9, 2025

Choose a reason for hiding this comment

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

I moved filtering to ReadAll(), so filtering happens on read, in result we don't have to enumerate twice, and additionally we skip second allocation. Also, switched to array as suggested for performance reasons

@dotnet-policy-service dotnet-policy-service bot added waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. and removed waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. labels Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add resiliency mechanism to reduce exception rate in resource monitoring
2 participants