Tuning Library Runtime Behavior

Tunables were implemented in glibc 2.25 (2017-02-01).

1. Why?

No set of library defaults is appropriate for all workloads.

The GNU C Library makes assumptions on behalf of the user and provides a specific runtime behaviour that may not match the user workload or requirements.

For example the NPTL implementation sets a fixed cache size of 40MB for the re-use of thread stacks. Is it possible that this is correct under all workloads? Average workloads? This default was set 10 years ago and has not been revisited.

I propose we expose some of the library internals as tunable runtime parameters that our users and developers can use to tune the library. Developers would use them to achieve optimal mean performance for all users, while a single advanced user might use it to get the best performance from their application.

To reiterate:

We have immediate short-term needs today to expose library internals as tunable parameters, in particular:

2. How?

3. Design examples

3.1. Example: Some properties read at startup others continually via a global pointer

The only feasible design today is to create a global pointer that points to a structure that contains all tunnables for the entire library. At startup certain values of this structure are used for IFUNC selection and to initialize library-wide values that need early initialization. Later some values which can be dynamically changed may also be read via this global pointer e.g. default thread stack size. We document each property and if it's applied at startup, or if it is read at ever use. Startup properties could only be set via env vars or an admin sysconfig file read at startup.

3.2. Rejected Design Ideas

The following list captures some design ideas which we discussed, but rejected.

4. Next steps

4.1. Collect all globals

As recommended in Cauldron 2013 we need to bring together a global internal private structure first that contains all of the globals one might want to modify. That way we can see what is actually tunnable.

4.2. Analyze env vars currently in use

Analyzing currenct use of glibc env vars. Currently not complete. Currently contains env vars from auxiliary libraries.

None: TuningLibraryRuntimeBehavior (last edited 2022-01-05 16:26:56 by CarlosODonell)