Skip to content

perf(hash-differ): stream-parse hash files to skip edges and deps - #22

Merged
honnix merged 1 commit into
mainfrom
honnix/diff-perf
Sep 29, 2026
Merged

honnix merged 1 commit into
mainfrom
honnix/diff-perf

Conversation

@honnix

@honnix honnix commented Sep 29, 2026

Copy link
Copy Markdown
Member

CompareHashFiles loaded both files into the full PersistedHashData struct, parsing ~2.7 GB of JSON to use ~100 MB. The seedable format added target_edges (523k entries, 13.6M strings) and dependency_hashes that the differ doesn't need.

The new loadHashesForDiff uses a streaming JSON decoder that stops reading as soon as git_commit_sha and target_hashes are found. With the current field order, it skips ~1 GB per file.

Scenario Time
Full struct (before) 9.5s
Streaming, parallel 366ms (26x)
Streaming, worst-case field order 3.9s (2.4x)

Works correctly regardless of field order. Added a struct comment on PersistedHashData warning that reordering fields degrades differ performance.

🤖 Generated with Claude Code

CompareHashFiles loaded both files into the full PersistedHashData
struct, allocating target_edges (523k entries, 13.6M strings) and
dependency_hashes only to discard them. With the seedable format this
meant parsing ~2.7 GB of JSON to use ~100 MB of it.

The new loadHashesForDiff uses a streaming JSON decoder that stops
reading as soon as git_commit_sha and target_hashes are both found.
With the current field order (target_hashes before target_edges), this
skips ~1 GB per file without even tokenizing it.

Measured on two real 1.3 GB seedable hash files (446k targets each):
  Full struct (before):     9.5s
  Streaming, parallel:      366ms   (26x faster)
  Streaming, reordered:     3.9s    (still 2.4x faster)

Works correctly regardless of field order. Added a struct comment
warning that reordering PersistedHashData degrades differ performance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@honnix
honnix marked this pull request as ready for review September 29, 2026 15:51
@honnix
honnix merged commit fc3a54e into main Sep 29, 2026
4 checks passed
@honnix
honnix deleted the honnix/diff-perf branch September 29, 2026 15:52
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.

2 participants