Skip to content

Batch remote bitfield index refreshes#808

Open
marcus-pousette-hp wants to merge 1 commit into
mainfrom
fix/remote-bitfield-index-refresh
Open

Batch remote bitfield index refreshes#808
marcus-pousette-hp wants to merge 1 commit into
mainfrom
fix/remote-bitfield-index-refresh

Conversation

@marcus-pousette-hp

@marcus-pousette-hp marcus-pousette-hp commented May 14, 2026

Copy link
Copy Markdown
Contributor

Receiving a multi-page remote bitfield currently refreshes the sparse quickbit index once per 4 KiB page. For a full 2 MiB segment, that rebuilds the same segment index 64 times.

This changes RemoteBitfield.insert() to copy all touched pages first and refresh each touched segment once. It also updates clear() to keep the sparse index correct for firstUnset() by updating the affected 128-bit quickbit index chunks.

Local microbench, 100 repeated inserts of the same remote bitfield:

bitfield size pages before after
4 KiB 1 ~0.04ms/insert ~0.04ms/insert
16 KiB 4 ~0.27ms/insert ~0.06ms/insert
64 KiB 16 ~2.06ms/insert ~0.14ms/insert
256 KiB 64 ~21.0ms/insert ~0.28-0.33ms/insert

The full-segment case improves by roughly 60x because it now rebuilds the sparse quickbit index once per touched segment instead of once per 4 KiB page.

PR as co-written with AI

@marcus-pousette-hp marcus-pousette-hp marked this pull request as ready for review May 14, 2026 08:37
@marcus-pousette-hp marcus-pousette-hp requested a review from a team May 14, 2026 08:37
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