Skip to content

perf(list): keep the nearest destinations in one bounded buffer per cursor - #231

Merged
blackopsrepl merged 1 commit into
mainfrom
feature/nearby-bounded-candidates-228
Nov 9, 2026
Merged

blackopsrepl merged 1 commit into
mainfrom
feature/nearby-bounded-candidates-228

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #228. Nearby list change/swap cursors keep the max_nearby nearest destinations in one reused bounded buffer instead of collecting, sorting and copying every reachable destination per source. Candidate order is unchanged (tested against a stable sort for every length up to 95 and every limit). Local make ci-local: 1723 passed, 0 failed.

…ursor

The nearby list change and swap cursors collected every reachable destination of a source position into a fresh vector, sorted and truncated it to max_nearby, then copied the survivors into a second destination list. Every source position paid for an allocation that grew with the whole solution, and on the zero-regression gate a quarter of nearby_change's branch misses sat in malloc, realloc, memmove and free.

Each cursor now owns a BoundedNearbyCandidates buffer that keeps only the max_nearby nearest destinations offered so far, in ascending distance with offer order between equal distances. That is exactly the set and order the stable sort and truncation produced, so candidate streams are unchanged. The buffer is reused across source positions and moves read from it directly, with no second copy.

Closes #228
@blackopsrepl
blackopsrepl merged commit f593fa8 into main Nov 9, 2026
14 checks passed
@blackopsrepl
blackopsrepl deleted the feature/nearby-bounded-candidates-228 branch November 9, 2026 15:04
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.

perf(list): nearby list cursors allocate and sort every reachable destination per source

1 participant