Repository navigation
Benchmarks, because "would SIMD help" cannot be asked without a baseline - #112
Merged
Merged
Conversation
Asked whether go-asmgen or go-simd could make go-pdfkit faster. The honest
first answer is that nobody can tell, and here is why:
render 43 test files, 0 benchmarks
reader 22 test files, 0 benchmarks
ops 27 test files, 0 benchmarks
extract 10 test files, 0 benchmarks
opentype 40 test files, 0 benchmarks
go-gfx/gfx 55 test files, 13 benchmarks
The only measured corner of the stack is gfx, and the only generated SIMD
anywhere in it is `gfx/resample` -- amd64, arm64 and s390x, from go-asmgen.
`go-highway` is an INDIRECT dependency of both gfx and render: no code of ours
calls it.
So optimising now would be choosing where to spend effort by guessing, and the
way that fails is well documented in this fleet: a plateau read as progress, or
two errors cancelling in a proxy measurement.
Five benchmarks over the paths where the question actually lives:
Paths gfx/vector's scanline rasteriser, which has no SIMD today
ByScale the same page at 72, 150 and 300 dpi, which says whether
cost follows PIXELS or follows OPERATORS -- the first thing
worth knowing before moving anything into assembly
Empty the fixed cost of opening, laying out and allocating, so
the floor is visible beside the work in all the others
ColourChanges many small fills with a colour change between each, the
case where per-operator cost dominates per-pixel cost
⛔ No numbers are claimed here. This machine is at load average 12-19 with
twenty peer sessions on it, and a number taken under load is a number about
the load. The benchmarks exist so the question can be answered on a quiet
machine, with `-count=6` and benchstat, rather than from one run against one
run.
`onePage` takes a testing.TB rather than a *testing.T, which is the whole of
the change to existing code. Coverage is untouched at 100 %.
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.
Asked whether
go-asmgenorgo-simdcould make go-pdfkit faster. Thehonest first answer is that nobody can tell, and here is why:
renderreaderopsextractopentypego-gfx/gfxThe only measured corner of the stack is
gfx, and the only generated SIMDanywhere in it is
gfx/resample— amd64, arm64 and s390x, from go-asmgen.go-highwayis an indirect dependency of both gfx and render: no code ofours calls it.
Optimising from here would be choosing where to spend effort by guessing, and
the way that fails is well documented in this fleet — a plateau read as
progress, or two errors cancelling inside a proxy measurement.
Five benchmarks, over the paths where the question lives
PagePathsgfx/vector's scanline rasteriser — no SIMD todayPageByScalePageEmptyPageColourChanges⛔ No numbers are claimed here
This machine is at load average 12–19 with twenty peer sessions on it, and
a number taken under load is a number about the load. The benchmarks exist so
the question can be answered on a quiet machine, with
-count=6andbenchstat, rather than one run against one run.A smoke run (one iteration each, not a measurement) confirms they execute and
hints at the shape: an empty page costs 2.1 ms of the 3.3 ms a hundred
rectangles cost, so the fixed floor is most of a small page. If that holds when
it is measured properly, the first win is not SIMD at all.
Change to existing code
onePagetakes atesting.TBrather than a*testing.T. That is the whole ofit. Coverage is untouched at 100 %.
🤖 Generated with Claude Code