Skip to content

Make pinned stacking linear and restore input order in allocate - #73

Open
fpedd wants to merge 6 commits into
mainfrom
python-core-cleanup
Open

fpedd wants to merge 6 commits into
mainfrom
python-core-cleanup

Conversation

@fpedd

@fpedd fpedd commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Stacking around pins was quadratic once anything was pinned, and stayed quadratic in the number of gaps between pins. A max tree over the gaps' free widths now finds each free item's first-fit gap in O(log gaps): identical results on 50k fuzzed layouts, 20k items with 10% pins from 9.2 s to 26 ms, and 10k items over 10k gaps from 3 s to 22 ms, with the pin-free path unchanged. BaseAllocator.allocate returns its result in input order as a documented contract and checks all postconditions in one pass, the raw-sequence path no longer wraps the input in temporary pools, and ensure_unique_ids takes a set-size fast path that keeps its TypeError for entities without an id.

An empty pinned pool no longer counts as overlapping another pool (validate, Memory and Pool.overlaps share one half-open overlap helper). Memory.is_allocated now also requires every pool base, so it agrees with Memory.extent; plot_allocation still draws packed pools without a base where Memory.allocate would put them, and still draws pinned pools that overlap (only Memory.allocate rejects those). Saving a pool whose ids collide as text raises, and every pool is checked before any file is written. Unknown registry names raise ValueError from both get and resolve. The matplotlib fallback stubs in visualize are gone, and the primitive tests are flattened into parametrized tables.

Kept on purpose: Memory.used_size (ALTO reads it), Memory/System.any_allocated, Pool.overlaps, available_cores, the unit constants and require_optional's install_extra. Only the old lowest_gap helper is dropped.

@fpedd
fpedd force-pushed the python-core-cleanup branch 2 times, most recently from 2aae312 to 3fc0c75 Compare September 29, 2026 21:21
@fpedd
fpedd changed the base branch from benchmark-cleanup to main September 29, 2026 21:22
@fpedd fpedd closed this Sep 29, 2026
@fpedd fpedd reopened this Sep 29, 2026
@fpedd
fpedd force-pushed the python-core-cleanup branch 2 times, most recently from cc9a6d8 to baa56a1 Compare October 17, 2026 11:37
@fpedd
fpedd force-pushed the python-core-cleanup branch from baa56a1 to ebe98a2 Compare October 17, 2026 13:09
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