Skip to content

Cut import time and hot path overhead, dedup the first-fit kernels - #70

Draft
fpedd wants to merge 1 commit into
mainfrom
simplify-perf
Draft

Cut import time and hot path overhead, dedup the first-fit kernels#70
fpedd wants to merge 1 commit into
mainfrom
simplify-perf

Conversation

@fpedd

@fpedd fpedd commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Import omnimalloc dropped from 226 ms to 7 ms: the heavy re-exports
(allocate, available_allocators, plot_allocation, version) resolve
through a module getattr, and matplotlib, onnx, huggingface_hub, and
tqdm load only when actually used, taking import omnimalloc.benchmark
from 380 ms to 79 ms.

The first-fit hot path now runs on the CSR adjacency directly:
ConflictIndices (a vector<vector<size_t>> copy of the CSR that was built
and discarded per call) is retired, FirstFitPlacer holds the CSR plus
flat size and pin snapshots, and one shared gather_placed_spans helper
with the radix interval sort backs all four previously hand-rolled
placement loops. FirstFitPlacer.peak, the fitness function for the
genetic, random, hill climb, and tabu allocators, is 26% faster; hill
climb at 5000 allocations went from 21.7 s to 17.0 s.

Supermalloc's greedy portfolio returns (offsets, height) per heuristic
and materializes only the winning packing instead of n Allocation copies
for each of its 13 heuristics. Tabu search scores neighborhood samples
by peak alone and places once per iteration. GreedyByAllAllocator scores
its seven orders as permutations against one shared placer instead of
running seven independent allocations, 18% faster serial. Telamalloc
hoists a per conflict scratch vector; interval_peaks and linearize_times
lose redundant binary searches.

Python side dedup: one helper behind the two conflict order functions,
shared ensure_size_range and ensure_duration_range for the fifteen
duplicated validation blocks, the seeded RNG and count resolution idioms
hoisted into BaseSource, the random allocator's copy pasted first trial
folded into its loop, the minimalloc source's dead lazy cache machinery
removed, redundant re-sorts dropped from results export, dead frequency
constants deleted. HuggingFace model listing stops issuing HTTP round
trips once enough models are gathered.

No observable behavior changes: placements verified byte identical for
every deterministic allocator across synthetic and minimalloc workloads,
RNG streams untouched, and the full suite passes unchanged.

Import omnimalloc dropped from 226 ms to 7 ms: the heavy re-exports
(allocate, available_allocators, plot_allocation, __version__) resolve
through a module __getattr__, and matplotlib, onnx, huggingface_hub, and
tqdm load only when actually used, taking import omnimalloc.benchmark
from 380 ms to 79 ms.

The first-fit hot path now runs on the CSR adjacency directly:
ConflictIndices (a vector<vector<size_t>> copy of the CSR that was built
and discarded per call) is retired, FirstFitPlacer holds the CSR plus
flat size and pin snapshots, and one shared gather_placed_spans helper
with the radix interval sort backs all four previously hand-rolled
placement loops. FirstFitPlacer.peak, the fitness function for the
genetic, random, hill climb, and tabu allocators, is 26% faster; hill
climb at 5000 allocations went from 21.7 s to 17.0 s.

Supermalloc's greedy portfolio returns (offsets, height) per heuristic
and materializes only the winning packing instead of n Allocation copies
for each of its 13 heuristics. Tabu search scores neighborhood samples
by peak alone and places once per iteration. GreedyByAllAllocator scores
its seven orders as permutations against one shared placer instead of
running seven independent allocations, 18% faster serial. Telamalloc
hoists a per conflict scratch vector; interval_peaks and linearize_times
lose redundant binary searches.

Python side dedup: one helper behind the two conflict order functions,
shared ensure_size_range and ensure_duration_range for the fifteen
duplicated validation blocks, the seeded RNG and count resolution idioms
hoisted into BaseSource, the random allocator's copy pasted first trial
folded into its loop, the minimalloc source's dead lazy cache machinery
removed, redundant re-sorts dropped from results export, dead frequency
constants deleted. HuggingFace model listing stops issuing HTTP round
trips once enough models are gathered.

No observable behavior changes: placements verified byte identical for
every deterministic allocator across synthetic and minimalloc workloads,
RNG streams untouched, and the full suite passes unchanged.
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