perf(sessions): extend transcript eviction grace from 20s to 3min - #76792
perf(sessions): extend transcript eviction grace from 20s to 3min#76792arnohillen wants to merge 5 commits into
Conversation
Twenty seconds after navigating away from a settled task, its parsed transcript is freed and the next visit pays a full log read and re-parse. That turns ordinary task flipping into repeated multi-second reloads. Three minutes keeps recently viewed transcripts warm while still freeing memory for genuinely backgrounded sessions. Generated-By: PostHog Code Task-Id: 5d24ea17-aec0-4334-884e-c2639867e260
Reconciling a task with a log_url but no workspace path hydrated the full transcript into the store without arming the idle-session eviction that connectToTask and the cloud reconcile branch run, so logs-only residency was bounded by time alone. With the grace now at 3 minutes that gap would let a triage pass over many logs-only tasks stack unbounded transcripts; evict on this path like the others. Generated-By: PostHog Code Task-Id: 47cdc119-1c24-42ec-ac36-74c43cdd7f4e
Quantifies the store-side parse a task flip re-pays after eviction, which is the cost the longer grace avoids. Not run in CI (test globs only match *.test.*); rerun with pnpm vitest bench in packages/core. Generated-By: PostHog Code Task-Id: 47cdc119-1c24-42ec-ac36-74c43cdd7f4e
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Reviews (1): Last reviewed commit: "bench(sessions): add a reproducible rehy..." | Re-trigger Greptile |
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the |
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
HostHog preview —
|
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the |
Keeps the 3 min transcript eviction grace alongside the new resident background transcript cap from master. Generated-By: PostHog Desktop Task-Id: 341e450d-132c-42dd-abf2-52b22f99c3f6
🤖 CI report✅ Trunk lane — non-backend laneThis PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes. |
There was a problem hiding this comment.
Approved.
Contained perf tuning to a desktop session-eviction timer plus a bounded-budget fix on the logs-only reconcile path, with new/updated tests covering both; no risky territory (no auth, billing, API, CI, deps, or data migration) so no independent assurance is required despite cross-team authorship.
- 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 91L, 2F substantive, 125L/4F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (125L, 4F, single-area, perf) |
| stamphog 2.0.0b4 | .stamphog/policy.yml @ 49406a2 · reviewed head 49406a2 |
Ports PostHog/code#3978 onto
products/desktop/after the desktop import (the code repo'smainis frozen). Original commits and authorship are preserved viagit am.Problem
Part 3 of the task re-open latency work (see #76788, #76791). A settled task's parsed transcript is evicted 20 seconds after its view unmounts. Anyone flipping between a few tasks slower than that pays a full disk read plus a three-pass re-parse of the log on every return, which is seconds of main-thread work for large transcripts.
Changes
SESSION_EVENT_EVICT_GRACE_MSgoes from 20s to 3 minutes. Eligibility is unchanged: only disconnected, settled sessions with no pending prompt are evicted, and the eviction/rehydration machinery is untouched.The memory tradeoff is bounded: only transcripts viewed in the last 3 minutes stay warm, and everything else about the residency system (rehydrate on return, retry after failed reads) behaves exactly as before.
How did you test this code?
products/desktop/:pnpm install --frozen-lockfile,pnpm typecheck(24/24 packages), and the full@posthog/corevitest suite (247 files, 2970 tests passing).Automatic notifications
Docs update
Not applicable (desktop app internals),
skip-inkeep-docslabel applied.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
This PR is a port of PostHog/code#3978, recreated here by PostHog Code following the /porting-code-prs skill: patch series applied with
git am --directory=products/desktop/(original authorship and commit messages preserved; no lockfile changes in this one). Part 3 of 3 ported PRs on task re-open latency.Created with PostHog Code