Repository navigation
perf(sessions): share history reader adapters across retained reads - #182200
Conversation
|
🦞👀 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. |
eca70be to
f1d4fb6
Compare
f1d4fb6 to
7ec838c
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR shares stateless history-reader methods while retaining a separate request runner and cleanup lifetime for each reader. Example: Open the same session history repeatedly.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it is an owner-backed allocation reduction with no actionable introduced correctness or security defect found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherHistory, transcript, board, and inventory callers enter the retained history-reader owner, which admits work to the selected database worker and returns projected results before releasing custody. flowchart TD
A[History and board callers] --> B[Retained reader owner]
B --> C[Shared reader methods]
C --> D[Per reader request runner]
D --> E[Admission and database worker]
E --> F[Projected read result]
F --> A
Technical reviewBest possible solution: Keep the shared method table on the existing retained owner, with receiver-preserving adapters and direct single-reader cleanup. Do we have a high-confidence way to reproduce the issue? The base factory visibly reconstructs the reader closures and the runtime copies their table on every retained read; no target code was executed during this read-only review. Is this the best way to solve the issue? The change removes repeated construction using the existing reader and resource owners, preserves enumerable decorators, and updates the detached adapter without adding a cache or another lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 56d79851163c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +7, Tests +23, Docs +29, Other +194. Total +253 across 9 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 24, 2026, 12:48 AM ET / 04:48 UTC. |
…penclaw#182200) * perf(sessions): share history reader adapters across retained reads * test(perf): measure history reader construction allocations * test(perf): register trusted source benchmark lint exception
What Problem This Solves
Repeated transcript reads rebuild the complete history-reader method table and its projection/preparation closures, then copy that table into a second owner object. Single-database reads also allocate the batch helper's target, retained-reader, mapped-owner, and reversed cleanup arrays.
User Impact
No intended user-visible behavior change. History, transcript, board, and inventory readers keep their existing results, admission, cancellation, revocation, and cleanup boundaries.
Why This Change Was Made
Create the stateless reader adapters once and carry the request runner as an own property on each retained reader. The runner still captures that read's database options, lane, and known-source state. Own methods remain enumerable for existing reader decorators. Preserve the receiver in the transcript execution adapter, add
assertCurrentwithout copying the table again, and let single-database callers retain/release directly.No new cache, retained database scope, schema, configuration, or invalidation mechanism. Production source grows by 7 lines to make the shared methods' receiver explicit; the allocated closure graph and redundant single-reader batching disappear. Most changed lines are the method table moving out of the factory.
Evidence
git diff --checkpassed. Changed-file lint passed. The benchmark also passed syntax/lint, 22 closure tests, and the export-name guard; its independent review is clean. CI initially caught the missing explicit allowlist entry for the benchmark’s documentedno-implied-evalexception; that exact one-entry repair was independently reviewed, and all 14 tests intest/scripts/lint-suppressions.test.tsnow pass. The trusted source file is already executable input; no production execution boundary was weakened.Unprofiled elapsed pairs (baseline → candidate, µs/setup): 2.0081 → 1.2800; 2.1170 → 1.2629; 2.1709 → 1.4302; 2.1098 → 1.3852; 2.0426 → 1.3036. Sampling includes objects collected by minor and major GC; its timing is not a gate. Elapsed medians were 2.1098 → 1.3036 µs, ranges 2.0081–2.1709 → 1.2629–1.4302 µs.
Scope: exact reader factory plus the extracted owner-construction expression, with synthetic runner sanity checks. The capsule's unused collaborator imports throw if invoked. Admission, SQLite, worker execution, the removed singleton batch wrapper, Gateway latency, and live deployment gains are not measured. Per-kind GC, promotion, event-loop tails, and both max pauses were not collected; there is no GC verdict or GC-based rejection, so no A/A GC gate is claimed. This is the requested structural simplification, with a measured setup allocation reduction and unchanged behavioral contracts.
Reproduce each side using its pinned files (baseline captured from
3bcc91708d8ee794e52f9cb0ae98ebb1f848ad25; these two modules also match the current base):Copy the matching
session-transcript-worker.types.tsbeside the reader. Use the documented start-file barrier for concurrent pairs; run--allocations --operations 100000separately. Workload SHA-256:a8045717ce7ed60ebe25bc9584d3819b4c9870acc266318580ee049c38d85963. Benchmark/tooling adds 194 lines and its README adds 29; production is +7 lines, with no new owner/cache or compatibility path.