[diffs] Cache serialized file header HTML on recycled File and FileDiff instances#715
Merged
amadeus merged 1 commit intoMay 20, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Preserve serialized file header HTML while a virtualized File/FileDiff instance is recycled, and invalidate it when options or file/diff identity change. This avoids repeating HAST-to-HTML serialization for stable headers during large CodeView jumps. Experiments: #13 Metric: actionDurationMs 1415ms → 1345.2ms (-4.9%)
SlexAxton
force-pushed
the
autoresearch/diffshub-header-cache/01-header-html-cache
branch
from
May 19, 2026 22:58
116fd74 to
ed828c4
Compare
amadeus
deleted the
autoresearch/diffshub-header-cache/01-header-html-cache
branch
May 20, 2026 05:27
amadeus
pushed a commit
that referenced
this pull request
May 20, 2026
…ff instances (#715) Cache File and FileDiff header HTML across recycle Preserve serialized file header HTML while a virtualized File/FileDiff instance is recycled, and invalidate it when options or file/diff identity change. This avoids repeating HAST-to-HTML serialization for stable headers during large CodeView jumps. Experiments: #13 Metric: actionDurationMs 1415ms → 1345.2ms (-4.9%)
amadeus
pushed a commit
that referenced
this pull request
May 20, 2026
…ff instances (#715) Cache File and FileDiff header HTML across recycle Preserve serialized file header HTML while a virtualized File/FileDiff instance is recycled, and invalidate it when options or file/diff identity change. This avoids repeating HAST-to-HTML serialization for stable headers during large CodeView jumps. Experiments: #13 Metric: actionDurationMs 1415ms → 1345.2ms (-4.9%)
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.
Summary
This PR caches serialized file header HTML on recycled File and FileDiff instances.
Diffshub’s large-jump profile showed repeated work in applyHeaderToDOM, especially converting stable header HAST back into HTML during virtualized recycle. The rendered DOM is still rebuilt as before, but stable header HTML no longer pays repeated toHtml(headerAST) serialization cost while the same virtualized instance is reused for the same file or diff.
What changed
Added cachedHeaderHTML to:
Updated applyHeaderToDOM to reuse cached serialized header HTML:
Preserved the cache across virtualized recycle cleanup:
Invalidated the cache when header output may change:
Why
During CodeView jumps, virtualized items are cleaned up and remounted often. The header content for a given file/diff is
usually stable, but the old code serialized its header AST every time applyHeaderToDOM ran.
This keeps the visual and DOM behavior the same while avoiding repeated HAST-to-HTML conversion for stable headers.
Performance
Autoresearch profile:
Workload:
This benchmark jumps between sections of a large diff outside the current virtual window, so each target requires fresh
rendered code.
Correctness notes
This caches only the serialized header string, not DOM nodes. Header DOM is still created, replaced, and mounted through
the existing path.
The cache is cleared when options or file/diff identity changes, so custom header modes, metadata changes through new
file/diff objects, and non-recycle cleanup continue to render fresh header HTML.
Validation
The finalized branch was created with the autoresearch finalizer, which ran the repo’s precommit checks while committing:
tsgo --noEmit --prettyoxfmt --writeoxlint --type-aware --tsconfig tsconfig.oxlint.json --fixThe finalizer also verified that the review branch contains no autoresearch session artifacts.