Skip to content

chore:optimize next_coalesced() by tracking removed ids in a HashSet#6353

Open
caicancai wants to merge 1 commit intovortex-data:developfrom
caicancai:perf/io-coalesce-hashset
Open

chore:optimize next_coalesced() by tracking removed ids in a HashSet#6353
caicancai wants to merge 1 commit intovortex-data:developfrom
caicancai:perf/io-coalesce-hashset

Conversation

@caicancai
Copy link
Contributor

@caicancai caicancai commented Feb 8, 2026

This PR speeds up State::next_coalesced() by avoiding an O(k) linear scan for every candidate when checking whether a request was already marked for removal. Previously, scanning a window of n candidates with k already-marked ids could cost O(n·k) (worst-case O(n²)). We keep the Vec<(offset, id)> for removals, but add a HashSet for O(1) average membership checks, bringing the scan closer to O(n). Coalescing behavior is unchanged.

@caicancai caicancai force-pushed the perf/io-coalesce-hashset branch from 5deafb8 to 3fe1afe Compare February 8, 2026 04:41
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