Skip to content

perf: benchmark and optimize large split review streams#76

Merged
benvinegar merged 9 commits intomainfrom
perf/benchmark-large-split-streams
Mar 23, 2026
Merged

perf: benchmark and optimize large split review streams#76
benvinegar merged 9 commits intomainfrom
perf/benchmark-large-split-streams

Conversation

@benvinegar
Copy link
Copy Markdown
Member

@benvinegar benvinegar commented Mar 23, 2026

Summary

  • move benchmark scripts and shared fixtures into benchmarks/ and document the benchmark workflow
  • add large split-stream benchmarks for cold/warm startup, note-enabled scrolling, and stage-level profiling
  • optimize viewport-scoped visible-note scrolling without changing the review-first behavior that notes remain visible while you mouse-scroll

Current behavior and findings

  • notes are viewport-scoped visible, not restricted to the selected hunk
  • the biggest cliff is still the note-enabled path on large split review streams
  • the best kept win came from caching note-aware section metrics by visible note set so placeholder height plans can be reused across scroll ticks

Measured results

Original note-enabled baseline

  • note-enabled 18-tick scroll: 16406.23ms

Selected-hunk-only experiment (discarded product direction)

  • note-enabled 18-tick scroll: 197.32ms
  • fast, but rejected because it hides notes when selection does not move during mouse scroll

Restored viewport-scoped-visible-notes baseline

  • note-enabled 18-tick scroll: 2009.15ms

Current kept result under viewport-scoped note visibility

  • note-enabled 18-tick scroll: 301.54ms
  • improvement vs viewport-scoped baseline: about 85%

Stage-profile sample

  • section metrics across 180 files: ~24.52ms
  • split row expansion across 180 files: ~12.87ms
  • note-enabled review-plan construction across 180 files: ~35.58ms

Main implementation changes

  • benchmark scripts now live in benchmarks/
  • benchmark result artifacts have a dedicated benchmarks/results/ location
  • viewport-scoped note visibility is preserved
  • note-aware section metrics are cached by visible note set to reduce repeated planning during scroll

Deferred ideas

  • replace the 50ms viewport polling loop in DiffPane with an event-driven scrollbox hook if OpenTUI exposes one
  • decouple note visibility planning from full buildReviewRenderPlan() rebuilds
  • consider a dedicated overlay/planning layer for viewport-visible note cards

Testing

  • bun run typecheck
  • bun run bench:bootstrap-load
  • bun run bench:highlight-prefetch
  • bun run bench:large-stream
  • bun run bench:large-stream-profile

…h before optimization; current 18-tick note-enabled scroll cost is 16406.23ms and still shows act warnings from deferred highlight work.\n\nResult: {"status":"keep","note_scroll_ticks_ms":16406.23}
…indowing active for the rest of the review stream; note-enabled 18-tick scroll drops from 16406.23ms to 647.48ms while the interaction test now follows notes as focus moves.\n\nResult: {"status":"keep","note_scroll_ticks_ms":647.48}
…holder windowing keeps accurate heights for the selected note-bearing file; note-enabled 18-tick scroll drops from 647.48ms to 231.25ms and the section-height helper now has note-row coverage.\n\nResult: {"status":"keep","note_scroll_ticks_ms":231.25}
…note-enabled 18-tick scroll improves further to 197.32ms, though the benchmark still occasionally surfaces deferred Pierre highlight act warnings that should be cleaned up separately.\n\nResult: {"status":"keep","note_scroll_ticks_ms":197.32}
…lected-hunk-only notes; under the broader visible-note policy the current 18-tick large-stream scroll cost is 2009.15ms.\n\nResult: {"status":"keep","note_scroll_ticks_ms":2009.15}
…ed visible notes reuse placeholder height plans across scroll ticks; under the restored always-visible note policy, the 18-tick large-stream scroll cost drops from 2009.15ms to 301.54ms while viewport-visible notes stay on screen.\n\nResult: {"status":"keep","note_scroll_ticks_ms":301.54}
@benvinegar benvinegar changed the title test: benchmark large split review streams perf: benchmark and optimize large split review streams Mar 23, 2026
@benvinegar benvinegar merged commit 2fc2308 into main Mar 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant