Repository navigation
perf(png): reconstruct scanlines with one filter dispatch - #11818
Merged
vincentkoc merged 1 commit intoNov 30, 2026
Merged
Conversation
Contributor
[Low impact] The PR appears safe to merge; no actionable issue was found. SummaryMoves PNG filter selection outside the byte loop and adds ten RGB/RGBA test vectors.
Reviews (2) · Last reviewed commit: "perf(png): dispatch reconstruction filte..." · Reviewed by Greptile |
Afloat16
marked this pull request as ready for review
November 23, 2026 01:47
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
vincentkoc
added a commit
to WoWHellgarve-HolyDeeW/rea
that referenced
this pull request
Nov 30, 2026
* commit '7f7d34ad7c30a5fe015b642118dd40e8e9ac093d': (167 commits) fix(artifacts): classify member presence from the absent side coverage (morluto#15200) fix(tar): account for retained pax owner names (morluto#15195) fix(conformance): validate paired fixture count expectations (morluto#14125) fix(nds): report unreachable file name directories (morluto#15192) refactor(firmware): share admitted-file decoder buffering (morluto#15198) fix(binary): carry the runtime refusal's repair instruction in remediation (morluto#14123) fix(agentenv): reject COM0 and LPT0 bundle names (morluto#14971) test(environment): share the loopback capture fixture (morluto#15196) perf(png): reconstruct scanlines with one filter dispatch (morluto#11818) feat(iso9660): stream files across separated extents (morluto#15190) perf(apple): build only the requested asset catalog page (morluto#14032) perf(artifacts): isolate offline session composition from deep providers (morluto#15194) perf(evidence): bound investigation closure worklist by depth (morluto#15193) perf(audit): avoid copying complete log lines (morluto#15184) test(mcp): share server result readers (morluto#15174) fix(android): declare Android mapping and JNI fixed allowances (morluto#15183) fix(artifacts): retain deep comparison source chains (morluto#15191) perf(evidence): bound link inspection frontier by records (morluto#15189) perf(evidence): retain snapshots across duplicate imports (morluto#15186) fix(nro): exclude ASET header bytes from asset ranges (morluto#15185) ...
4 of 19 tasks
vincentkoc
added a commit
to XiaoBinGan/rea
that referenced
this pull request
Nov 30, 2026
* commit '4ca43e2cb20f0edd86cdbf315a9c99c7b9b87468': (173 commits) fix(paths): reject Windows console device names (morluto#14972) fix(artifacts): classify member presence from the absent side coverage (morluto#15200) fix(tar): account for retained pax owner names (morluto#15195) fix(conformance): validate paired fixture count expectations (morluto#14125) fix(nds): report unreachable file name directories (morluto#15192) refactor(firmware): share admitted-file decoder buffering (morluto#15198) fix(binary): carry the runtime refusal's repair instruction in remediation (morluto#14123) fix(agentenv): reject COM0 and LPT0 bundle names (morluto#14971) test(environment): share the loopback capture fixture (morluto#15196) perf(png): reconstruct scanlines with one filter dispatch (morluto#11818) feat(iso9660): stream files across separated extents (morluto#15190) perf(apple): build only the requested asset catalog page (morluto#14032) perf(artifacts): isolate offline session composition from deep providers (morluto#15194) perf(evidence): bound investigation closure worklist by depth (morluto#15193) perf(audit): avoid copying complete log lines (morluto#15184) test(mcp): share server result readers (morluto#15174) fix(android): declare Android mapping and JNI fixed allowances (morluto#15183) fix(artifacts): retain deep comparison source chains (morluto#15191) perf(evidence): bound link inspection frontier by records (morluto#15189) perf(evidence): retain snapshots across duplicate imports (morluto#15186) ...
vincentkoc
added a commit
to ShuaixinHuang/rea
that referenced
this pull request
Nov 30, 2026
* commit '4ca43e2cb20f0edd86cdbf315a9c99c7b9b87468': (34 commits) fix(paths): reject Windows console device names (morluto#14972) fix(artifacts): classify member presence from the absent side coverage (morluto#15200) fix(tar): account for retained pax owner names (morluto#15195) fix(conformance): validate paired fixture count expectations (morluto#14125) fix(nds): report unreachable file name directories (morluto#15192) refactor(firmware): share admitted-file decoder buffering (morluto#15198) fix(binary): carry the runtime refusal's repair instruction in remediation (morluto#14123) fix(agentenv): reject COM0 and LPT0 bundle names (morluto#14971) test(environment): share the loopback capture fixture (morluto#15196) perf(png): reconstruct scanlines with one filter dispatch (morluto#11818) feat(iso9660): stream files across separated extents (morluto#15190) perf(apple): build only the requested asset catalog page (morluto#14032) perf(artifacts): isolate offline session composition from deep providers (morluto#15194) perf(evidence): bound investigation closure worklist by depth (morluto#15193) perf(audit): avoid copying complete log lines (morluto#15184) test(mcp): share server result readers (morluto#15174) fix(android): declare Android mapping and JNI fixed allowances (morluto#15183) fix(artifacts): retain deep comparison source chains (morluto#15191) perf(evidence): bound link inspection frontier by records (morluto#15189) perf(evidence): retain snapshots across duplicate imports (morluto#15186) ...
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.
Summary
Reduce CPU work when comparing existing PNG screenshots by selecting the reconstruction filter once per scanline. Each filter now reads only its required neighbors; unfiltered rows use a buffer copy. The decoded pixels, comparison metrics, supported formats and admission limits remain unchanged.
Problem and expected behavior
At base
af062e7a2d290fec4307fb9444298a13c2fea630,unfiltercomputes all three neighbor values and dispatches throughapplyFilterfor every byte, even though a row has one fixed filter. A 1920 × 1080 RGBA image therefore repeats that selection 8,294,400 times instead of 1,080 times.The expected contract is identical reconstruction with less repeated work. This is a performance change, not a claim that existing filter arithmetic is incorrect. No separate issue is linked because the concrete reproduction, measurements and proposed repair are included here.
Related #11223 adds filter-coverage tests. This change addresses the reconstruction loop itself. Historical positional-helper implementations also still selected the filter per byte; removing an options object is not the basis of this optimization.
Change and scope
Move the switch outside the byte loop and keep one loop per filter. None copies the row, Sub reads left, Up reads above, Average reads left and above, and Paeth reads all three neighbors. The Paeth predictor and tie-breaking code are unchanged. Unsupported filter values still fail.
The PR contains only the implementation and ten fixed RGB/RGBA scanline tests. Benchmark scripts, fixtures and validation workflow are retained separately as evidence.
Contract and boundary impact
pngVisualDiff.ts; screenshot artifact comparison keeps the same pixel and metric contracts.Expected effects:
Evidence and regression coverage
The ten new vectors cover all five filters for both RGB and RGBA, first and later rows, initial columns and byte wraparound. Their PNG encodings were independently decoded and checked byte-for-byte with Pillow 13.0.0. The tests exercise the public screenshot-artifact and comparison APIs against explicit expected RGBA bytes. They pass before and after; the improvement is established by native measurements rather than a claimed functional failure.
The native benchmark uses Pillow-produced 640 × 360 RGB, 1920 × 1080 RGB and 1920 × 1080 RGBA images, each with identical and changed-image cases. An independent Pillow pixel oracle checks every comparison metric. Each timed task creates both screenshot artifacts, parses the comparison input and calls
comparePngScreenshots. Disk reads, module import and fixture production are outside the timed task.On Ubuntu 24.04 with Node 24.22.1, three alternating before/after rounds used 36 fresh processes and 252 completed public tasks. Every complete output matched byte-for-byte. Cold is the median first task from three fresh processes; warm is the median of calls 5–7 in those processes after four warm-up calls, giving nine measurements per phase and case.
These measurements support approximately 29–52% lower median warm elapsed time and 18–41% lower median cold elapsed time for these tasks. They do not establish an end-to-end browser capture, network, token or general memory improvement; one RGBA case has a higher process peak. The real-producer fixtures predominantly exercise Up, Paeth and Sub; the fixed vectors separately cover all five filters.
For evidence-bearing changes:
Validation performed
At the pinned base plus the exact two files in this PR:
npm run test:local -- src/domain/pngVisualDiff.test.ts src/domain/pngHeader.test.ts— 53 passed before and 53 after.npm run test:focused -- tests/boundary/cli/browserCli.test.ts tests/boundary/browser/browserToolContractExamples.test.ts— 19 passed against the compiled package.npm run check— passed, including typecheck, lint, formatting, Knip, metadata and architecture checks; the run reports zero errors and 5,026 advisory lint warnings.git diff --check— passed; the isolated source worktree changed only these two files.An earlier workflow attempt selected built boundary tests with
test:localand stopped with the runner's instruction to usetest:focused. The corrected run above completed. That earlier attempt is retained and is not counted as a pass.Compatibility, safety, and release
No breaking change, migration, dependency or package change. The comparison budget, CRC checks, image admission, failure behavior and schemas are unchanged. Validation covers native Linux/Node decoding and compiled CLI/browser-contract tests using the repository's controlled CDP fixture; it does not claim a live browser or other-OS performance measurement. No new execution, mutation or external communication capability is introduced.
Author readiness
Human owner: @Afloat16
Before merge
type(scope): outcome.