Skip to content

Add O(N log N) sweep and hybrid sweep allocators#34

Open
fpedd wants to merge 1 commit into
mainfrom
sweep-allocators
Open

Add O(N log N) sweep and hybrid sweep allocators#34
fpedd wants to merge 1 commit into
mainfrom
sweep-allocators

Conversation

@fpedd

@fpedd fpedd commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Chronological sweep placement for very large problems: allocation/free
events are processed in time order over an address-ordered, coalescing
free list (C++ sweep_place), with first-fit, best-fit, and two-ended
(median split) fit policies. Hybrid variants place the largest
max_obstacles allocations with the exact quadratic first-fit and sweep
the rest around them as forbidden offset bands (hybrid_sweep_place);
with the budget fixed at its default of 1024 the family stays
O(N log N). SweepByAllAllocator runs all 7 variants in parallel and
keeps the best result, mirroring GreedyByAll.

On a 33-problem suite (minimalloc datasets, synthetic sources, ONNX
models) the portfolio matches the quadratic GreedyByAll baseline at
geomean 0.9967 (2 wins, 29 ties, 2 losses, worst +1.7%) while placing
1M allocations in 0.83 s for a single sweep versus hours extrapolated
for one quadratic greedy variant. Hybrid runs with max_obstacles >= N
are bit-identical to the corresponding exact greedy variants, used as
a test invariant.

Total sizes beyond the free list's 2^61 top-gap bound raise
OverflowError instead of overflowing offset arithmetic, and a negative
max_obstacles raises ValueError. Research notes, prototypes, and the
quality benchmark used to select the shipped variants live in
research/, excluded from ruff/ty as a scratch area.

Chronological sweep placement for very large problems: allocation/free
events are processed in time order over an address-ordered, coalescing
free list (C++ sweep_place), with first-fit, best-fit, and two-ended
(median split) fit policies. Hybrid variants place the largest
max_obstacles allocations with the exact quadratic first-fit and sweep
the rest around them as forbidden offset bands (hybrid_sweep_place);
with the budget fixed at its default of 1024 the family stays
O(N log N). SweepByAllAllocator runs all 7 variants in parallel and
keeps the best result, mirroring GreedyByAll.

On a 33-problem suite (minimalloc datasets, synthetic sources, ONNX
models) the portfolio matches the quadratic GreedyByAll baseline at
geomean 0.9967 (2 wins, 29 ties, 2 losses, worst +1.7%) while placing
1M allocations in 0.83 s for a single sweep versus hours extrapolated
for one quadratic greedy variant. Hybrid runs with max_obstacles >= N
are bit-identical to the corresponding exact greedy variants, used as
a test invariant.

Total sizes beyond the free list's 2^61 top-gap bound raise
OverflowError instead of overflowing offset arithmetic, and a negative
max_obstacles raises ValueError. Research notes, prototypes, and the
quality benchmark used to select the shipped variants live in
research/, excluded from ruff/ty as a scratch area.
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