Skip to content

Overlap Azure OCR with local barcode decoding - #549

Merged
Szer merged 1 commit into
mainfrom
perf/coupon-overlap-ocr
Oct 5, 2026
Merged

Szer merged 1 commit into
mainfrom
perf/coupon-overlap-ocr

Conversation

@Szer

@Szer Szer commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Slow barcode decoding delays the Azure OCR request even though the two stages read the same image independently. Start the OCR task first, run the local barcode decoder, then await OCR before parsing the combined result. This overlaps network wait with CPU work while preserving local-barcode priority, one OCR request per recognition, and backend-failure handling. It needs no additional CPU worker.

Validation:

  • All 45 OCR tests and 264 CouponHubBot integration tests pass. New cases cover deferred success, empty results, faults, cancellation, and synchronous OCR failure.
  • All 2,201 original coupon images return identical recognition outputs before and after with the same mock OCR response.
  • Five paired runs on five original images in a two-CPU ARM64 pod, with a simulated one-second OCR response, give the median end-to-end timings below. No paid Azure calls were made; these measurements demonstrate overlap rather than predict live Azure latency.
Original-image case Sequential Overlapped
Fast native read A 1.013 s 1.001 s
Fast native read B 1.012 s 1.000 s
Managed fallback success A 1.220 s 1.000 s
Managed fallback success B 1.498 s 1.000 s
Exhausted local search 1.974 s 1.000 s

@Szer
Szer marked this pull request as ready for review October 5, 2026 10:16
@Szer
Szer merged commit e29934b into main Oct 5, 2026
8 checks passed
@Szer
Szer deleted the perf/coupon-overlap-ocr branch October 5, 2026 10:18
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