Skip to content

Simplify slab partitioning with drain from end#1

Merged
NathanHowell merged 2 commits intofix/bulk-load-overcapacityfrom
fix/bulk-load-drain-from-end
Feb 25, 2026
Merged

Simplify slab partitioning with drain from end#1
NathanHowell merged 2 commits intofix/bulk-load-overcapacityfrom
fix/bulk-load-drain-from-end

Conversation

@NathanHowell
Copy link
Owner

Summary

  • Replaces split_off + mem::replace + shrink_to_fit with inverted partition_envelopes + drain from the tail
  • Each yielded slab gets exact capacity from collect(), eliminating shrink_to_fit on the hot path
  • Only the final slab (via mem::take) needs shrinking since drain doesn't reduce self.remaining's capacity

Suggested by @adamreichold in georust#220 (comment)

Test plan

  • All existing rstar tests pass (50 unit + 27 doc-tests)
  • test_cluster_group_iterator updated for reversed slab order (largest-first)
  • test_cluster_group_iterator_no_excess_capacity continues to verify no over-allocation
  • test_bulk_load_no_excess_capacity continues to verify tree nodes aren't over-allocated

Instead of split_off + mem::replace + shrink_to_fit, invert the
partition so slab elements end up at the tail and drain them into
a new Vec with exact capacity. This eliminates the need for
shrink_to_fit on every non-last slab while keeping the code simpler.
@NathanHowell NathanHowell merged commit f45d858 into fix/bulk-load-overcapacity Feb 25, 2026
@NathanHowell NathanHowell deleted the fix/bulk-load-drain-from-end branch February 25, 2026 19:00
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