perf: read each package once per track, not once per attempt
Some checks failed
tests / model-free (pull_request) Has been cancelled

Vision took a crop from 5 ms to 25 ms, so re-reading the same package on every
attempt was the measured cause of the live coverage collapse: 789 -> 60 crops/s
at 8 workers, and 12/8/2/6 labels on the same clip at four pacings.

The reading is now cached on the track and later attempts re-run only the local
lane. Measured through the real server on add/image6.jpg:

  saturated pool   15.9 -> 49.4 crops/s (8 workers, 64 crops)
  per crop         142 -> 92 ms on a 300x400 crop
  3 s clip, send   19.7 mean labels (15-24, unstable) -> 24.0 (23-25, stable)
  12 s clip, send  48/131 -> 53/131; result pacing 53/134 -> 50/135

The 12 s numbers are within run-to-run noise; the short clip is where the
pacing sensitivity lived and it is now flat across pacings.

An empty read is not cached - a crop too small or too blurry to read says
nothing about the next one - and the cache is cleared with the rest of the
evidence on a method change or a drift relabel, so a reading never outlives the
product it described. The native crop lane skips OCR on the same rule.

Test: OCR runs once per track while the local lane keeps running. Disabling the
skip makes it fail 2 != 1. Suite 280 -> 281.
This commit is contained in:
tngo 2026-09-28 23:25:09 +09:00
parent fd72251160
commit 5f6de4d48a
3 changed files with 66 additions and 7 deletions

View file

@ -523,7 +523,7 @@ class RecognitionEngine:
return DecisionPolicy().decide(lane.rank(crop), text_rank, text_read=read)
def score_crop_lanes(
self, crop: Any, method: Optional[str] = None
self, crop: Any, method: Optional[str] = None, skip_ocr: bool = False
) -> Tuple[Dict[str, float], List[Tuple[str, float]], str]:
"""Both lanes' evidence for one crop: local scores, text ranking, raw read.
@ -538,6 +538,8 @@ class RecognitionEngine:
`decide_crop`, which fuses a single crop.
"""
scores = self.score_crop(crop, method)
if skip_ocr:
return scores, [], ""
text_lane = self.identity_text_lane()
if text_lane is None:
return scores, [], ""