Repository navigation
perf(sessions): avoid redundant actor entry writes - #175191
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR retains persisted row columns during actor hydration and combines run adoption with reducer persistence. Example: Adopt run current-run with startedAt 2 and activity updatedAt 20.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR removes redundant writes that remain on main, and review found no introduced correctness or security defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe session actor accepts ordered lifecycle commands, hydrates committed session facts, and uses the existing storage writer to persist changes and publish receipts. flowchart TD
A[Session callers] --> B[Session actor]
C[SQLite hydration] --> B
B --> D[Lifecycle and reducers]
D --> E[Existing entry writer]
E --> F[SQLite transaction]
F --> G[Committed receipt]
Technical reviewBest possible solution: Retain complete persisted comparison facts and perform one final entry write through the existing transaction owner. Do we have a high-confidence way to reproduce the issue? Source establishes both redundant-write paths on fetched main: immediate adoption persistence before reducers, and incomplete hydrated columns supplied to exact node comparison; no target code was executed during this review. Is this the best way to solve the issue? The patch addresses both causes within existing owners, preserves lifecycle checks and final admission, and leaves genuinely stale persisted columns eligible for repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6485b1906e73. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +92. Total +95 across 3 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 17, 2026, 2:04 AM ET / 06:04 UTC. |
Retain the already-selected persisted node columns in the session actor's committed row so its existing comparison skips unchanged writes after hydration. Strip aggregate actor projections from that retained row. Defer no-turn run-adoption persistence to the existing reducer tail, folding lifecycle and activity into one node/window write while preserving actor ordering, write receipts and synchronous SessionManager behavior. Validated with 56 focused actor tests, scoped type-aware lint and a clean Codex review. No schema or public API changes. Release-note context: reduce redundant session bookkeeping writes during run adoption and after actor hydration.
What Problem This Solves
Session run adoption can rewrite the same node and window twice within one actor command, and the first unchanged patch after hydration can rewrite a node unnecessarily.
User Impact
No user-visible behavior or storage contract changes. The session actor performs fewer redundant SQLite writes while preserving its ordering, receipts, row facts, and synchronous SessionManager SDK contract.
Why This Change Was Made
The entry writer already compares persisted columns and skips unchanged nodes and windows. Hydration selected those columns but discarded several before publishing the actor's resident committed row, so its next comparison could falsely detect changes. Retain those existing scalar columns while stripping the aggregate actor projections. No new query or payload projection is introduced.
Defer no-turn run adoption to the existing reducer tail, just as delivery and completion already do, so lifecycle and activity changes persist together once. This removes the intermediate write path without adding another cache or command API. Request fusion remains separate work.
Removed redundant work and accepted edges:
No security or lifecycle authority checks were removed. No schema, migration, dialect, SDK, update, or service-lifecycle changes.
Evidence
bbb775bd011b. Scanner/config/package and affected source blobs match the base and candidate; no candidate-only findings. Recorded with the main-failure owner.SQL measurement — complete
Three alternating pairs in order M1,C1,M2,C2,M3,C3, with ten warm turns per run (30 per revision). Base
82d97d2fada961b765957fb4ff862e81816d7a6f; candidate57ec0590b4989c046b56bbb37ca2b3ceedadcf70. Shared harness v3 was unchanged; Node/SQLite, compile-cache setting, source heads, runtime artifact bytes, workload completion, causal attribution, and process cleanup were validated for every run.No standard-workload saving is demonstrated. All 60 warm turns have the same turn-attributed counts by turn position. The workload does not exercise the combined no-turn adoption/activity case or the unchanged hydrated patch covered by the regression. No latency claim on the loaded host.
Values are median [min–max]; SQL includes every thread. Raw windows also include background work.
Whole-workload ranges overlap; the −2 median statements/requests are background timing variation, not a claimed optimization. Raw warm/first-turn MAIN spikes are the same 13 startup-maintenance lease reads moving between phase windows; turn-caused MAIN remains zero. Touched-scope T1 stays 0 → 0, and the full inventory stays 182 → 182 sites in 88 files.
Subsystem attribution
Every warm subsystem median delta is 0 statements / 0 requests. Family requests are distinct linked wire IDs and overlap across families; they are not additive. Reads are classified from full native execution stacks, not the compact analyzer’s representative stack. No saving is attributed to the variable cache-snapshot count.
The earlier owner reproduction on
b87b4590f54cf747472e8ebfef7cc40dcda3b627observed 2 node + 2 window writes for adoption plus activity and 1 node write for an unchanged hydrated patch. The current base retains those exact decision paths (source verified). This candidate passes 1 node + 1 window, 0 + 0 after hydration, and 1 + 0 when a stale stored column genuinely needs repair. The failing reproduction was not rerun on the current base; it is explicitly earlier-base evidence.Phase-specific raw counts
Each cell is median [min–max] across three runs. Phase windows include background timers; their shifts do not establish owner savings.