perf(sessions): extend transcript eviction grace from 20s to 3min - #76792
Open
arnohillen wants to merge 3 commits into
Open
perf(sessions): extend transcript eviction grace from 20s to 3min#76792arnohillen wants to merge 3 commits into
arnohillen wants to merge 3 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 |
2 tasks
Contributor
|
Reviews (1): Last reviewed commit: "bench(sessions): add a reproducible rehy..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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