Skip to content

Pooled execution mode (spawn.pool) for wide fan-out (#70 Phase 2) - #76

Merged
scttfrdmn merged 2 commits into
mainfrom
design/70-pool-integration
Jul 31, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
design/70-pool-integration

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Phase 2 of nf-spawn#70: wire nf-spawn to the spawn-side worker pool (spawn#456, Phase 1) so a wide fan-out runs as a pool of fungible workers draining a shared queue instead of one instance per task.

Stacked on #75 (non-blocking submit, Phase 0) — this branch includes that commit; merge #75 first, or merge this and #75 folds in. Design: docs/pool-integration-design.md.

The gap this closes

Phase 1 built the pool engine in spawn (spawn pool create/submit/drain + spored pool-worker), but nothing told nf-spawn to use it. The blocker was "nf-spawn has no run-level lifecycle hook." Resolved: Nextflow exposes TraceObserverFactoryV2 (a pf4j ExtensionPoint) with onFlowCreate(Session) / onFlowComplete() — verified against the shipped 26.04.3 jar.

What's here

  • SpawnPoolObserver (TraceObserverV2) + SpawnPoolObserverFactory (registered in build.gradle extensionPoints, alongside SpawnExecutor): onFlowCreate → spawn pool create (provision workers + queue); onFlowComplete → spawn pool drain. Inert unless spawn.pool.enabled.
  • SpawnPoolConfig: reads the spawn.pool { … } block and derives a stable, SQS-name-safe run id from session.uniqueId — so the observer and every submit() agree on the queue without shared mutable state (the run id is a pure function of the session both hold).
  • SpawnTaskHandler.submit() pool branch: builds the same TaskSpec, then spawn pool submit --run-id R --spec f.json (S3 stage + one SQS send — no launch) instead of spawn task run. checkIfRunning/checkIfCompleted are unchanged — a pooled worker writes the same .exitcode/completion.json. killTask() is a no-op in pool mode (workers are shared; pool drains at run end / idle-timeout).

Semantics (design §5)

  • Best-effort/eventual: PartialCohort (ask N, accept minViable) — fewer workers ⇒ lower parallelism, never a failed run. A pool that can't reach min-viable aborts the run at onFlowCreate, before any task submits.
  • Drain is unconditional (onFlowComplete on success and failure); workers idle-drain to $0; reaper + queue retention backstop a dead-head crash. Three independent teardown paths.
  • Homogeneous pool: per-process ext.instanceType isn't honored in pool mode — documented; best for the wide uniform scatter.

Testing

  • Full Spock suite green (91 tests). New SpawnPoolTest: config parsing, run-id stability + SQS-safety, and the spawn pool create/drain/submit argv builders (pure/static, @CompileStatic, no AWS) — mirroring the existing buildTaskRunCommand/buildTaskSpec argv tests. Plugin assembles; extensions.idx registers both extensions.
  • Paid N=108 validation is a separate, explicitly-authorized step (design §7): spawn.pool.enabled, TTL set, post-run terminate + leak-check. Success criteria: peak → N, dispatch → seconds, $0 after drain.

Refs #70. Requires a spawn release carrying spawn pool (spawn#456).

@scttfrdmn
scttfrdmn force-pushed the design/70-pool-integration branch from f173b6d to fc24e1d Compare July 31, 2026 02:47
@scttfrdmn
scttfrdmn merged commit 5632961 into main Jul 31, 2026
4 checks passed
@scttfrdmn
scttfrdmn deleted the design/70-pool-integration branch July 31, 2026 02:48
scttfrdmn added a commit that referenced this pull request Jul 31, 2026
Ships pool mode (spawn.pool, #76) + non-blocking dispatch (#75) in a release.
Also a post-audit doc refresh: 'How it works' now describes spawn task run +
durable S3 completion (not the stale spawn launch/spored complete); pool section
requires spawn >= v0.97.0; design docs marked shipped/implemented; runbook pins
>= v0.97.0 and fixes the run-id derivation; version pins bumped to 0.10.0.
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