Skip to content

feat(load): add the smoke, stress and performance harness - #4589

Merged
yannickmonney merged 26 commits into
mainfrom
feat/load-harness
Oct 9, 2026
Merged

yannickmonney merged 26 commits into
mainfrom
feat/load-harness

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

A separate, manually started smoke / stress / performance test of a running Tale deployment: tools/load (@tale/load, run with node tools/load/src/cli.ts). Nothing here joins the merge gate; the new Load workflow is workflow_dispatch only.

Part Command Does
Mock provider mock OpenAI- and Anthropic-compatible provider that behaves like a real one: sampled time to first token and token rate, usage matching the content, prompt-cache hits, tool calls, reasoning, embeddings, a priced model catalog, 429/5xx/mid-stream faults and [[mock:…]] directives; node:cluster for throughput. Deliberately separate from the deterministic e2e gateway.
Seeder seed Users, credential accounts, minted sessions and memberships straight into SQL (one password hash for all), organizations through the API so the platform's hooks run, each configured for the mock (provider, credential, embeddings, a shared project). 20,000 users in ~15 s.
Scenario (driven by run) Seven personas (browser, chatter, task-worker, knowledge, admin, api-client, fuzzer) of faker-driven users in EN/DE/FR: the dashboard boot waterfall, held /events and chat streams, multi-turn chats with TTFT, tasks, uploads + knowledge search, admin chores, the REST API with keys, hostile input. Every route verified against the code.
Runner run, merge smoke / load / stress (breakpoint) / spike / soak / connections / signin-storm profiles across generator processes and --shard i/n; HDR histograms per route; Prometheus and pg_stat_statements before/after; thresholds → exit code; JSON + Markdown reports that merge exactly across shards.
Local stack stack up/down/status N api + M worker processes of the platform plus the mock, for horizontal-scaling runs on one machine.

Why

A million concurrent users cannot be judged by unit tests, and k6-style per-VU runtimes would need terabytes of RAM to hold a million open streams; an async TypeScript harness holds each user in tens of kilobytes and shards across generators. The runs it already enabled found the platform defects fixed in the two companion PRs.

Also

  • .commitlintrc.json gains the load scope; knip, the performance inventory, scripts/performance/README.md and CONTRIBUTING.md know the workspace; the platform's manual performance suite gains PERF-P16.

Review fixes (folded in)

Two adversarial review rounds; each fix is its own commit:

  • stack up starts each process in its role (ROLE, which the backend reads), binds the API processes to --host through a new BACKEND_LISTEN_HOST (not HOST: deployments already set that to the public host name), and watches workers through a 5 s settle window so a boot crash fails the stack.
  • An interrupted run (Ctrl-C) lets the orchestrator wind its workers down (e2e test); shard reports merge stage by stage and a harness failure exits 2; only a merged report claims "Merged from N shards".
  • Worker shares grow monotonically; smoke covers every persona; a healthy SSE stream reconnects the way a browser's EventSource does: after the server's retry: (jittered per stream once perf(platform): serve realtime streams from one shared reader per process #4590 lands), else the browser's default.
  • pg_stat_statements deltas count a statement once across roles and nesting; the control loop folds only the windows it reads.
  • The mock bounds what a request can make it generate: per array, per string, and one total size budget for a tool call's arguments that charges every element, string, scalar, property key and enum/const value (nested arrays multiplied to ~0.5 GB before).
  • New metric writes_unheard: task writes whose realtime hint never reached the writer's own stream.

Testing

  • bun run --filter @tale/load typecheck|lint|test — 179 tests (mock wire formats, client, seeder rows, personas against a fake platform, runner, report merge).
  • Live: seeded 300 / 20,000 / 60,000-user plans; a 30-user smoke and a 300-user load run passed every threshold; 3,000-user runs drove the profiling behind the companion PRs. actionlint clean on load.yml; repo-wide knip clean.

A separate, manually started test of a running deployment: a realistic
OpenAI- and Anthropic-compatible mock provider, a bulk seeder (SQL
identities with minted sessions, organizations through the API), seven
personas of faker-driven virtual users with their journeys, a runner with
smoke/load/stress/spike/soak/connections/signin-storm profiles across
generator processes and shards, exact report merging, a local multi-process
stack launcher, and the dispatch-only Load workflow.
The manual performance suite gains PERF-P16 (the smoke profile), its
automation row names what the harness's own tests own, and the
measurement guide and CONTRIBUTING send deployment-scale questions to
tools/load instead of saying no load test exists.
…ency

Knip's check counts an export no other module imports as dead; the
harness's tests are now its entries, the module-local constants and
helpers lose their export, and five declarations nothing used go.
The run command could turn certificate checks off for self-signed
targets. Drop the switch: a target behind a private authority trusts
it through NODE_EXTRA_CA_CERTS and stays verified.
A cache_control breakpoint on the system block is the usual Anthropic
pattern, but the mock only remembered prefixes ending in a message, so a
single-turn request never read its system prompt from cache. Tools and
the system prompt are now a prefix of their own.
The OpenAI and Anthropic clients parse, accumulate and raise exactly what
a real provider would make them: buffered and streamed replies with
usage, tool calls with schema-valid arguments, reasoning and signed
thinking, prompt caching, max_tokens, rate limits, outages, mid-stream
errors and missing keys. Unit tests pin option precedence, directives,
latency calibration, chunking, the cache rules, stream capacity and
stalls.
The launcher set TALE_ROLE, which only the container's entrypoint maps
to ROLE; the backend reads ROLE, so every api and worker process ran
every role. It now sets ROLE (and TALE_ROLE alongside), and a worker
that exits at boot fails stack up instead of going unnoticed.
Ctrl-C reaches the whole process group, and the forked workers had no
handler, so every worker died at once: no stop, no final snapshot, no
wind-down, and the report listed each as failed. Workers now leave the
signal to the orchestrator, which stops them over IPC; an orphaned
worker still exits on the IPC disconnect.
A merged report copied the first shard's stages and breaking point, so
a 50-shard million-user run claimed to have held through one shard's
load. Stages now sum every shard per index (the slowest shard's p95 as
an upper bound, held only where all held) and the run breaks at the
earliest shard. A crashed, failed or killed generator exits 2, as the
README promised, instead of reading as a threshold failure.
…sona

- splitTarget floored proportional shares, so a rising target could
  lower one worker's share: a live user stopped while another worker
  started its replacement, and a full worker asked to take a user back
  threw. Users are now dealt round-robin, which only ever raises a
  share; a pool with no free index starts the rest on its next call.
- stopAll waited only for users still live, not those a falling
  target had stopped, so a load run's wind-down waited for nobody.
- Smoke drew 14 personas by hash and usually missed some, the same
  ones every run; it now deals them out on one process and reports
  the users it actually runs as its peak.
The reconnect attempt reset on every event, heartbeats included, so a
stream dropped by a deploy came back within a uniform second: a whole
generator's streams in one wave, unlike the browsers it models. A
healthy stream now waits the server's retry (or EventSource's 3 s
default); only one that keeps failing backs off with full jitter.
pg_stat_statements keeps a row per user, database, query and top
level, and the diff keyed rows by query id alone, so a statement run
by two roles or both nested and at top level was diffed against the
wrong baseline. The read now sums the rows of each query.
- A tokens directive is cut to the request's ceiling before the reply
  is generated, not after: a huge one froze the event loop.
- A schema's minItems and minLength are met up to 50 items and 4,096
  characters.
- An undecodable model id answers 404, not 500.
- In cluster mode each worker admits its share of the stream limit;
  the prompt cache is documented as per process.
- The LRU test now tells LRU from FIFO.
stack up advertised --host as the interface its processes listen on,
but the backend had no listen address and bound every interface — an
open-sign-up stack reachable from the local network. The API now
takes an optional HOST (unset: every interface, as a container
needs), and stack up passes its --host.
Each progress line and stage close re-merged every worker's whole
series, decoding and re-encoding every window histogram of the run on
the 1 s control loop, so the cost grew with run length. They now fold
the windows they read; the final report still folds everything.
Hint latency only measured the hints that came. A task write made while
its organization had an open stream in the process now counts as
watched, and as unheard when no stream of the process heard it within
60 s: a hint the platform lost, told apart from a slow one.
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 9, 2026
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 9, 2026
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 9, 2026
@yannickmonney
yannickmonney marked this pull request as draft October 9, 2026 04:38
Deployments already set HOST to the public host name, which no interface answers to, so binding to it would stop the API from listening. The listen interface is BACKEND_LISTEN_HOST.
With one API the liveness check ran right after the workers spawned, too early to see one crash at boot.
Per-array and per-string bounds multiplied through nested arrays to about half a gigabyte; one budget of elements and characters now covers the whole value.
A merge of merged reports claimed as many shards as reports it took, and one report folded alone claimed a merge.
Only array elements and generated strings were counted, so nested arrays around an enum or const leaf or a wide object still built hundreds of megabytes. Optional properties stop once the budget is spent; required ones stay so the call validates.
The event and progress streams send a per-stream jittered retry: once the shared hint hub lands; the earlier note checked a base without it.
The interrupt test drives its fixture by path, which knip cannot follow; mergeStages is used only inside the report module.
@yannickmonney
yannickmonney marked this pull request as ready for review October 9, 2026 06:22
# Conflicts:
#	services/platform/tests/manual/reference/automation.md
#	services/platform/tests/manual/suites/performance.md
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