Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

[release/3.1] Read values from /proc/[pid]/status (#41122) - #42370

Merged
danmoseley merged 1 commit into
dotnet:release/3.1from
danmoseley:procport
Nov 5, 2019
Merged

danmoseley merged 1 commit into
dotnet:release/3.1from
danmoseley:procport

Conversation

@danmoseley

@danmoseley danmoseley commented Nov 4, 2019 •

Copy link
Copy Markdown

Port of #41122
Fixed #23449
Fixed #36086

Summary

Adds or improves results for several memory stats on Linux.

Add support for:

Process.PeakWorkingSet64
Process.PrivateMemorySize64
Process.PagedMemorySize64
Process.PagedSystemMemorySize64
Process.PeakVirtualMemorySize64

Improves:

Process.VirtualMemorySize64
Process.WorkingSet64

Customer Impact

This prevents some profilers from providing full memory information for services running on Linux, eg.,

Fixing this makes it easier for customers to monitor and diagnose issues on their services through telemetry. There is a desire to get this into an LTS release for this purpose.

Regression?

No, these have never worked on Linux.

Testing

Unit tests have been modified to require non zero values on Linux. This change does not fix OSX.

Risk

Affects reading of any process information on Linux (eg., GetProcessesByName). Previously it would read /proc/<pid>/stat and now it also reads /proc/<pid>/status to gather the other information. The risks include, slower performance from reading two files (although, Linux is already slower than Windows); bugs in reading the file could throw - although we catch IOException; bugs parsing the file could throw or produce garbage.

cc @stephentoub does the text above seem reasonable? Could you please sign off on the port? I just did cherry pick.

* Fix #23449 - Read values from /proc/[pid]/status

* Fix tests for new returned data from /prod/[pid]/status

* Update tests of process info on OSX

* Rename property ParsedStatus.pid --> ParsedStatus.Pid

* 1. Avoid reallocation of delimiter array
2. Use tryParse instead of Parse to avoid exceptions

* Rename static field and mark it as readonly

* Change pid from /status to be read only from debug mode

* Change status file read implementation using spans

* Remove unecessary debug statement

* Revert "Remove unecessary debug statement"

This reverts commit f60b4f3.

* Refactor logic using if statements with reduction in code redundancy

* Improve condition arrangement to avoid reading subsequent files if process name doesn't match

* Avoid failure of process info creation in case of fail read from one of many files.

* Refactor Interop.ProcFsStat for better understanding

* Change process creation logic to fail on read /stat

* Change logic for unit and non unit values in file
@danmoseley danmoseley added the Servicing-consider Issue for next servicing release review label Nov 4, 2019
@danmoseley danmoseley added this to the 3.1 milestone Nov 4, 2019
@danmoseley

Copy link
Copy Markdown
Author

Approved by Steve

@danmoseley danmoseley added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 5, 2019
@danmoseley
danmoseley merged commit 1eacd30 into dotnet:release/3.1 Nov 5, 2019
@danmoseley
danmoseley deleted the procport branch November 5, 2019 16:13
@preethikurup preethikurup modified the milestones: 3.1, 3.1.x Feb 10, 2020
@danmoseley danmoseley modified the milestones: 3.1.x, 3.1 Feb 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants