Skip to content
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

ArrayPool degradation above 70% memory utilization #13289

Closed
jkotas opened this issue Aug 8, 2019 · 11 comments
Closed

ArrayPool degradation above 70% memory utilization #13289

jkotas opened this issue Aug 8, 2019 · 11 comments
Labels
area-System.Runtime enhancement Product code improvement that does NOT require public API changes/additions tenet-performance Performance related issue

Comments

@jkotas
Copy link
Member

jkotas commented Aug 8, 2019

From https://gitter.im/dotnet/corefx?at=5d043a468e050f62aa1ccc18 :

using the arraypool is great in theory but since it responds to gc pressure once you start getting collections you lose most benefit from it.

@jkotas
Copy link
Member Author

jkotas commented Aug 8, 2019

In worst case, the current array pool policies may send you on a death spiral above 70% memory utilization: The array pool will start flushing itself after every Gen2 GC, that produces a lot of garbage that needs to be collected, that triggers more GCs, that causes more trimming, …

@jeffschwMSFT jeffschwMSFT transferred this issue from dotnet/coreclr Aug 20, 2019
@stephentoub
Copy link
Member

@jeffschwMSFT, why did you move this issue to corefx? The ArrayPool implementation is in coreclr.

@jeffschwMSFT
Copy link
Member

@stephtoub my mistake... moving it back :)

@jeffschwMSFT jeffschwMSFT transferred this issue from dotnet/corefx Aug 21, 2019
@stephentoub
Copy link
Member

stephentoub commented Aug 21, 2019

😄 (single repo for the win)

@JeremyKuhne
Copy link
Member

I'm not sure what we can do here in a "global" sense. If the GC is under significant pressure the ArrayPool rooting a bunch of otherwise unrooted objects can kill performance or lead to OOM conditions as well. Adding the collection under pressure logic had a significant positive impact.

You can already create your own private pool, which doesn't collect (i.e. ArrayPool<T>.Create()), is that enough to address the concern here?

We're already doing some logic to favor larger arrays. We could try to add more logic to tweak our aggressiveness, but I worry about unintended consequences. Not saying that we shouldn't do anything, I'm just voicing my concerns. I'd love to see more detailed scenarios.

@Maoni0 do you have any suggestions on how to play nicer with the GC?

@jkotas
Copy link
Member Author

jkotas commented Aug 22, 2019

create your own private pool, which doesn't collect (i.e. ArrayPool.Create()), is that enough to address the concern here?

That does not help. Close to none of the APIs that use ArrayPool as implementation detail take a custom array pool as an input.

@VSadov
Copy link
Member

VSadov commented Aug 23, 2019

Perhaps when trimming due to pressure, the pool size should be temporarily reduced?

Like:

  • add another nonconstant limit that is typically the same as MaxBuffersPerArraySizePerCore and use that for how much can actually be retained.
  • every time you need to panic-trim in Gen2 reduce that limit by half before reallocating the buckets.
  • increase the limit by 1 up to MaxBuffersPerArraySizePerCore every time you survive Gen2 without a need to trim.

Just a thought...

@joperezr
Copy link
Member

@jkotas I suppose this is not new for 3.0 or a regression right? I just ask because I was about to triage this as Future but wanted to double check.

@jkotas
Copy link
Member Author

jkotas commented Aug 27, 2019

Correct. This is not a regression.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 26, 2020
@joperezr joperezr added enhancement Product code improvement that does NOT require public API changes/additions tenet-performance Performance related issue and removed untriaged New issue has not been triaged by the area owner labels Jul 2, 2020
Copy link
Contributor

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

@dotnet-policy-service dotnet-policy-service bot added backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity labels Jan 2, 2025
Copy link
Contributor

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@dotnet-policy-service dotnet-policy-service bot removed this from the Future milestone Jan 16, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2025
@dotnet-policy-service dotnet-policy-service bot removed no-recent-activity backlog-cleanup-candidate An inactive issue that has been marked for automated closure. labels Feb 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime enhancement Product code improvement that does NOT require public API changes/additions tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

8 participants