Repository navigation
Description
What
chant <verb> costs about 800ms before it does anything, and a consumer that reads an estate pays that once per member per read.
behold shells the project's own chant — deliberately, because members pin different versions — so an N-member estate is N processes. On the 11-member Kubernetes estate behold measured in INTENTIUS/behold#367, that is ~8.8 seconds of CLI startup before a single line of graph work or one call to a substrate.
This issue is the ask INTENTIUS/behold#424 exists to make: not "behold is slow", but "here is the share of it that is chant's, measured".
The floor, measured
Mean of 3 runs each, chant 0.61.0, macOS arm64, warm filesystem. chant --help parses argv and exits — it does no graph work at all, so it is the floor every other invocation stands on.
| invocation | wall | floor's share |
|---|---|---|
chant --help (parse argv, exit) |
799 ms | — |
chant graph <8-node example> --format ir |
1048 ms | 76% |
chant graph <3-lexicon example> --format ir |
1513 ms | 53% |
chant graph . --live --overlay --env prod (1 member, AWS on a local Floci) |
1277 ms | 63% |
So on a small member, three quarters of the read is module load and argv parsing. The content cost is 249 ms for the 8-node example and 714 ms for the three-lexicon one; the live half against an emulator adds ~478 ms over the floor.
Per-member figures from behold's own read ledger agree: a 5-root Terraform member reads at 1144 ms and 1123 ms, queuedMs 0 both times, against the same ~800 ms floor.
Why it multiplies
behold cannot amortise it. It shells the project's own chant precisely because two members of one estate may pin different chant versions, so a single imported chant would graph one member's source with another's compiler. That is stated in src/member-ir.ts and it is not something behold intends to change.
What behold has already done, so this is not an ask about caller behaviour:
- a process-wide FIFO read budget, two concurrent by default, with in-flight sharing by read identity and per-subscriber cancellation (behold#367);
- a per-member source-IR cache keyed on source stamp, resolved chant and graph options, so a member whose source has not moved does not spawn at all (behold#307);
- removal of the browser's unconditional 3/8/15s follow-up reads (behold#367).
The remaining cost is per invocation, and it is chant's.
The other half, cited not re-measured
behold#367 measured chant's per-read Kubernetes discovery on an 11-member estate: 153s to observe, 147s on a repeated read with the source cache warm, and 217 API requests in 28s from a single member. Those figures are that issue's, reproduced here for scale rather than re-run — reproducing them needs a cluster, and this machine's kube context belongs to something else.
The floor above is fresh and side-effect-free; the discovery figure is prior work, attributed.
The ask
- Is the ~800 ms startup reducible — a lazy CLI module graph, a smaller entry point for read verbs, or a compiled entry rather than
tsxon the published bin? A read verb that answered in 200 ms would take ~2.2s off an 11-member estate before anything else changed. - Is there an interest in a long-lived read mode — one process answering many graph reads for one project — that would let a consumer amortise the floor without importing chant and losing per-member version fidelity?
- Separately, the Kubernetes discovery cost in behold#367 is chant's k8s reader, not behold's caller behaviour. Worth its own issue on that side if the numbers above are accepted.
Method, so it can be re-run
chant --help # the floor
chant graph <project> --format ir # source evaluation
chant graph <project> --live --overlay --env <env> # source + substrate
behold's own per-read breakdown is on GET /api/doctor?reads=1 (behold#420/#421): source and live phase totals, per-member samples with running and queued milliseconds, and a count of members the ledger cannot see.
Refs INTENTIUS/behold#424, INTENTIUS/behold#419, INTENTIUS/behold#367.
Activity
lex00 commentedon Sep 18, 2026
Partial measurement, and what I could not measure, from the behold side (INTENTIUS/behold#424).
The tooling floor, measured
The published bin is
exec npx tsx "$MAIN_TS" "$@", so every invocation pays two layers before a line of chant loads. On macOS arm64, warm, mean of 3-5:node -e ""tsx -e ""(the bin directly)npx tsx -e ""So
npxcosts roughly 120 ms over invoking tsx directly, and tsx costs roughly 140 ms over bare node. Against the ~800 mschant --helpI measured for #2481, that is about 15% of every invocation spent resolving a binary the package already depends on, and another ~17% in the transpiler before any chant module is read.The remaining ~500 ms is chant's own module graph being transpiled and loaded, which is the part that actually needs the lazy-entry work the issue describes.
What I did not do, and why
I did not change the bin. The obvious move is to resolve tsx directly rather than through
npx, but it is not a one-liner worth guessing at:npx tsxworks regardless of hoisting, and a direct path (../../.bin/tsx) or anode --import tsxentry each make assumptions about the consumer's install layout that want testing against a realnpm i @intentius/chantrather than a workspace checkout.just smoke-npmis presumably the lever for that.I also could not produce a reliable before/after. My machine stopped being a usable measurement environment partway through — the same
chant --helpthat measured 799 ms this morning was exceeding ten minutes by the afternoon, after a fulljust checkand a lexicon regen. Shipping a perf change I cannot measure would be the wrong thing, so the numbers above are the contribution rather than a patch.Suggested split
The
npxlayer and the module graph are independent and differently sized. The first is a packaging question with a ~120 ms answer and a smoke test to prove it; the second is the real work. Worth two issues if that matches how you would take it on.Refs INTENTIUS/behold#424.
lex00 commentedon Sep 19, 2026
Correcting my comment above, and replacing the part I said I could not do.
The correction
I wrote that my machine "stopped being a usable measurement environment" and that I could not produce a reliable before/after. That was wrong, and the mistake was mine rather than the machine's: I had been timing the chant source checkout, where every invocation transpiles the whole monorepo (5:33 wall, 320 s user CPU). The published package — what users actually run — measures cleanly and repeatably at ~800 ms. I conflated the two and blamed the hardware.
So the experiment I declined to run was runnable the whole time. Here it is.
The result
Three bins against the same installed
@intentius/chant,--help, mean of 7 warm runs on macOS:npx tsx main.ts(ships today)node node_modules/tsx/dist/cli.mjs main.tsnode --import tsx main.tsnode --import tsx/esm main.tsThe floor I measured earlier holds up:
npxis ~250 ms of bin resolution, and tsx's own CLI then spawns a second node. Pointing--importat tsx's loader collapses both.Confirmed in a clean
node:24-slimcontainer against a realnpm installof the packed tarball: 598 ms → 425 ms, −29%, with all 326 lines of--helpdiffing clean. On a real read rather than--help,graph <project> --format irgoes 928 ms → 696 ms.tsx/esmis the fastest but the wrong choice: it registers only the ESM hook, and chant callscreateRequirein about ten places including the two that load user files (config-import.ts,cli/plugins.ts).--import tsxkeeps the CJS hook and is still ~30% off.On the lever I said I'd need
I said
just smoke-npmwas the thing to prove this against a real install layout rather than a workspace checkout, which is why I wouldn't guess at a patch. I've now run it: 72 passed / 6 failed, identical before and after. The six are the pre-existing k8s microservice example failures (ingress.ts,Cannot read properties of undefined (reading 'split')) and are unrelated.behold's own suite — 2081 tests, most of which shell this bin — also passes unchanged, 4.0 s → 3.5 s wall.
PR: #2485. It only addresses the per-invocation floor; the "once per member per read" half of this issue, which is the scheduler and cache question, is untouched and is the larger win.
perf(cli): register tsx in-process instead of shelling npx (#2481) (#…