Content-Length: 422425 | pFad | https://github.com/dotnet/runtime/pull/86109

05 Clean up shared ArrayPool naming and add some env var config by stephentoub · Pull Request #86109 · dotnet/runtime · GitHub
Skip to content

Clean up shared ArrayPool naming and add some env var config #86109

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

Merged
merged 7 commits into from
May 11, 2023

Conversation

stephentoub
Copy link
Member

We've had several requests to be able to tweak / experiment with how many arrays the shared array pool might store. This adds two environment variables, one that controls the number of partitions the shared pool uses, and one that controls the number of arrays cacheable in each partition. Previously these values were constants.

As part of doing that, I needed to choose names that were a bit more palatable for external consumption, and I renamed things in the implementation accordingly.

We've had several requests to be able to tweak / experiment with how many arrays the shared array pool might store.  This adds two environment variables, one that controls the number of partitions the shared pool uses, and one that controls the number of arrays cacheable in each partition.  Previously these values were constants.

As part of doing that, I needed to choose names that were a bit more palatable for external consumption, and I renamed thngs in the implementation accordingly.
@stephentoub stephentoub requested a review from jkotas May 11, 2023 18:16
@ghost ghost added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 11, 2023
@ghost ghost assigned stephentoub May 11, 2023
@filipnavara
Copy link
Member

Is there any guidance on introducing new environment variables like this? I would expect AppContext / runtimeconfig.json to be a better fit.

The reason I am asking is that we had several instances in the past where a global variable was set in the system and affected our app, resulting in crashes. In that particular case it was some "system optimizer" app turning on the PGO for all .NET apps. I'd really like to avoid situations like that happening again.

@stephentoub
Copy link
Member Author

Most such knobs have environment variables controlling them, some also have appcontext switches (and a few I think only have appcontext). In this case, they're very much an implementation detail and effectively experimental for now, and appcontext switches are more official, so I stuck with env vars.

@filipnavara
Copy link
Member

In this case, they're very much an implementation detail and effectively experimental for now

That's exactly what worries me. PGO was also very clearly marked as experimental, yet someone decided to turn it on system-wide. That's dangerously easy to do with environment variables and extremely difficult to diagnose for client-side apps deployed to consumer machines. AppContext is local to a specific app and that seems like a better fit for something that's experimental.

@stephentoub
Copy link
Member Author

There are literally hundreds of environment variables the runtime and libraries look for. I'm not sure why this one would be special. If you're asking that they all be ripped out, that's a much larger discussion.

@filipnavara
Copy link
Member

If you're asking that they all be ripped out, that's a much larger discussion.

I'm not necessarily asking to rip them all out but I think some review may be in order. Some of the variables are documented, some of them are not. Some of them are prefixed with DOTNET_ (or historically COMPlus_) while this one is not. I'd expect some guidance to be present for this.

We literally had an incident where DOTNET_TieredPGO=1 was set globally by a 3rd-party app and caused crashes of our app once the tiered PGO triggered in one specific code path. It took us months to find the root cause, so forgive me for being cautious about adding more of these global knobs that could accidentally create a problem.

@jkotas
Copy link
Member

jkotas commented May 11, 2023

Yes, environment variables can break apps, it has been the case since .NET Framework 1.0. It is both convenient and dangerous.

@filipnavara
Copy link
Member

filipnavara commented May 11, 2023

Yes, environment variables can break apps, it has been the case since .NET Framework 1.0. It is both convenient and dangerous.

AppContext exists since .NET Core 1.0, and it's app local, which is why I think it's a better fit for knobs like these. If you want to stick to environment variables (to my great dismay) it would be nice to follow a convention, like the DOTNET_/ComPlus_ prefix so we can collect the relevant subset into crash reports (eg. as additional parameters into Sentry).

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM!

@stephentoub stephentoub merged commit 43d6cb0 into dotnet:main May 11, 2023
@stephentoub stephentoub deleted the configarraypool branch May 11, 2023 23:56
@ghost ghost locked as resolved and limited conversation to collaborators Jun 11, 2023
@teo-tsirpanis teo-tsirpanis added area-System.Buffers and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 4, 2024
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.

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/dotnet/runtime/pull/86109

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy