Repository navigation
perf(colors): vectorize the CMYK characterization and copy ICCBased samples with a device alternate (#476) - #494
Merged
Conversation
…amples with a device alternate (#476) The SWOP polynomial converts runs of distinct colors four at a time in Vector128<double> lanes, in the scalar term order (bit-exact, checked over 20 million 8-bit colors and the clip's special values). 8-bit samples of an ICCBased space whose alternate is the target device space with 0..1 ranges are copied, as DeviceRGB samples already were. Clamp01 inlines, and the per-sample range lookups no longer take a modulo.
…imd-cmyk-icc # Conflicts: # docs/conformance/iso-32000-2.md # samples/Broadside.Viewer.Blazor.Sample/KernelBenchmarks.cs
#476) The gate reported only the eight SkiaFirstTileBenchmarks.FirstTile cases, each 160 B per call above the baseline (single cold invocations, which include the color pipeline's one-time setup); every other case is unchanged.
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
…red values The eight SkiaFirstTileBenchmarks.FirstTile entries measured 288 B under the baseline in every gate run of this branch (identical values on four attempts, before and after merging #494); set them to those values. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com>
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
* perf(filters): vectorize the 8 x 8 islow inverse DCT (#474) - InverseDct.TransformVector runs libjpeg's jpeg_idct_islow four columns, then four rows, at a time in 32-bit Vector128 lanes: pass 1 works on the coefficient rows as loaded, its results are transposed with constant byte shuffles and selects, and pass 2's outputs are packed back into rows by multiplies. The range-limit table becomes a sign-extend and clamp. - Bit-exact with the scalar port, which stays as TransformScalar and the fallback: libjpeg's column shortcut is computed and selected per lane (the full arithmetic differs where the DC term wraps); its row shortcut equals the full arithmetic in the 10 bits the range limit keeps. - Left shifts are multiplies: the browser AOT build runs a vector shift at several times their cost. - InverseDctKernelTests (every single-coefficient block, sparse and full-range random blocks, a wider stride), InverseDctBenchmarks with allocation baseline entries at 0, and an idct-8x8 KernelBenchmarks case. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * docs(benchmarks): record the #474 inverse DCT kernel Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * docs(benchmarks): add the CI browser figures for the #474 inverse DCT Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * test(direct2d): assert WIC beats the managed decoder only with subsampled chroma With the vector IDCT (#474) the managed decoder matches or beats WIC's pixels on the 8-megapixel 4:4:4 photograph (0.82x in two of three CI runs, 1.9x to 2.0x before). The 4:4:4 case is measured and logged; the default decoder choice is unchanged. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * chore(bench): set the SkiaFirstTile allocation baselines to the measured values The eight SkiaFirstTileBenchmarks.FirstTile entries measured 288 B under the baseline in every gate run of this branch (identical values on four attempts, before and after merging #494); set them to those values. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> --------- Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com>
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.
Closes #476.
Profiled first (macOS
sample, Native AOT, 96 DPI): color conversion was 33% of the catalogue's render time (the CMYK characterization and its callers) and 73% of the brochure's and the newsletter's (RGB images in ICCBased spaces converting through their DeviceRGB alternate, byte to float and back to the same byte). The showcase spends under 1% there. The ICC engine's matrix/TRC (IccTransforminBroadside.Rendering) only runs withUseIccColorManagement, so it is not on these paths and is not vectorized here.Changes
CmykCharacterization.ToRgbRowVector: the SWOP polynomial for four colors per iteration in two pairs ofVector128<double>lanes, in the scalar term order (bit-exact).DeviceConverterkeeps its run detection and converts each stretch of distinct colors as one row. Gated off in the browser (!OperatingSystem.IsBrowser(), as the box filter): the blazor-wasm job measured 0.89x in the interpreter build (2.78x in AOT, which cannot be told apart at run time).ColorMath.Clamp01inlines (two comparisons, the same bits); the per-sample range lookups no longer takei % inputs.CmykCharacterizationBenchmarks(gate entries at 0), acmyk-to-rgbcase in the BlazorKernelBenchmarks, conformance rows for §8.6.5.5 and §10.4, and a section indocs/benchmarks/simd-kernels.md.Speed
Kernel, ns per color, scalar → vector: JIT 20.2 → 12.8 (1.58x), Native AOT 20.2 → 9.9 (2.04x), browser interpreter CI 618 → 694 (0.89x, hence the gate; 1.44x locally under Node), browser AOT CI 146 → 53 (2.78x). BenchmarkDotNet, 794 colors: 14.66 → 7.34 µs,
Allocated-.Whole documents (every page, 96 DPI, ms per pass). Native: base before #472; browser: base the integration branch after #472, head this change merged onto it (scalar kernel in both browser builds):
Bit-exact
CmykCharacterizationKernelTests(SimdKernelcategory): 20 million 8-bit colors, special values (NaN, ±0, denormals, out of range, infinities) at every short length and offset, the dispatcher, and runs of equal colors against per-color conversion. Passes withDOTNET_EnableHWIntrinsic=0too.Broadside.Rendering.Tests, 1,442) pass; page 0 of 1,228 files (pdf.js corpus, GWG output suite, PDF 2.0 examples, sample documents; 1,113 render) hash identically before and after.