Skip to content

Test#1

Closed
Bhumika247 wants to merge 1 commit into
AutoPTZ:masterfrom
Bhumika247:testBranch
Closed

Test#1
Bhumika247 wants to merge 1 commit into
AutoPTZ:masterfrom
Bhumika247:testBranch

Conversation

@Bhumika247

Copy link
Copy Markdown
Collaborator

this is test

this is test

@Bhumika247 Bhumika247 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

@Bhumika247 Bhumika247 closed this Sep 21, 2022
@Bhumika247 Bhumika247 deleted the testBranch branch September 21, 2022 22:48
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>
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