Repository navigation
perf(plugins): release retired knowledge link parses - #185368
Conversation
Keep Markdown link extraction with the current parsed document instead of retaining obsolete body strings in a global FIFO. Preserve merged projections and guarded rereads of unsettled files. Add focused regressions and synthetic Knowledge worker coverage to the existing performance harness.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR ties Markdown-link parses to live Knowledge records and extends existing performance tools to measure document churn. Example: A Knowledge store contains 256 pages and repeatedly edits documents.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses retained Knowledge document bodies that current main still caches; no actionable correctness or security defects were found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherKnowledge scans guarded vault files into validated records, extracts document links, and resolves them against eligible records for navigation, connections, and diagnostics. flowchart LR
A[Vault files] --> B[Guarded scan and validation]
B --> C[Parsed record owners]
C --> D[Merged record projections]
C --> E[Weak link parse cache]
D --> E
E --> F[Scoped link resolution]
F --> G[Navigation and diagnostics]
Technical reviewBest possible solution: Keep link extraction with the existing parsed-record lifetime while preserving merged-projection reuse and complete file validation. Do we have a high-confidence way to reproduce the issue? Current main demonstrably retains complete obsolete body strings as global cache keys until FIFO eviction; the PR additionally reports a baseline Gateway heap census, but no target code was executed during this review. Is this the best way to solve the issue? The change fixes the retaining owner directly, removes the superseded FIFO, and keeps necessary reuse through existing record copies; its new flags configure diagnostic scripts only. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ef1df2f79516. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +14, Tests +77, Docs +11, Other +125. Total +227 across 9 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 26, 2026, 11:21 PM ET / October 27, 2026, 03:21 UTC. |
Keep Markdown link extraction with the current parsed document instead of retaining obsolete body strings in a global FIFO. Preserve merged projections and guarded rereads of unsettled files. Add focused regressions and synthetic Knowledge worker coverage to the existing performance harness.
What Problem This Solves
Knowledge workers retain obsolete document bodies after edits because the global Markdown-link cache keeps up to 20,000 full body strings.
User Impact
Knowledge uses less retained heap as documents change. Link resolution, merged-page references, filesystem validation, and store access rules remain unchanged. No configuration or migration is required.
Why This Change Was Made
Tie extracted links to the existing parsed-record lifetime with weak keys, replacing the global body-keyed FIFO. Shallow scan copies and merged projections share that owner. Recently modified files still undergo the complete guarded reread and validation; identical freshly read bytes can reuse their link parse without admitting a cached record read.
Production code is net +14 lines across three files. The additional ownership handoff preserves reuse for merged projections and unsettled files; the old FIFO and eviction policy are removed. The remaining changes add synthetic Knowledge coverage to the existing performance tools and regressions.
Evidence
The baseline includes the earlier worker import reduction in #185169. A fresh isolated Gateway ran 10,800 synthetic sessions, 65 WebSocket clients, 40 default plugins plus Knowledge, concurrent mock-provider turns with tool calls and native subagents, and sidebar/list/search churn. Its Knowledge store contained 256 synthetic pages of approximately 14 KiB, with 25 edits per round. After 10.5 minutes, its storage worker retained 38.9 MiB after GC; the body-keyed cache held 531 document versions (7.1 MiB of key strings). The snapshot analysis is aggregate-only and ephemeron-aware; key-string bytes are a census, not an exclusive dominator claim.
Built storage-worker protocol, 256 pages, 3,000 catalog operations per side with one document edited every 10 operations:
This is a small retained-heap improvement, not a CPU or allocation improvement. Host load varied substantially (1-minute load at arm start/end: base 78.70→77.54, candidate 76.03→88.00), so wall-time changes are not claimed as speedups. Minor collections were 394→395 and major collections 22→22; major pause tails are context-only. GC/min changed 275.56→306.36 ms because the same work finished sooner, an absolute +30.79 ms/min. Owner GC by kind: minor total 1,241.39→1,027.39 ms, maximum 152.80→92.13 ms; major total 500.16→390.79 ms, maximum 129.47→127.51 ms. Worker loop p99 was 44.24→26.31 ms (117,863/113,050 samples).
The full Gateway runs also confirm the retention reduction: Knowledge post-GC heap 38.885→35.469 MiB (−3.416 MiB, −8.78%), and snapshot heap 38.856→35.434 MiB. Both completed 40 mock turns and 40 tool calls/results. The candidate snapshot has no full-body string keys in the link cache, versus 531 in the baseline. Total string shallow bytes fell 23,082,372→18,818,996.
Whole-Gateway timing is inconclusive as a causal comparison: mean 1-minute host load was 18.319→94.548 (candidate range 77.264–125.075). The numbers below are reported, not hidden, but do not establish a regression or speedup; no adverse verdict is made without A/A controls. No A/A controls were run, so these host-contended timing samples do not support an adverse or favorable whole-Gateway verdict.
sessions.listclient p99Main GC detail (base→candidate): minor 633→536 collections, 1,136.88→7,690.56 ms total, maximum 11.17→322.80 ms; major 34→18 collections, 774.41→3,430.28 ms total, maximum 45.22→592.30 ms; incremental 34→18 collections, 32.06→67.45 ms total, maximum 1.33→43.16 ms. These full-Gateway GC figures share the host-load confound above. Knowledge status p95 was 238.14→4,530.94 ms with only 11 samples/side (including warmup), so it is context only; the fixed-work owner comparison has 3,000 operations/side.
Handler histograms contain 1,173 observations per side; interpolated p99 lies in the 60–80 ms and 500–600 ms buckets. Storage-worker evidence is complete; the broader diagnostic census is incomplete because Git workers retired and were replaced. A separate canonical allocation pair completed on fresh fixtures (inclusive V8 sampling at 512 KiB; GC/latency in this mode are diagnostic only):
sessions.listcallsSampled main allocation rose 0.944 MiB/s (+4.18%); this is not a main-thread allocation win. The single serial pair also ran under different host loads. The measured benefit is lower retained Knowledge-worker heap, with no CPU or allocation-saving claim.
Artifacts compare
ce069f9f837471069b3a35df1e7c05953ea792abagainst the same build inputs plus this production patch. The branch was subsequently rebased cleanly onto current main; exact-head CI passed on97f9785ddfd00a3e0d96789c9943d1f3fec03360. Earlier candidate measurements exposed excess parsing for unsettled files; that version was superseded by the reviewed ownership handoff above.Validation completed: 33 focused Knowledge tests passed (
markdown-links,real-vault,source-descriptor-integration); the earlier merged-reference sibling run passed all 20 tests; canonical stress-controller tests passed all 26 tests. Both eager-import and PR-wrapper source closure guards passed (29 tests), export-name collision checks passed, changed-file type-aware lint and formatting passed, and the full runtime artifact build completed successfully. PR CI supplies broad validation.The focused live-record churn regression fails on the baseline because unrelated documents evict a still-live record's parse. Additional coverage checks merged projections, changed bodies, and guarded rereads of unsettled files.
Independent subagent review (autoreview route unavailable): the configured Codex helper refused its route preflight; the authorized isolated reviewer found no actionable P0–P2 findings, including in the subsequent unsettled-file ownership fix. The reviewer also checked the final rebased head and found no actionable integration findings. No operator configuration was changed.
RSS is process-wide and cannot be honestly assigned to an individual worker. This proof uses synthetic local state, never a live deployment or production data.