Repository navigation
performance: a 2x workspace-status budget for a single-resource trace, met and checked in CI (#4032) - #4065
Merged
Conversation
…from one walk each, with a time budget checked in CI (#4032) A trace of packages/core/src/cli/main.ts on chant's repo took 6.4 to 6.9 times as long as workspace status, about 19 s. Most of it was 3474 git merge-base --is-ancestor processes: SignerPositions placed each commit on the base's first-parent line by a binary search of ancestry checks. It now reads the parents of everything the base reaches once and answers each full commit id from a map. descendants() reads the children of the revision once instead of one rev-list --ancestry-path per decision, and the ssh attestor takes the object format from the commit's tree line instead of a rev-parse per commit. Output is unchanged. scripts/bench-trace.ts times three traces against workspace status, median of 5 interleaved runs, and fails over 2x. It runs in the check job on a full clone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4032
A single-resource trace now meets a budget of 2x
workspace status, and CI enforces it. A trace of the most edited file went from about 19 s to about 2.8 s, with byte-identical output.Baseline (before)
chant 0.124.27 at
dd79deae731a5b8bd4e738ca06f83efdd4ad1b22, 2525 commits, full clone; Apple M5 Pro (18 cores), macOS, node v24.13.1; CLI from source (node --import tsx packages/core/src/cli/main.ts); median of 5 interleaved runs after one warm-up.workspace status prod --jsongraph --intent packages/core/src/cli/main.ts --json(233 commits)graph --intent LICENSE --json(1 commit)graph --intent packages/core/src/workspace/intent.ts#intentGraph --jsonThe dominant cost
The
cli/main.tstrace started 3760 git processes, and 3474 weregit merge-base --is-ancestorfromSignerPositions.lookupintrust/rotation.ts: a binary search of about 12 ancestry checks per commit to find where it entered the base's first-parent line.recordProvenancemade the same calls for every decision record. After the fix the trace starts 134 processes.trust/rotation.ts:SignerPositionsreadsgit rev-list --parents <base>once and answers each full commit id from an in-memory map; refs and short ids still take the old path.intent.ts:descendants()reads a revision's children once instead of onerev-list --ancestry-pathper decision or work window, in an in-memory entry keyed by repository and full commit id.trust/ssh-commit.ts: the object format comes from the commit's own tree line instead of agit rev-parseper commit.chant/lifecycle.After
cli/main.tsLICENSEintent.ts#intentGraphUnder heavy machine load (load average about 30) the ratio stayed at 0.6x to 0.77x.
Budget and CI
The budget: a single-resource trace takes at most 2x
workspace status <env> --jsonon the same machine, median of 5 against median of 5. It is documented in a new "How long a trace takes" section ofcli/workspace-graph.mdx.scripts/bench-trace.tstimes the three targets and fails over 2x; it refuses a shallow clone and a missing base revision, since the trace would skip signature checks. It runs at the end of thecheckjob in.github/workflows/chant.ymlon every pull request and push to main, withfetch-depth: 0,git remote set-head origin main,pipefail, and its result in the step summary. It should add about 1 to 1.5 minutes. At--budget 0.5it printed OVER BUDGET and exited 1.Output equality
Old and new code at
--at dd79deae7, JSON and text: byte-identical for the three targets,trust/rotation.ts#SignerPositions,--intent --record ws-001,ws-078,ws-092, andworkspace records --at … --json(745 KB). Newancestry-index.test.tschecks every commit's placement against the old git path, and every pair againstgit rev-list --ancestry-path, in a temp repo with merges.Acceptance
workspace status), and met (0.85x to 0.98x).Checks
npx tsx scripts/typecheck.ts: no regressions (26 baselined)npx tsx scripts/check-lexicons.ts: no untracked tier-1 failuresGITHUB_SHA,GITHUB_RUN_IDandCIsetop/factory.e2e.test.tsfailureslint-docs-sentences(no regressions),lint-prompts,check-docs-diataxis,./scripts/build-docs.sh: passchant/lifecycle.For #4023 and #4025: the largest remaining cost is one
git cat-file commitper commit in the ssh attestor (86 forcli/main.ts, about 0.9 s); agit cat-file --batchread is the next step.policyAtBasebuildsSignerPositionstwice per trace. The bench targetsintent.ts#intentGraphby name.