Skip to content

Reduce managed coupon barcode decoding CPU and latency - #547

Merged
Szer merged 1 commit into
mainfrom
perf/coupon-managed-decoding
Oct 5, 2026
Merged

Szer merged 1 commit into
mainfrom
perf/coupon-managed-decoding

Conversation

@Szer

@Szer Szer commented Oct 5, 2026

Copy link
Copy Markdown
Owner

The managed barcode fallback repeatedly copies and rotates overlapping image regions. Use shared luminance views and SIMD row binarization to reduce that work, then decode independent crops with separate readers and a concurrency limit derived from Environment.ProcessorCount. The full-image fast path and original first-success crop priority are preserved; CPUs without SIMD use the scalar path.

In an isolated ARM64 comparison on one difficult image, five warmed paired runs reduced median managed-fallback time from 3.17 s to 1.27 s (60%) and process CPU time from 2.72 s to 1.58 s (42%). This is a targeted benchmark, not a production-wide latency estimate.

Validation:

  • 264 hermetic HTTP integration tests passed.
  • 40 OCR tests passed normally and again with hardware intrinsics disabled and one reported processor.
  • Final implementation matched the unchanged managed decoder on all 2,201 offline corpus images, plus 71 selected cases on ARM64.
  • Added coverage for low-contrast fallback recognition, concurrent calls, and patterned images with awkward widths; mandatory comment gate passed.

Recognition outputs are preserved, including existing limitations. The adapted ZXing threshold algorithm includes its attribution and Apache license.

Read cropped and rotated luminance through shared pixel views and vectorize the ZXing row threshold while preserving scalar behavior. Run crop attempts with per-worker readers bounded by Environment.ProcessorCount and retain the original success priority.

Add fallback, concurrent-recognition, and patterned-image coverage. Include attribution for the adapted ZXing threshold algorithm.
@Szer
Szer merged commit 10e5272 into main Oct 5, 2026
8 checks passed
@Szer
Szer deleted the perf/coupon-managed-decoding branch October 5, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant