Repository navigation
perf(photos): read the stored frame upright inside the resample - #891
Merged
Merged
Conversation
zenc square oriented a full-frame copy (311 MB of f32 for a 26 MP photo) and then resampled it three times. It now hands the stored frame to halflight's new resample_oriented, which reads it upright inside the horizontal pass and is bitwise equal to orienting first. Pins halflight at 871487e (its resample-oriented branch, to be merged with a merge commit as #1 was). Same-file decode-to-resample floor, 6240x4160 JPEG, interleaved: orientation 1 491 ms (unchanged), 3 568 -> 491, 6 582 -> 445, 8 592 -> 461. Rotation now costs nothing, and the axis-swapping cases beat upright because each tap streams one whole stored row. zenc:bench against the tiled-orient branch: identical on all 24 outputs and 258 histograms; rotated sources 1.06-1.07x wall and 2.3-3.8% less CPU, each at p <= 0.0012; upright sources not called. images/histograms regenerated from this build (byte-identical) and re-locked, since Cargo.lock and pixels.rs are its inputs.
Contributor
Wire-size diff vs merge base
Brotli q11, the quality the edge serves. Every number here is deterministic: Client assetsNo change. 26 files, 87.55 KiB Brotli total. PagesNo change. 57 files, 585.04 KiB Brotli total. Worker bundleNo change. 250.16 KiB gzip. Dictionary transportFamily dictionary acquisition: no change, 14.41 KiB q11.
|
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.
Needs oddharsh/halflight#2 merged with a merge commit (not a squash), as halflight#1 was, so the pinned sha
871487estays reachable from halflight'smain. CI here already builds against it, since the sha is fetchable from its branch.The second pass of the loop. #889 made the orientation copy fast; this removes it.
zenc squarenow hands the stored frame to halflight's newresample_oriented, which reads it upright inside the horizontal pass and is bitwise equal to orienting first. No 311 MB upright copy is built for any rotated photo.Measured
Same-file decode-to-resample floor, one 6240x4160 JPEG, three builds interleaved:
Rotation now costs nothing, and the axis-swapping cases come in under upright, because each filter tap streams a whole stored row and updates thousands of accumulators in one contiguous loop.
bun run zenc:benchagainst #889's tree, which ismain's zenc now:Gate: all 24 square outputs and 258 histograms byte-identical.
The loop, inside halflight
Measured in a probe on the kernel alone (6240x4160 RGB, three box tiers) before touching zenc:
Changes
tools/photos/zenc/Cargo.toml: halflight80e9f34→871487e, with a note on how to move it.square::tiertakes the orientation and computes geometry on the upright size;pixels::scale_orientedwrapsresample_oriented.Upright, so they behave exactly as before.resizeandframestill use perf(photos): orient full frames by row and by tile instead of per pixel #889's tiledorient.images/histogramsregenerated from this build (byte-identical) and re-locked, sinceCargo.lockandpixels.rsare its inputs.Checks:
cargo test39/39, clippy-D warningswith and withoutheif-experiment,lint,test847/0,derive:check.