Skip to content

requestedWorkers(): the worker count clusterSetup() asks for - #72

Merged
eliotmcintire merged 2 commits into
developmentfrom
requestedWorkers
Nov 18, 2026
Merged

eliotmcintire merged 2 commits into
developmentfrom
requestedWorkers

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

A program that must know how many workers a fit will get, before the workers exist, can now ask. Until now only the cluster set-up code knew, so callers copied its rule and got it wrong for some inputs.

Affects: nothing changes in the clusters that are built; there is one new exported function.

Technical details

The rule for the worker count was inline in clusterSetup() (R/clusterSetup.R:68,69,102): a single number of cores is that many "localhost", each host is cut to options(clusters.maxWorkersPerHost), and the planner is asked for the number of names when a host repeats, else nCoresNeeded. fireSense_spreadFit restated it and missed repeated host names (rep("mega", 40): 40 workers, it gave 30).

Fix: requestedWorkers(cores, nCoresNeeded) holds the rule, and clusterSetup() calls it. The host cap is included, because it can cut the count, so the function gives the same number clusterSetup() asks for (a cap message is printed as in clusterSetup()). The doc says so. It is what is asked for: the planner can still build fewer when memory or other clusters' bookings limit a host. NULL cores (no cluster) gives nCoresNeeded. The step that turns cores into host names, .requestedHosts(), is shared and idempotent.

Reuses: .trimToHostCap(), changeNodenameToLocalhost(), the existing plan_psock_min(total =) call; new: requestedWorkers(), .requestedHosts() and .workerTotal() (the count on hosts already trimmed, so clusterSetup() applies the cap once) (the rule was inline in clusterSetup(), nothing callable existed).

Tests: new tests/testthat/test-requestedWorkers.R (number, 1L, distinct hosts, repeated hosts, NULL, cap, and the total clusterSetup() gives the planner, pinned to literal values that also pass on the base code). devtools::test(): base 1382 pass, 0 fail, 0 skip; branch 1401 pass, 0 fail, 0 skip. R CMD check --no-manual --no-tests (scratch library, _R_CHECK_FORCE_SUGGESTS_=false as DT is not installed): base 0 errors, 0 warnings, 3 notes; branch 0 errors, 0 warnings, 2 notes.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

… already trimmed and renamed)

requestedWorkers() on clusterSetup()'s own .requestedHosts() result cut again after
the rename to localhost, so 5 thisHost + 5 localhost under a localhost cap of 6 asked for 6, not 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.22%. Comparing base (3dd04b2) to head (c6f7f2f).
⚠️ Report is 1 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development      #72      +/-   ##
===============================================
- Coverage        77.34%   76.22%   -1.13%     
===============================================
  Files               24       24              
  Lines             2256     2145     -111     
===============================================
- Hits              1745     1635     -110     
+ Misses             511      510       -1     

☔ 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.

@eliotmcintire
eliotmcintire merged commit c43cb05 into development Nov 18, 2026
12 of 14 checks passed
@eliotmcintire
eliotmcintire deleted the requestedWorkers branch November 18, 2026 16:48
eliotmcintire added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant