Repository navigation
perf(gemm): start workers once per product, synchronise on work done - #26
Merged
Merged
Conversation
…le-buffered B Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b pools Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t the profile-based claim Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Diagnosis (hardware counters, Zen 3 KVM guest cfarm421)
At 16 workers a 1024² product kept the CPUs busy 7.1 of 16 of the time. The instruction count stayed flat and so did L1 misses. The old driver forked and joined goroutines twice per (jc, pc) block. A fork/join wakes parked threads one after another; a micro-benchmark on the same guest measured it at 26 µs at 2 workers, 165 µs at 8 and 330 µs at 16, which is about 40% of a 12.5 ms product.
Refuted first: SMT siblings (pairwise interference is 0–10%, never half) and the size of the A block versus L2 (an MC sweep over 72–256 gave nothing clear).
docs/perf.md had said "not scheduling overhead: 83% of the profile is the micro-kernel". That was wrong, because a cycles profile cannot see idle cores. It is now struck through and corrected in place.
Change (
internal/kernels/gemm.go)packBP/packBParMinand the barrier type are gone.spinUntilspins, then yields withruntime.Gosched, and never parks.Tests
TestSpinUntilandTestGemmParallelYieldingcover every wait yielding immediately and more workers than CPUs. The existing GEMM tests run under-race, and coverage stays at 100%.Measured (medians of interleaved runs vs the previous driver)
Against OpenBLAS-16, measured in one interleaved run: at 256² we are now 1.44× faster (the previous driver was 1.06×); at 512² 0.42× (was 0.29×); at 1024² 0.51× (was 0.43×).
Known loss: 2 workers on the KVM guest lose 8–18% on mid sizes. Bare-metal POWER9 gains at 2 workers. Not measured on Apple M, because the machine was shared at the time.
Version: v0.4.1 (performance only, no API change).
🤖 Generated with Claude Code