Skip to content

docs: float64 Exp on 16 cores is slowed by allocation, not the kernel - #102

Merged
tannevaled merged 1 commit into
mainfrom
docs/exp-alloc-attribution
Nov 8, 2026
Merged

tannevaled merged 1 commit into
mainfrom
docs/exp-alloc-attribution

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The README said float64 Exp below 256 Ki was slower than NumPy (0.82×, measured with 16 cores). Measured today on Zen 3, that is the allocation, not Exp. This PR corrects the claim and adds the benchmark that shows it.

The evidence:

  • On one core: float64 Exp is 1.2–1.3× faster than NumPy at every size (1 Ki to 4 Mi).
  • With GOMAXPROCS = 16: the same serial code (below ParThreshold, nothing is split) gets slower than with 1, at 89 µs against 73 at 16 Ki.
  • The attribution: Add goes from 14 to 23–26 µs at 16 Ps, while AddInto, which allocates nothing, stays at 4.3 µs. The per-result allocation costs more with more Ps.
  • In a Workspace (new BenchmarkExpWS), the difference disappears.
float64 Exp, Zen 3, load ≤ 5 1 Ki 16 Ki 256 Ki 4 Mi
NumPy 2.5.4 (one thread) 6.0 µs 85.5 µs 1.32 ms 25.0 ms
ours, 1 P, allocating 4.9 µs 73 µs 1.11 ms 19.3 ms
ours, 16 P, allocating 5.8–6.6 µs 83–95 µs 0.63–0.78 ms 4.8–6.7 ms
ours, 16 P, Workspace 4.1 µs 64 µs 0.18 ms 1.47 ms

Changes:

  • README: float64 Exp moves under "faster". The "slower" list keeps the allocating forms, noting that their cost grows with GOMAXPROCS.
  • docs/perf.md: the table above. The note about the other architectures now says the kernels live in go-simd/floats since v0.37.0, NEON included (proven, not benchmarked).
  • benchmarks: BenchmarkExpWS.

No library code changes.

🤖 Generated with Claude Code

The README listed float64 Exp below 256 Ki as 0.82x NumPy (16 cores). On
one core it is 1.2-1.3x faster at every size. With GOMAXPROCS=16 the same
serial code got slower than with 1 (89 vs 73 us at 16 Ki), as does Add
(14 -> 23-26 us) while AddInto does not move: the per-result allocation
costs more with more Ps. In a Workspace on 16 cores, Exp is 1.3-1.5x NumPy
up to 16 Ki and 7-17x from 256 Ki (new BenchmarkExpWS).

The README now says so; perf.md gets the table, and its note on the other
architectures now reflects that the kernels live in go-simd/floats since
v0.37.0, NEON included (unbenchmarked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit c7b9263 into main Nov 8, 2026
12 checks passed
@tannevaled
tannevaled deleted the docs/exp-alloc-attribution branch November 8, 2026 09: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