Repository navigation
🤖🤖🤖 perf(history): cache timeline labels and isolate hover updates - #82
Merged
Merged
Conversation
Timeline label formatters called value.toLocaleString(options) / toLocaleTimeString(options) on every call, each of which constructs a fresh Intl.DateTimeFormat internally — one of the most expensive browser ops. The timeline recomputes all tick labels on every render, which fires on every pointer-move frame while hovering the chart, so this was a top main-thread self-time hotspot. Cache formatters by locale + options and reuse them via .format(). Measured hover frame cost: ~657ms -> ~553ms avg. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Hovering the history chart previously requested a full panel render and repeatedly rebuilt timeline labels. Cache date formatters and scale data, retain toolbar date references, and send hover timestamps directly to the toolbar.
Type of change
Evidence
After: All pass; 215 scoped unit tests pass across 33 files.
After: The same benchmark averaged 16 ms per step. A final 40-step mouse sweep averaged 16.7 ms, handled all 40 hover events, and kept the toolbar marker synchronized. No long tasks were observed during the final five-second idle sample or sweep.
Testing
pnpm buildpnpm sb:buildpnpm formatpnpm lint:typesChecklist
Merge Danger
Door: two-way
Revert the commits and rebuild the bundle to restore the previous behavior.
Blast Radius: frontend
History panel hover markers, comparison markers, and timeline labels. Cache invalidation includes bounds, scale configuration, width, zoom, locale, and translation identity. No backend or persisted-state migration.