Skip to content

Add and expose Rayon thread pool handling to the Python module.#346

Merged
prehner merged 2 commits intomainfrom
rayon_threads
Mar 14, 2026
Merged

Add and expose Rayon thread pool handling to the Python module.#346
prehner merged 2 commits intomainfrom
rayon_threads

Conversation

@g-bauer
Copy link
Copy Markdown
Contributor

@g-bauer g-bauer commented Mar 14, 2026

Allows users to specify the number of threads used (important for HPC/Cluster envs).

There are three ways to do this:

  • Do nothing. When a parallel function is called, lazily initialise thread pool using all CPUs (this is the current state)
  • Use FEOS_MAX_THREADS env variable.
  • Use set_num_threads().

No matter in which way the pool was initialised, it cannot be changed in the same Python process. Users can use get_num_threads() to get the number of threads used. Invoking this function will also lazily initialise the thread pool with the default.

@g-bauer g-bauer added enhancement New feature or request python Python related feature or issue labels Mar 14, 2026
@g-bauer g-bauer requested a review from prehner March 14, 2026 18:58
@prehner
Copy link
Copy Markdown
Contributor

prehner commented Mar 14, 2026

Awesome 🤩 Then we can use rayon in all kinds of places without feeling too guilty.

@g-bauer
Copy link
Copy Markdown
Contributor Author

g-bauer commented Mar 14, 2026

Also: I think the code can easily be copied for rust binaries to get the same behaviour.

@prehner prehner merged commit b3b8539 into main Mar 14, 2026
17 checks passed
@prehner prehner deleted the rayon_threads branch March 14, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Python related feature or issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants