Cut import time and hot path overhead, dedup the first-fit kernels - #70
Draft
fpedd wants to merge 1 commit into
Draft
Cut import time and hot path overhead, dedup the first-fit kernels#70fpedd wants to merge 1 commit into
fpedd wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.