Skip to content

Optimise hdiff buffer handling by (re)using Milhouse data structures#9236

Open
michaelsproul wants to merge 14 commits intosigp:unstablefrom
michaelsproul:optimise-hdiff
Open

Optimise hdiff buffer handling by (re)using Milhouse data structures#9236
michaelsproul wants to merge 14 commits intosigp:unstablefrom
michaelsproul:optimise-hdiff

Conversation

@michaelsproul
Copy link
Copy Markdown
Member

Proposed Changes

Core idea is using Milhouse types in HDiffBuffer so we can avoid cloning in and out of vecs, and preserve structural sharing across diff application.

Benchmarks to come (from lcli apply-hdiff/compute-hdiff newly added)

michaelsproul and others added 11 commits April 13, 2026 09:51
- `CompressedU64Diff::apply`: Use a dense/sparse hybrid strategy.
  When >50% of elements change, rebuild the List from scratch.
  Otherwise, use copy-on-write `get_mut` for only non-zero diffs.
  This significantly speeds up inactivity scores (all-zero diffs).
- `ValidatorsDiff::apply`: Collect updates into a BTreeMap and use
  `bulk_update` instead of per-element `get_mut`, avoiding repeated
  copy-on-write tree modifications.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Temporary eprintln! timing for each diff component to stderr
for profiling purposes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@michaelsproul michaelsproul added work-in-progress PR is a work-in-progress optimization Something to make Lighthouse run more efficiently. database labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database optimization Something to make Lighthouse run more efficiently. work-in-progress PR is a work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant