You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Opt-in API that has a cached ThreadpoolController #254
Creating a controller is still expensive on Linux at least, so for libraries that do this a lot a cached version that notices when libraries change might be useful.
My thought is a top-level API get_cached_controller(force_new=False), that checks if e.g. the length of sys.modules has changed. If yes, it creates (and caches) a new controller, otherwise it returns a cached one. With force_new=True it always invalidates.
Application authors would presumably know that there's no other mechanism where new libraries might get loaded.
I would like to use this for joblib, on the theory that:
Joblib never had this oversubscription mitigation before.
This will catch the vast majority of cases where new libraries get added.
In the rare cases it doesn't catch a loaded library, it's not a bug, it's just a performance hit... and again, joblib never solved this before anyway so those users are no worse off.
Benchmarks should indicate if this is necessary, or if already done optimizations are sufficient to make threadpoolctl unnecessary in cases where it's used a lot. Benchmarks should be done on Linux, Windows, macOS though.
I did a benchmark on example_pipelines with and without this (with fastest/latest threadpoolctl/joblib PRs/branches), and this makes a noticeable difference on Linux, so I think this is worth adding, and I think it's worth using in joblib.
Activity
itamarst commentedon Sep 21, 2026
For FlexiBLAS one could have custom logic invalidation if it's loaded.
itamarst commentedon Sep 21, 2026
Benchmarks should indicate if this is necessary, or if already done optimizations are sufficient to make threadpoolctl unnecessary in cases where it's used a lot. Benchmarks should be done on Linux, Windows, macOS though.
itamarst commentedon Sep 23, 2026
I did a benchmark on
example_pipelineswith and without this (with fastest/latest threadpoolctl/joblib PRs/branches), and this makes a noticeable difference on Linux, so I think this is worth adding, and I think it's worth using in joblib.