Repository navigation
perf(objectql): memoize the cascade-delete closure on the registry object revision - #34437
Conversation
…ject revision Part of the bundle compile cost: the metadata read serves the closure beside every object, and it walked the whole registry per object per request. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oyZgRX9Qc1ZHsMRQp
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oyZgRX9Qc1ZHsMRQp
📓 Docs Drift Check6 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a741454f481f47f97626ffde431c42113413ae82 && git checkout a741454f481f47f97626ffde431c42113413ae82
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c9ef6538bf647d4ab7dabd0f04f5913193f88bc5 a61501aaae21fdf9d20fad658a364a3a4a64385a && git checkout -B drift-repro c9ef6538bf647d4ab7dabd0f04f5913193f88bc5 && git merge --no-ff a61501aaae21fdf9d20fad658a364a3a4a64385a
node scripts/docs-audit/affected-docs.mjs --json c9ef6538bf647d4ab7dabd0f04f5913193f88bc5 |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5oyZgRX9Qc1ZHsMRQp Final head for review: |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kcNtBBExhz4DZqYbi 席位核对 · ACCEPT (L1, first read; landing waits on CI) · Head-sha: a61501a · 2026-11-16T17:49ZL1 thread L1-a, routed by the seat for card #34206 (route C). I read the final-head comment 6924350511, dev report 6924328376, maintainer ruling 6920925378 (letter B: a metadata change signal plus a cache of caller-independent compiled results, and no per-caller bundle cache), route records 6919864431, 6919887033 and 6920972383, the PR body, and the full diff against merge base
Notes (not blocking)
Landing: not Tier H, and no L2 owed. The seat lands it once its checks are green. |
Requested by Leehom · project thread
Part of #34206 (route C, the first of three changes: C, then the ADR PR, then the shared compile cache, per ruling 6920925378 and claim amendment 2 6920972383). The card stays open after this lands.
Clause-②: no
Metadata-protocol: none
维护者速读
packages/objectql/src/engine-references-and-master-detail.ts末尾的getCascadeDeleteObjects与cascadeDeleteObjectsMemo说明块;packages/objectql/src/engine-cascade-delete-objects.test.ts末尾新增的 describe。pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-cascade-delete-objects.test.ts,预期 14 个测试全绿。What changes
ObjectQL#getCascadeDeleteObjects(the objects a delete of a record can cascade into, which the metadata read serves beside everyobjectitem ascascadeDeleteObjects) is memoized per engine on the schema registry's existingobjectRevision.undefinedand is not remembered, so the memo grows with the registered objects and never with what callers ask.packages/objectql/src/engine-references-and-master-detail.tschanges in the runtime. The rule (collectCascadeDeleteObjects,cascadeRelationsInto,cascadeRelationBehavior) is untouched, and so is the delete walk, which still reads the rule fresh.Why
The card's profile and the earlier report (6919782135) put the closure at about 47 ms of a Setup bundle call: an app bundle reads every object it names, and each read walked every registered object. The walk reads the registered object set and nothing else, and the registry already keeps a counter that moves on every change to that set, which the roll-up summary index and the record-currency parent lock already key on.
Closure inputs, re-verified on 9e6fee1 before the first edit
resolveObjectNameandgetObjectread the registry's object index (resolveObjectKey,resolveObject);getAllObjectsreads the merged objects.cascadeRelationBehaviorreads one field definition (statesDeleteSemantics,deleteWalkTargetOf), resolves its target through the same index, and asksisFederatedUnprovisionedInjectedColumn, which reads only the schema it is handed (isFederatedObjectandresolveInjectedColumnProvenanceare pure functions of the definition).withholdDisabledExtensions), andenablePackage/disablePackageboth callinvalidateAll, which moves the revision.objectRevision:registerObject,unregisterObject,unregisterObjectsByPackage,removeObjectOverlay,withdrawObjectExtension,invalidate,invalidateAll,reset. The refused-registration restore (noteObjectEntry's restore closure) drops the cache without a bump itself, but its only caller,restoringOnRefusal, runs it inside a synchronous registration and callsinvalidateAllright afterpoint.restore(), so the revision moves there too. The earlier report's note on that restore is answered by this.Tests
Seven pins in
packages/objectql/src/engine-cascade-delete-objects.test.ts, a new top-leveldescribein the closure's existing harness file:cascadeRelationBehaviorspy not called) and answers the same list;viewitem) keeps the memo (no walk) and the answer stays right, with non-vacuity asserts that the view landed and the counter did not move;undefined, and its later registration is answered.Ablations (
scripts/ablation-replace.mjs, each restored to the HEAD blobba03b08f,git diff HEADempty after each):memo.revision !== revisiondropped from the refill test)Package runs
pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-cascade-delete-objects.test.ts: Test Files 1 passed, Tests 14 passed.pnpm --filter @objectstack/objectql test: Test Files 603 passed (603), Tests 13477 passed (13477), exit 0.pnpm --filter @objectstack/objectql typecheck: exit 0;check:test-typecheck: OK, 39 files / 233 errors / 64 pinned signatures held intest-typecheck-debt.json(unchanged).Acceptance notes
db65 to 87 ms) and the full recompile; that is the shared compile cache's job (the third change), not this one.Verification
Same box, same build,
pnpm dev -- --freshshowcase, seeded admin,X-OS-Debug-Timing: 1,metamember ofServer-Timingin ms. "Before" is this branch with onlyengine-references-and-master-detail.tsrestored toorigin/main9e6fee1 and objectql rebuilt (dist checked: 0 hits of the memo's name, 4 after the restore). Shared box: other agents' work may have been running.Raw readings
Before, Setup: repeat 201.02 / 187.39 / 183.25 / 183.83 / 165.43 / 170.27; 304 168.97 / 158.21 / 167.23 / 171.11 / 170.15 / 177.99; reload 464.12 / 480.78 / 363.73; first call 953.69 / 889.24 / 822.17.
After, Setup: repeat 157.06 / 143.86 / 204.05 / 148.84 / 144.26 / 142.43; 304 152.45 / 153.17 / 118.51 / 117.11 / 150.09 / 119.56; reload 329.69 / 365.96 / 355.66; first call 663.82 / 780.87 / 737.67.
Before, showcase_app: repeat 65.54 / 66.51 / 71.57 / 68.52 / 68.19 / 79.83; 304 77.19 / 68.62 / 75.6 / 67.98 / 101 / 77.63; reload 114.31 / 114.27 / 99.81.
After, showcase_app: repeat 73.99 / 106.76 / 63.87 / 66.49 / 64.4 / 77.97; 304 70.8 / 64.81 / 75.38 / 71.17 / 77.53 / 65.38; reload 82.84 / 92.1 / 77.31.
Gates (head a61501a)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 65 commands derived for this diff (49 by path, 9 by change kind, 9 whole-tree); all 65 run locally, each exit 0, recorded asCOMMAND :: exit CODE.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE: "65 derived famil(ies) accounted for — 65 run, 0 NOT-MEASURED (a DERIVED zero — all 65 recorded an exit code and none of them is 3)", exit 0.node scripts/check-nul-bytes.mjs: exit 0.git merge-tree --write-tree origin/main HEADagainstorigin/mainc9ef653: clean (exit 0);origin/mainhas not touched the closure files or the registry since the base. No open pull request touches the three files (39 open heads read; two old ones whose history this checkout lacks were read through their file lists, both empty).pnpm lint) are read from this PR's check runs, not re-run here.!in the title, no(narrowing)arm).Human Minimum
packages/specholds no runtime logic. (No spec change.)pnpm lintpasses. (CI runs it.)main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code