Skip to content

Share one CSR first-fit kernel and compute every greedy order in C++ - #74

Open
fpedd wants to merge 3 commits into
python-core-cleanupfrom
cpp-core-cleanup
Open

fpedd wants to merge 3 commits into
python-core-cleanupfrom
cpp-core-cleanup

Conversation

@fpedd

@fpedd fpedd commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Every allocator now reads the conflict relation as one CSR adjacency instead of unpacking it into a vector per allocation, and one place_order kernel serves first fit, best fit, the omni portfolio and FirstFitPlacer, replacing four copies. The greedy orders, including greedy_by_contention from #78, are computed only in C++ (the Python copies had drifted in their tie-breaking): each GreedyBy allocator just names its GreedyOrder, the Python order_by_* functions stay as thin wrappers over the native orders, and FirstFitPlacer.order reuses a placer's adjacency (genetic seeding at 50k: 2.05 s to 1.32 s). greedy_by_all is omni without linearization, 4-7x faster at 100k and 1M with identical peaks, and its thread pool is gone. Omni's placements on scalar input are byte-identical to the parent.

ConflictSweep owns its reduced rows, happens_before replaces the inverted dominates, one hash_combine replaces three combiners, ClockSpans is move-only since its spans may view its own buffer, the bindings lose their redundant return policies, the raw greedy_order binding checks the total size, and stale comments are corrected. Telamalloc allocates its scratch once and bounds its incumbents by the deadline (160k disjoint allocations with a 1 s timeout took 4.5 s, now 0.26 s), tabu search forbids a reversal for its full tenure, the random allocator gets a timeout and takes (seed, num_trials, timeout) like every other seeded allocator, genetic checks its deadline while seeding, and every seeded allocator validates its seed up front via common.validation.ensure_seed.

On vector clocks only: the contention order draws every key from the timeline it ranks (a linearized surrogate's durations break ties, as DURATION and AREA already do), and greedy_by_all no longer linearizes; genetic's contention seed ranks on the same surrogate. greedy_by_start ranks clock lanes with omni's canonical_starts instead of main's separate Python content sort, so its vector-clock packings follow omni's START order and can differ from main's (39 worse, 26 better of 352 fuzzed instances; scalar unchanged). greedy_by_start breaks ties by input index, as omni does. Stacked on #73.

fpedd added 3 commits October 17, 2026 15:03
One place_order kernel over a CSR conflict adjacency serves first fit, best fit, the omni portfolio and FirstFitPlacer. The greedy orders, now including greedy_by_contention from main, are computed only in C++ (GreedyOrder); the Python order_by_* functions stay as thin wrappers over them, and FirstFitPlacer.order reuses a placer's adjacency. greedy_by_all is omni without linearization. Omni's scalar placements are byte-identical.

On vector clocks the contention order now draws every key from the timeline it ranks (the linearized surrogate's durations break ties, as DURATION and AREA already do), and greedy_by_all no longer linearizes; both differ from #78 there and nowhere on scalar input. The genetic allocator's contention seed ranks on the same surrogate. greedy_by_start now ranks clock lanes with omni's canonical_starts rather than main's separate Python content sort, so on vector clocks it follows omni's START order and its packings can differ from main's.
@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