Conversation
5 tasks
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
Populate MMCQ's existing box population cache so queue comparisons reuse counts instead of repeatedly summing the same histogram regions.
Background
VBox.count(histogram:)checkscachedCount, but the current engine never fills it. Queue sorting and population/volume comparisons therefore rescan each box. A split already computes the partial sums needed to obtain both child populations.Solution
Cache the initial box's count from the actual histogram, then cache both child counts from the existing split-axis partial sums after invalidating the inherited caches. Computing the initial count from the histogram preserves the supplied-histogram path, whose populations need not equal
pixels.count.The split axis, cut location, averages, queue ordering, and histogram precision are unchanged.
Related Issue
N/A.
Verification
swift package resolveswift build -c debugswift test --filter MmcqQuantizerTests— 14 CPU/Metal tests passed.swift test --filter PaletteKitTests --filter PaletteKitInsightsTests— 61 tests passed.swift test -c release --filter MmcqQuantizerTests— 14 CPU/Metal tests passed.swift test -c release --skip-build --filter MmcqQuantizerBenchmarks— 2 benchmarks passed in each comparison run.git diff --checkCompatibility and Impact
Additional Context
Release medians per quantization for a deterministic 100,000-pixel sampled gradient. Each clock sample contains 20 quantizations plus identical output-checksum work; values below divide by 20. There are 15 clock samples per case across three process runs with order alternated.
2286664Reproduce with
swift test -c release --filter MmcqQuantizerBenchmarks. For the baseline, use2286664with only the new benchmark file copied unchanged. Input generation and warmup are outside the measured region. These results measure MMCQ plus the checksum, not image decode, color conversion, the full extractor, or iPhone performance. Low-color shortcut/terminal workloads should not be expected to show these speedups.This branch is based directly on
mainand is independent of the transfer-function LUT change.Checklist