Repository navigation
Multiply the clips at the pixels that are painted, not at every pixel they cover - #62
Merged
Merged
Conversation
… they cover
A page composes far more pixels into its clips than it ever paints
through them:
composed painted ratio
the form this was found on 32 148 788 226 639 141.9x
both corpora, 3215 docs 8 433 010 263 293 645 790 28.7x
`narrow` was multiplying the clip already in force into the new one at
every pixel of the new clip's box -- 34% of the time this renderer spends
drawing, second only to the rasteriser's inner loop. Almost all of that
product is never read: it is computed for pixels no mark reaches.
So a clip now holds its own shape and a pointer to the clip it narrowed,
and `at` walks the chain. The chain's box is the intersection of every
shape in it, so one test still rejects a pixel no link needs to be asked
about; and because a chain box only ever shrinks, a pixel inside it is
inside every link's grid and no link needs a bounds test of its own.
## With a bound, because a page can say `W n` without end
Past clipDepth = 8 links, narrow composes the chain into one grid.
Composing costs the box once; walking costs the chain at every painted
pixel. No page in either corpus nests clips that deep, which is exactly
why the test that pulls that brake had to be written by hand: a safety
brake nothing exercises is where the next defect lives.
## Measured, against a harness that was calibrated first
The draw phase timed in-process: a process-per-document harness cannot
measure this on this machine, where a short-lived process is placed on an
efficiency or a performance core by the scheduler and that difference is
larger than the effect. Run against itself the harness reads +0.2%.
the form it was found on 98.9ms -> 85.1ms -14%
37 documents, total draw 1198.1 -> 1195.8ms -0.2%
The aggregate is within the floor: one document in 37 clips heavily
enough for this to matter. Beside the rasteriser change in go-gfx/gfx#49,
which is independent, the same form goes 96.23ms -> 70.72ms, -26.5%.
And it draws the same picture: 3215 documents rendered before and after
and compared as PNG bytes, 3215 byte-identical.
## One dead branch, found by the gate
`at` checked each link for a nil grid. Every link has one -- narrow gives
one to each and flatten to what it composes -- and the only clip without
one is the empty clip, whose box the bounds test has already answered
for. The check could not fire, and the coverage gate is what said so.
go-gfx/gfx v0.32.0. The two are independent and compose: the form this branch was measured on goes 96.23ms to 70.72ms, -26.5%, where each alone is -14% and -12%.
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.
A page composes far more pixels into its clips than it ever paints through them.
narrowwas multiplying the clip already in force into the new one at every pixel of the new clip's box, which is 34% of the time this renderer spends drawing — second only to the rasteriser's inner loop. Almost all of that product is never read: it is computed for pixels no mark ever reaches.So the product is left to the pixels that are painted
A
clipnow holds its own shape only, and a pointer to the clip it narrowed.atwalks the chain and multiplies. The chain's box is the intersection of every shape in it, so one test still rejects a pixel no link needs to be asked about — and because a chain box only ever shrinks, a pixel inside it is inside every link's grid and no link needs a bounds test of its own.With a bound, because a page can say
W nwithout endA page that narrows itself repeatedly without a
Qbetween would otherwise make every painted pixel walk the lot. PastclipDepth= 8 links,narrowcomposes the chain into one grid: composing costs the box once, walking costs the chain at every painted pixel.Measured
The draw phase, timed in-process. A process-per-document harness cannot measure this on an Apple Silicon machine — a short-lived process is placed on an efficiency or a performance core by the scheduler, and that difference is larger than the effect. The harness reads +0.2% when run against itself.
The aggregate is inside the floor, and that is the honest reading: one document in 37 clips heavily enough for this to matter. Beside go-gfx/gfx#49, which is independent and already released as v0.32.0, the same form goes 96.23 ms → 70.72 ms, −26.5% — the two compose.
And it draws the same picture
3215 documents of both corpora rendered before and after and compared as PNG bytes — not a metric over them, the bytes: 3215 byte-identical, 0 different. Run twice: once for the change, and again after a dead branch was removed from
at.One dead branch, found by the coverage gate
atchecked each link for a nil grid. Every link has one —narrowgives one to each andflattento what it composes — and the only clip without one is the empty clip, whose box the bounds test has already answered for. The check could not fire, and the gate is what said so.And the brake had to be tested by hand
No page in either corpus nests clips past
clipDepth, so nothing in the corpus pulls it. A safety brake nothing exercises is where the next defect lives, soTestALongChainIsComposedRatherThanWalkednarrows eleven times and checks both that the chain is composed and that it still answers the same thing.🤖 Generated with Claude Code