Skip to content

feat(load): --load-workers multi-process load generator - #2930

Merged
cliffhall merged 7 commits into
v2/mainfrom
v2/feat/2914-load-workers
Nov 5, 2026
Merged

cliffhall merged 7 commits into
v2/mainfrom
v2/feat/2914-load-workers

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2914

--load-workers <n> spreads one --load run over n generator processes and merges their results into one summary, for when a single Node process rather than the server is the bottleneck.

How it works

  • Parent: the CLI the user ran connects once, so any login is done first. It then re-runs its own command (process.argv, minus --load-workers) as n forked children with MCP_INSPECTOR_LOAD_SHARD=<i>/<n>, and waits.
  • Worker: takes its share with shardLoadOptions. Concurrency, --load-requests and --load-rate are split as evenly as integers allow; everything else applies to every worker as given. It connects with stored credentials only, runs the shared engine, and sends { summary, raw } to the parent over IPC instead of printing.
  • Exact merge: LatencyRecorder, ErrorTally and OutcomeStats gain snapshot()/merge(). Recorders stay exact while both sides' samples fit, and fall back to adding bucket counts once either side has switched, so the merged percentiles equal one recorder fed every call (tested). Counts and rate figures add, and elapsedMs is the slowest worker's. The summary gains workers: n. Thresholds and --load-baseline judge the merged result through the existing code.
  • Stops: a worker's early stop (circuit breaker, stop on breach) makes the parent stop the rest with the same LoadStop. Ctrl+C or SIGTERM in the parent forwards an interrupt to every worker, and the merged partial summary still prints and exits 130. A worker that exits without reporting fails the run with its exit code (load_worker_failed) once the others have stopped.
  • {{seq}} / {{worker}} stay unique across processes (shardContext interleaves them).
  • Progress lines add up the workers' latest reports. Their p50 and p99 are the slowest worker's, since percentiles don't add; the final summary is exact.
  • Engine plumbing: a raw hook that hands the measured window's mergeable stats over as it ends, a shard option, and both threaded through runLoad / runLoadAcrossConnections / LoadRunExtras.

Scope decisions

  • One-shot CLI only. mcpdo runs the engine inside its daemon on a held connection, so there is no command for it to re-run as a worker. The mcpdo README and agent skill point at mcp-inspector --cli … --load-workers instead.
  • Refused combinations: --load-steps/--load-ramp, --load-interval, --load-connections, --load-churn, --load-subscribe and --output. Each produces per-stage, per-bucket, per-session or per-call output that would need a merge of its own. Also refused: stdio servers (each worker would spawn its own server) and n above --load-concurrency or --load-requests.

The CLI README has a new section; the mcpdo README and the agent skill are updated.

Tests

clients/cli/__tests__/load-workers.test.ts covers:

  • recorder/tally/stats merges (exact, histogram, mixed)
  • sharding, seq uniqueness, argv stripping and the refusals
  • mergeLoadWorkerResults over real engine runs (steps, warm-up, stops, rate figures)
  • progress merging
  • runLoadWorkers with fake workers (results, stop propagation, interrupt, worker failure)
  • runAsLoadWorker and processWorkerPort
  • an end-to-end run: the in-process CLI forks three real built-CLI workers against an HTTP test server, and the test asserts the merged counts and nine distinct {{seq}} values.

npm run local:gate is green.

🤖 Generated with Claude Code

@cliffhall cliffhall added the v2 Issues and PRs for v2 label Nov 5, 2026
@cliffhall
cliffhall requested a balanced review from Copilot November 5, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved worker-orchestration defects can break authenticated load runs, skew scenario proportions, delay circuit-breaker stops, and lose the expected interrupt exit status.

5 open issues
What changed in this PR

Adds --load-workers <n> to the one-shot CLI to distribute load generation across processes when a single Node process becomes the bottleneck, addressing #2914.

Changes:

  • Adds worker spawning, workload sharding, IPC result collection, progress aggregation, and stop forwarding.
  • Extends shared load statistics with snapshot/merge support and reports worker counts in summaries.
  • Adds merge, orchestration, and end-to-end tests, plus documentation explaining supported combinations and the mcpdo limitation.
File Description
skills/​mcpdo/​SKILL.md Directs users to the one-shot CLI for multi-process load generation.
core/​cli/​handlers/​load-workers.ts Implements worker orchestration, sharding, IPC, and summary merging.
core/​cli/​handlers/​load-test.ts Adds worker options, mergeable statistics, raw-stat hooks, and unique call identifiers.
core/​cli/​handlers/​load-latency.ts Adds latency snapshots and merging.
core/​cli/​handlers/​load-format.ts Displays worker-process counts in text summaries.
clients/​mcpdo/​README.md Documents why multi-process generation is CLI-only.
clients/​cli/​src/​cli.ts Parses and validates the flag and dispatches parent and worker execution.
clients/​cli/​README.md Documents usage, merged results, and incompatible options.
clients/​cli/​__tests__/​load-workers.test.ts Tests statistics merging, sharding, orchestration, and real worker processes.

Review effort: Balanced

Comment thread clients/cli/src/cli.ts Resolved
Comment on lines +99 to +103
...(options.requests !== undefined && {
requests: share(options.requests, index, count),
}),
...(options.rate !== undefined && { rate: options.rate / count }),
shard: { index, count },

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in d7f533d. scenarioPicker takes the shard, and worker i of n takes every n-th pick of the one weighted sequence, starting at i. The processes together therefore run the mix one picker would. Test added with your example (two 1:1 steps, two requests, two workers), which now calls each step once.

Comment thread core/cli/handlers/load-workers.ts Resolved
Comment thread core/cli/handlers/load-workers.ts Resolved
Comment thread core/cli/handlers/load-workers.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1, all five findings fixed in d7f533d:

  • The parent runs the tool preflight under auth recovery.
  • The scenario mix is sharded so the workers together keep the weights.
  • --relogin/--no-revoke are stripped from worker arguments.
  • The parent's interrupt now outranks a worker's stop.
  • A worker's early stop is relayed immediately via a new engine observe.stop hook.

Requesting round 2.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Worker sharding can exceed the requested start rate and severely distort weighted step proportions in duration-only runs with unequal step latencies.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Shard offsets fail to preserve the combined load-rate schedule

core/​cli/​handlers/​load-workers.ts:105

Dividing the rate leaves every process with an immediate first slot: --load-rate 1 --load-duration 1 --load-concurrency 4 --load-workers 4 can start four calls instead of one. Longer runs can also cluster starts rather than preserve the evenly spaced rate grid. Coordinate a shared start epoch and shard-specific slot offsets so the combined run preserves the requested pacing.

4 resolved since last review

Review effort: Balanced

Comment thread core/cli/handlers/load-test.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2, fixed in 9b54477:

  • Inline: the scenario mix is now balanced per worker (a rotated start, no stride). See the thread.
  • Previously missed (no thread), the rate burst: each worker's rate grid now starts offset by index × interval / count, so the workers interleave into the run's even spacing. --load-rate 1 --load-duration 1 --load-concurrency 4 --load-workers 4 now starts one call (test added), and the rate figures measure each worker's window from its own grid start. A shared wall-clock epoch across processes is not attempted: the processes start milliseconds apart, and the README now states that this shifts the grids by as much.

Requesting round 3.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active issues inflate the merged achieved rate by using offset-shortened denominators and skew argument coverage by coupling row selection to the interleaved worker sequence.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Keep argument-row cycling independent per worker

core/​cli/​handlers/​load-test.ts:1992

The interleaved seq also selects argument rows in loadArgsTemplate (load-template.ts:264), so with two workers and a two-row sequential --load-args-file, each process always uses just one row. In a duration-bound run with concurrency two, if those inputs take 1 ms and 100 ms respectively, the alternating workload becomes roughly 100:1. Keep each process's row-cycling position separate from the globally unique placeholder sequence so every process exercises the full argument cycle.

1 resolved since last review

Review effort: Balanced

Comment thread core/cli/handlers/load-test.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 3, fixed in e59cf8b:

  • Inline: the merged achievedRate is now computed over a common window.
  • Previously missed (no thread), argument rows: LoadCallContext gains an optional row (not a placeholder), which shardContext sets to the process's own call count. A sequential --load-args-file therefore cycles every row in every worker while {{seq}} stays globally unique. Test added; README updated.

Requesting round 4.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Inconsistent achieved-rate denominators across request-capped shards underreport an unsaturated 4/s schedule as 3.04/s, requiring a common-window calculation and regression coverage.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread core/cli/handlers/load-workers.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 4, fixed in d03981d: the merged achieved rate is now computed over the run's own window, request-capped runs included. Requesting round 5.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Request-capped runs with unequal worker latencies can report an inflated achievedRate because the measurement window excludes some counted request starts.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread core/cli/handlers/load-workers.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 5, fixed in e10604a: the merged rate window now covers every worker's last start. Requesting round 6.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The afterLast clamp overstates achieved rate in saturated duration-bound runs; it needs request-exhaustion-only truncation and a regression test covering the duration-bound case.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread core/cli/handlers/load-workers.ts Resolved
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 6, fixed in 988b6c4: the merged rate window is truncated only when the requests ran out. Requesting round 7.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Correctness risks in multi-process interruption handling, worker cleanup, and baseline session-count validation require human assessment.

1 open issue
1 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 7 had no inline comments and nothing suppressed; the headline names no specific finding. The open issue it counts is resolved threads awaiting resolution. Closing the review loop on this round.

cliffhall and others added 7 commits November 5, 2026 16:07
…ix; relay stops at once; strip --relogin

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
…rio mix

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
…e per worker

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
…pped included

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall
cliffhall force-pushed the v2/feat/2914-load-workers branch from 988b6c4 to 05d0003 Compare November 5, 2026 21:12
@cliffhall
cliffhall merged commit 2c03413 into v2/main Nov 5, 2026
11 checks passed
@cliffhall
cliffhall deleted the v2/feat/2914-load-workers branch November 5, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--load: multi-process load generator (--load-workers) for higher throughput

2 participants