Test#1
Closed
Bhumika247 wants to merge 1 commit into
Closed
Conversation
This was referenced Jun 24, 2026
TCVinNYC
added a commit
that referenced
this pull request
Jun 26, 2026
… source (#120) ## Problem With multiple cameras the app pegged CPU (~930% / 66% system on 4 real cameras) with bursty variance and frame drops. Profiling the **live** session (macOS \`sample\`) showed the #1 consumer was ORT thread-pool **spin-wait** (\`ThreadPoolTempl::WorkerLoop\`, 10,105 leaf samples; 88 ORT worker threads) — threads busy-spinning between intermittent inference runs, **not** actual compute. insightface's SCRFD+ArcFace sessions made it worse: \`get_model()\` forwards only \`providers\`, so they ran cores-wide + spinning, bypassing the per-camera thread cap. ## Fix - **\`inference.py\`** — \`_apply_low_idle_threading()\` disables ORT intra/inter-op spinning (\`session.intra_op.allow_spinning=0\`) and forces a single sequential inter-op pool on every \`make_session()\` session (detector + pose). Pure scheduling change; identical inference results. - **\`identify.py\`** — \`_capped_insightface_sessions()\` scopes a patch of \`onnxruntime.InferenceSession.__init__\` to inject a capped, non-spinning \`SessionOptions\` during \`FaceAnalysis\` construction (the only hook insightface leaves). Guarded by a module lock since the degraded per-worker face-build path isn't otherwise serialised across camera threads. ## Results (validated) | | old | fixed | |---|---|---| | Inference pool, headless A/B (4 cams, yolo11m, all services) | 514% | **273%** | | **Real 4 cameras, full pipeline (PyCharm)** | **~930% / 66% sys** | **~411% / 29% sys** | A **2.3× reduction**, under the 30% system target, with the CPU variance gone. Live re-profile confirms \`WorkerLoop\` is eliminated from the hotspots. ## Test / scaling infrastructure (enables headless multi-camera CPU validation, no camera permission) - **\`SyntheticAdapter\`** (\`source type: synthetic\`) — procedural / image / video synthetic source that pans the scene so detection/tracking/ego all run; effective-fps telemetry (\`AUTOPTZ_SYNTH_DEBUG\`). - **\`AUTOPTZ_DB_PATH\`** — run against an isolated config profile. - **\`AUTOPTZ_SKIP_CAMERA_PREFLIGHT\`** — start the engine with no local camera (NDI/RTSP/synthetic-only or headless), instead of gating all engine start on macOS camera permission. - \`tests/test_synthetic_source.py\` (9 tests). All 1336 tests pass; ruff + mypy + selftest green. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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.
this is test