Repository navigation
perf: prevent markdown rendering remounts and re-parses - #1159
Draft
gmsgowtham wants to merge 1 commit into
Draft
gmsgowtham wants to merge 1 commit into
gmsgowtham wants to merge 1 commit into
Conversation
Parent re-renders and streaming markdown updates remounted and re-parsed the whole tree on every change. Derive stable, content-based React keys in a pre-parse token walk, stabilize hook options against inline object literals, and reuse parsed top-level elements whose token content is unchanged, so unchanged blocks skip re-rendering entirely. - assignStableKeys: content-derived keys (type:raw[@occurrence]) per token instance; avoids the duplicate-key flaw of hashing identical content - useStableValue + areHookOptionsEqual: inline styles/theme literals no longer invalidate the parse; colorScheme changes still flow through - ElementsCache: persist parsed top-level elements, keyed by occurrence-suffixed content key within a parser epoch (theme/style changes rebuild the epoch); caches hold elements, not untyped tokens - markdown.tsx: React.memo on computed data via useMarkdown; itemId via stable keys - Memoize the Markdown component and FlatList cells; key cells by stable element keys - add optional token param to RendererInterface and thread it from Parser so custom renderers can key nodes; registry components keyed from stable token keys Tests: 187 passed (+27 new), 93 snapshots unchanged, tsc + biome clean
Performance Comparison ReportSignificant Changes To DurationShow entries
Show details
Meaningless Changes To DurationThere are no entries Render Count ChangesThere are no entries Render IssuesThere are no entries Added EntriesThere are no entries Removed EntriesThere are no entries Stability
|
This branch has not been deployed
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.
Parent re-renders and streaming markdown updates remounted and re-parsed the whole tree on every change. Derive stable, content-based React keys in a pre-parse token walk, stabilize hook options against inline object literals, and reuse parsed top-level elements whose token content is unchanged, so unchanged blocks skip re-rendering entirely.
Tests: 187 passed (+27 new), 93 snapshots unchanged, tsc + biome clean