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

[3.1 port] Improve the performance of Environment.WorkingSet in Windows (#26522) #27212

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

sywhang
Copy link

@sywhang sywhang commented Oct 15, 2019

Description

This is a backport of #26522.

Environment.WorkingSet API was not made to be performant, so it was using reflection to call System.Diagnostics.Process API, which internally allocates a ProcessInfo object and fills up a lot of irrelevant information that gets thrown away. This changes Environment.WorkingSet API to call into the Windows API for fetching the working set directly to improve its performance on Windows.

Customer Impact

Bing reported this API to be a blocker for adopting the runtime performance counters in their production environment.

Regression?
No

Risk
Low. Performance tests showed an improvement of ~2000x speedup with this change.

…26522)

* Use win32 api directly for workingset counter

* Fix build warnings

* Removing useless code

* more cleanup

* remove size annotation

* remove useless comment

* Move all the changes to Environment.WorkingSet and remove it from RuntimeEventSourceHelper

* removing useless usings

* Use kernel32.dll instead of psapi.dll

* Code review feedback

* Remove newline change

* More code review nits
@MeiChin-Tsai
Copy link

Do we have similar performance problem on Linux? Just wondering. Otherwise, approved.

@jkotas
Copy link
Member

jkotas commented Oct 16, 2019

Do we have similar performance problem on Linux?

Yes: https://github.com/dotnet/coreclr/issues/23736#issuecomment-530627464

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants