perf(diff): reuse evicted worker highlights - #791
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR adds a worker-local, byte-bounded LRU so syntax-highlight results can be reused after eviction from the terminal-side cache. It also introduces content-derived cache identities, transferable payload cloning, focused tests, and a cold-versus-warm benchmark.
Confidence Score: 4/5The PR appears safe to merge, with only a non-blocking formatting inconsistency in the newly added TypeScript. The cache identity, serialized request lifecycle, clone-before-transfer ownership, and eviction behavior preserve current highlighting correctness; the remaining accepted issue is limited to formatting consistency. Files Needing Attention: src/ui/diff/worker/highlightWorkerCache.ts and other newly added TypeScript files Important Files Changed
Sequence DiagramsequenceDiagram
participant T as Terminal
participant W as Highlight worker
participant C as Worker LRU
T->>W: Highlight request
W->>W: Hash rendering inputs
W->>C: Lookup cache key
alt Cache hit
C-->>W: Clone retained compact payload
else Cache miss
W->>W: Render and compact highlight
W->>C: Retain payload if within budget
W->>W: Clone retained payload
end
W-->>T: Transfer response buffers
Prompt To Fix All With AI### Issue 1
src/ui/diff/worker/highlightWorkerCache.ts:21-24
**Use prescribed TypeScript indentation**
The newly added worker-cache implementation uses two-space indentation instead of the applicable four-space convention, leaving the new TypeScript inconsistent with the repository's prescribed formatting.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "perf(diff): reuse evicted worker highlig..." | Re-trigger Greptile |
| constructor(maxBytes = MAX_WORKER_HIGHLIGHT_CACHE_BYTES) { | ||
| this.maxBytes = Number.isFinite(maxBytes) ? Math.max(1, Math.floor(maxBytes)) : 1; | ||
| } | ||
|
|
There was a problem hiding this comment.
Use prescribed TypeScript indentation
The newly added worker-cache implementation uses two-space indentation instead of the applicable four-space convention, leaving the new TypeScript inconsistent with the repository's prescribed formatting.
Context Used: guidelines.mdc Cursor rule (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/diff/worker/highlightWorkerCache.ts
Line: 21-24
Comment:
**Use prescribed TypeScript indentation**
The newly added worker-cache implementation uses two-space indentation instead of the applicable four-space convention, leaving the new TypeScript inconsistent with the repository's prescribed formatting.
**Context Used:** guidelines.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/guidelines.mdc))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
c5554be to
cbf2fc3
Compare
Merges main, whose new cache-layer benchmark (#791) landed importing the core/types shell that this branch melts; DiffFile now comes from its declaring module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XcuayyxJrwQd9EHpuxNef1
Summary
Validation
bun run format:checkbun run lintbun run typecheckbun test src/ui/diff/diffRows.test.ts src/ui/diff/worker/highlightCompact.test.ts src/ui/diff/worker/highlightWorkerCache.test.ts src/ui/diff/worker/highlightWorkerIdentity.test.ts src/ui/diff/worker/highlightWorkerClient.test.tsbun run bench:highlight-cache-layersv0.19.0 comparison
Seven fresh processes each highlighted the same 8,000-line TypeScript diff, then made five sequential identical worker requests.
The worker cache makes repeated direct worker requests about 159× faster in this controlled revisit workload. Cold performance is effectively unchanged.
bench:highlight-cache-layersalso tests the realprefetchHighlightedDiffpath: it makes eight unique 8,000-line requests (exceeding the 60k-line main cache) and revisits the first. Across five fresh-process samples, the resident main-cache hit remained 0.32 ms in both revisions; the post-eviction revisit fell from 233.24 ms on v0.19.0 to 3.25 ms on this PR. The main cache remains worthwhile: it is about 10× faster than a worker-LRU hit and supplies a highlighted snapshot during render instead of waiting for an effect.bun testwas also attempted; its three failures are pre-existing missing website test dependencies (@axe-core/playwrightand@playwright/test) in this worktree.This PR description was generated by Pi using gpt-5.6-terra