-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Conversation
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.
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. |
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. |
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. |
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. |
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 We literally had an incident where |
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
Yes, environment variables can break apps, it has been the case since .NET Framework 1.0. It is both convenient and dangerous. |
|
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
4ff68d6
to
546cfaa
Compare
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Buffers/SharedArrayPool.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.