Avoid redundant cloning on fresh session store loads#60595
Avoid redundant cloning on fresh session store loads#60595efww wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryRemoves the redundant Confidence Score: 5/5This PR is safe to merge — the optimization is correct and the test validates the key aliasing invariant. The No files require special attention. Reviews (1): Last reviewed commit: "perf(sessions): avoid redundant clone on..." | Re-trigger Greptile |
|
This PR is intentionally minimal and only changes 2 files on top of the latest
The current failing Given that this branch is a clean 2-file session-store change, I believe the PR itself should be evaluated separately from those repo-wide extension/timeout failures. |
|
Thanks for the context here. I did a careful shell check against current Close as implemented on main: current main and release v2026.4.29 already avoid the redundant full-store clone on the hot locked session-store update paths via an explicit So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the current explicit Do we have a high-confidence way to reproduce the issue? Not applicable as a performance PR rather than a failing bug. The relevant behavior is source-verifiable on current main: locked update paths force a fresh disk read and opt out of cloning with Is this the best way to solve the issue? Yes. Current main is a narrower maintainable solution than the PR's blanket Security review: Security review cleared: The PR diff only changes session-store TypeScript logic and a unit test, with no CI, dependency, package, secret, or supply-chain surface touched. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3c4851037b6c; fix evidence: release v2026.4.29, commit a448042c2edd. |
Summary
loadSessionStore(..., { skipCache: true })already forces a fresh disk read, but it still returnsstructuredClone(store)afterward.On this path, the parsed store is not shared with the cache, so the extra clone is unnecessary. This change returns the parsed store directly when
skipCacheis true, while preserving the defensive clone behavior for normal cached reads.Why
Session store update paths currently re-read the full store from disk with
skipCache: true, mutate one entry, and then write the full JSON back out. The full rewrite is still the dominant cost, but the extra clone adds avoidable O(n) overhead on the read side of that hot path.Tests
corepack pnpm install --frozen-lockfileon Linuxcorepack pnpm protocol:checkon Linuxsrc/config/sessions.test.tsregression run attempted locally; final pass/fail should come from GitHub CINote
skipCacheminimal change insrc/config/sessions/store-load.tsandsrc/config/sessions.test.ts.