Skip to content

Latest commit

 

History

History
85 lines (62 loc) · 2.59 KB

File metadata and controls

85 lines (62 loc) · 2.59 KB

Gitree Performance Benchmarks

Summary

Operation Performance Notes
Load 34k commits 1.47s Was 778s before optimization
Navigation per keypress <1ms Virtual scrolling
Graph layout 1k commits ~300µs Linear history
Row render ~1.3µs O(1) per row

Phase 22 Optimizations (v0.4.0)

Issue 1: O(refs × commits) Loading

Before: Loading iterated through ALL refs (including remotes), causing:

  • 2,402 refs × 34k commits = catastrophic slowdown
  • Zed repository: 778 seconds (13 minutes!)

After: Load from HEAD + local branches only:

  • Zed repository: 1.47 seconds
  • Improvement: 556x faster

Issue 2: O(n) Navigation

Before: Every keypress re-rendered ALL rows.

After: Virtual scrolling renders only visible rows (~50):

  • Improvement: O(n) → O(viewport_height)
  • Navigation is instant regardless of commit count

Benchmark Results

Tested on: Apple M1 Pro, darwin/arm64

Git Operations

BenchmarkLoadCommits/commits_50      1.78ms    552KB   4154 allocs
BenchmarkLoadCommits/commits_100     3.67ms   1016KB   7825 allocs
BenchmarkLoadCommits/commits_200     7.68ms   1942KB  15164 allocs
BenchmarkLoadRepository (100)        3.67ms   1040KB   8125 allocs
BenchmarkLoadFileChanges             0.19ms    121KB    597 allocs

Graph Layout

BenchmarkBuildLayout_Linear/100        27µs     40KB    504 allocs
BenchmarkBuildLayout_Linear/500       140µs    208KB   2504 allocs
BenchmarkBuildLayout_Linear/1000      303µs    415KB   5006 allocs
BenchmarkBuildLayout_Linear/5000     1.76ms   2020KB  25018 allocs

BenchmarkBuildLayout_Branching/100     49µs     51KB    633 allocs
BenchmarkBuildLayout_Branching/500    867µs    837KB   5161 allocs
BenchmarkBuildLayout_Branching/1000  3.32ms   3142KB  12247 allocs

Row Rendering

BenchmarkRenderRow/any_size           1.3µs    88B      7 allocs
BenchmarkRenderViewport/20_rows      1.40ms   103KB   6364 allocs
BenchmarkRenderViewport/40_rows      2.89ms   210KB  12968 allocs
BenchmarkRenderViewport/60_rows      4.36ms   320KB  19812 allocs

Complexity Analysis

Operation Before After
Load commits O(refs × commits) O(local_branches × commits)
Navigation render O(total_commits) O(viewport_height)
Row render O(1) O(1)
Graph layout O(commits) O(commits)

Running Benchmarks

# All benchmarks
go test -bench=. -benchmem ./internal/git/... ./internal/tui/graph/...

# Specific benchmark
go test -bench=BenchmarkLoadCommits -benchmem ./internal/git/...