Skip to content

[Documentation] Add FAQ section explaining cores, threads_per_core and max_workers#998

Draft
jan-janssen wants to merge 2 commits into
mainfrom
docs-cores-threads-workers-faq
Draft

[Documentation] Add FAQ section explaining cores, threads_per_core and max_workers#998
jan-janssen wants to merge 2 commits into
mainfrom
docs-cores-threads-workers-faq

Conversation

@jan-janssen
Copy link
Copy Markdown
Member

@jan-janssen jan-janssen commented Jun 4, 2026

What changed

Added a new "Cores, Threads per Core and Maximum Workers" section to docs/trouble_shooting.md (the page that serves as the project FAQ), just above the existing "Resource Dictionary" section.

Why

Users frequently struggle to distinguish the cores, threads_per_core and max_workers/max_cores parameters, since they all control compute resources but operate on different levels. The new section separates them by scope:

  • max_workers / max_cores — executor-level: the total core budget shared across all submitted tasks. max_cores is recommended; max_workers exists only for stdlib Executor backwards compatibility.
  • cores — per-function-call (resource_dict): number of MPI ranks for a single function. Explicitly noted that this should primarily be used with mpi4py, and that giving a plain serial function cores > 1 just reserves idle cores without speeding it up.
  • threads_per_core — per-function-call (resource_dict): OpenMP threads per core (OMP_NUM_THREADS etc.), for thread-based parallelism in linked libraries rather than MPI.

It closes with the relationship (cores * threads_per_core per task, summed across tasks must stay within max_cores) and a runnable SingleNodeExecutor(max_cores=4) + resource_dict={"cores": 2} mpi4py example.

Notes for reviewers

  • Docs-only change; no code touched.
  • Placed in trouble_shooting.md because there is no dedicated FAQ page in _toc.yml. Happy to split it into a standalone faq.md page if preferred.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified Python version guidance for the scheduler (limited to Python 3.13 and below; Python 3.13 recommended).
    • Added a “Cores, Threads per Core and Maximum Workers” troubleshooting section explaining how executor-wide parallel budget, per-task cores, and threads-per-core interact, with rule-of-thumb guidance for MPI vs. threaded/external-application executions.

Users frequently confuse the cores, threads_per_core and
max_workers/max_cores parameters since they all control compute
resources but on different levels. Add a dedicated FAQ section to the
trouble shooting docs clarifying that max_workers/max_cores is the
executor-wide core budget, while cores (per call, primarily for mpi4py)
and threads_per_core (per call, OpenMP) describe how each function call
spends a slice of that budget.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates docs/trouble_shooting.md: it rewords Flux scheduler Python-version guidance (Python 3.13 recommended, limited to ≤3.13) and adds a troubleshooting section explaining max_workers/max_cores, cores, and threads_per_core, with rules-of-thumb and examples.

Changes

Executor Resource Configuration Documentation

Layer / File(s) Summary
Cores and worker resource constraints troubleshooting
docs/trouble_shooting.md
Reworded Flux scheduler Python-version limitation and added a new subsection explaining max_workers/max_cores (executor-wide budget), cores (per-function MPI rank/process count via resource_dict), and threads_per_core (per-function OpenMP thread limit), including cores * threads_per_core and example usage.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • pyiron/executorlib#531: Updates docs/trouble_shooting.md documentation to clarify resource_dict parameter naming and cores concept, aligning with this PR's resource constraint explanations.

Poem

🐰
I hopped through lines of docs at night,
Fixed Python notes and made things right,
Cores and threads now sing in tune,
Max workers set beneath the moon,
Happy runs and speedy flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The PR title accurately describes the main change: adding a FAQ section that explains the relationship between cores, threads_per_core, and max_workers parameters in the troubleshooting documentation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs-cores-threads-workers-faq

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/trouble_shooting.md`:
- Around line 80-81: Update the sentence to reference threads_per_core so it
matches the formula: change the wording that currently says "the sum of their
requested cores never exceeds `max_cores`" to state that executorlib schedules
tasks so that the sum of each task's requested `cores * threads_per_core` (i.e.,
requested threads) never exceeds `max_cores`, explicitly mentioning the symbols
`cores`, `threads_per_core`, and `max_cores` to avoid ambiguity.
- Around line 67-68: The doc line claiming "when neither is provided executorlib
uses the number of cores available on the machine" is too absolute; update the
wording to scope the fallback to CPU count to executors/modes that enable local
core fallback (see src/executorlib/standalone/inputcheck.py and the
set_local_cores=True path). Mention that when set_local_cores is False the
library raises a ValueError instead, and clarify which executors or modes use
the automatic CPU-count fallback versus those that require explicit
max_cores/max_workers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2fa7054e-3c45-46ba-ac9c-14b038cdf32d

📥 Commits

Reviewing files that changed from the base of the PR and between 0a7214e and 9bcbcb2.

📒 Files selected for processing (1)
  • docs/trouble_shooting.md

Comment thread docs/trouble_shooting.md
Comment on lines +67 to +68
limit refers to the number of compute cores. Setting either is optional - when neither is provided executorlib uses the
number of cores available on the machine.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify defaulting behavior when neither max_cores nor max_workers is set.

This sentence is too absolute. The code path in src/executorlib/standalone/inputcheck.py shows fallback to CPU count is conditional (set_local_cores=True); otherwise it raises ValueError. Please scope this statement to the relevant executors/modes.

Suggested wording
-  limit refers to the number of compute cores. Setting either is optional - when neither is provided executorlib uses the
-  number of cores available on the machine.
+  limit refers to the number of compute cores. Setting either is optional in executors that support local-core fallback;
+  in that case, when neither is provided, executorlib uses the number of cores available on the machine.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
limit refers to the number of compute cores. Setting either is optional - when neither is provided executorlib uses the
number of cores available on the machine.
limit refers to the number of compute cores. Setting either is optional in executors that support local-core fallback;
in that case, when neither is provided, executorlib uses the number of cores available on the machine.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/trouble_shooting.md` around lines 67 - 68, The doc line claiming "when
neither is provided executorlib uses the number of cores available on the
machine" is too absolute; update the wording to scope the fallback to CPU count
to executors/modes that enable local core fallback (see
src/executorlib/standalone/inputcheck.py and the set_local_cores=True path).
Mention that when set_local_cores is False the library raises a ValueError
instead, and clarify which executors or modes use the automatic CPU-count
fallback versus those that require explicit max_cores/max_workers.

Comment thread docs/trouble_shooting.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.19%. Comparing base (0a7214e) to head (121d38e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #998   +/-   ##
=======================================
  Coverage   94.19%   94.19%           
=======================================
  Files          39       39           
  Lines        2103     2103           
=======================================
  Hits         1981     1981           
  Misses        122      122           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
docs/trouble_shooting.md (1)

67-68: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Address the prior review comment about conditional CPU fallback.

A previous review correctly noted that the statement "when neither is provided executorlib uses the number of cores available on the machine" is too absolute. The code path shows this fallback is conditional on set_local_cores=True; when false, a ValueError is raised instead. Please scope this statement to clarify which executors or modes support automatic CPU-count fallback versus requiring explicit configuration.

Run the following script to confirm which executor implementations enable the automatic CPU fallback:

#!/bin/bash
# Description: Identify executors that set set_local_cores=True vs False

# Search for set_local_cores usage patterns
rg -nP 'set_local_cores\s*=' --type=py -A2 -B2

# Find executor initialization that may control this behavior
ast-grep --pattern $'class $EXECUTOR($$$) {
  $$$
  set_local_cores
  $$$
}'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/trouble_shooting.md` around lines 67 - 68, Update the docs text to stop
asserting an unconditional fallback: clarify that executorlib only uses the
machine CPU count when set_local_cores=True; otherwise the executor raises a
ValueError and requires explicit CPU configuration. Mention the configuration
flag set_local_cores (and the behavior of ValueError) and instruct readers to
check specific executor classes that set set_local_cores=True to know which
implementations support automatic fallback (e.g., search for set_local_cores
usage in executor classes).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/trouble_shooting.md`:
- Line 56: Fix the spelling mistake in the sentence "performance computing
installations Python 3.13 is the recommended Python verion." by changing
"verion" to "version" so it reads "...recommended Python version."; update that
line in the troubleshooting document where that exact sentence appears.

---

Duplicate comments:
In `@docs/trouble_shooting.md`:
- Around line 67-68: Update the docs text to stop asserting an unconditional
fallback: clarify that executorlib only uses the machine CPU count when
set_local_cores=True; otherwise the executor raises a ValueError and requires
explicit CPU configuration. Mention the configuration flag set_local_cores (and
the behavior of ValueError) and instruct readers to check specific executor
classes that set set_local_cores=True to know which implementations support
automatic fallback (e.g., search for set_local_cores usage in executor classes).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a0d33b2-6096-4a99-87c0-51f9daadda2e

📥 Commits

Reviewing files that changed from the base of the PR and between 9bcbcb2 and 121d38e.

📒 Files selected for processing (1)
  • docs/trouble_shooting.md

Comment thread docs/trouble_shooting.md
the [flux](http://flux-framework.org) job scheduler are currently limited to Python 3.12 and below. Consequently for high
performance computing installations Python 3.12 is the recommended Python verion.
the [flux](http://flux-framework.org) job scheduler are currently limited to Python 3.13 and below. Consequently for high
performance computing installations Python 3.13 is the recommended Python verion.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix spelling error.

"verion" should be "version".

📝 Proposed fix
-performance computing installations Python 3.13 is the recommended Python verion. 
+performance computing installations Python 3.13 is the recommended Python version.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
performance computing installations Python 3.13 is the recommended Python verion.
performance computing installations Python 3.13 is the recommended Python version.
🧰 Tools
🪛 LanguageTool

[grammar] ~56-~56: Ensure spelling is correct
Context: ...s Python 3.13 is the recommended Python verion. ## Cores, Threads per Core and Maximum Work...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/trouble_shooting.md` at line 56, Fix the spelling mistake in the
sentence "performance computing installations Python 3.13 is the recommended
Python verion." by changing "verion" to "version" so it reads "...recommended
Python version."; update that line in the troubleshooting document where that
exact sentence appears.

@jan-janssen jan-janssen marked this pull request as draft June 4, 2026 08:48
@jan-janssen jan-janssen changed the title Add FAQ section explaining cores, threads_per_core and max_workers [Documentation] Add FAQ section explaining cores, threads_per_core and max_workers Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant