Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
docs(webcam): round 3 brief — settle the execution provider
EtienneLescotcf2baa28cc0e
diff --git a/technical-documentation/engineering/webcam-segmentation-bench-brief.md b/technical-documentation/engineering/webcam-segmentation-bench-brief.mdindex f0779817b..ed4a0d511 100644--- a/technical-documentation/engineering/webcam-segmentation-bench-brief.md+++ b/technical-documentation/engineering/webcam-segmentation-bench-brief.md@@ -1,117 +1,112 @@-# Brief — segmentation experiment ladder (round 2)--> **Superseded in part.** E0 was run and **falsified** the overhead-bound hypothesis this ladder-> was built on ([results](https://github.com/getopenscreen/openscreen/pull/493#issuecomment-5415093217)).-> E2 and E4 are dropped. The live levers are input resolution, fp16/int8, and the CPU EP — see-> [webcam-segmentation.md](webcam-segmentation.md).+# Brief — segmentation experiment ladder (round 3: settle the execution provider)Self-contained brief for an agent on a test machine. Read[webcam-segmentation.md](webcam-segmentation.md) for the decision this feeds.-Round 1 answered "is realtime affordable?" — *qualified yes, 2.59 ms of headroom against a floor-estimate*. Its report is in-[PR #493](https://github.com/getopenscreen/openscreen/pull/493#issuecomment-5410489010).--Round 2 answers a different question: **where do the 3.8 ms actually go, and which lever gets-them back?** A flatbuffer parse of the vendored model says the GPU is idle 96 % of the time, so-the time is overhead, not arithmetic. Confirm that, then attack it.+Previous rounds, both in PR #493:+[round 1](https://github.com/getopenscreen/openscreen/pull/493#issuecomment-5410489010) —+realtime is affordable but thin (+3.01 ms/frame, 2.59 ms headroom).+[round 2](https://github.com/getopenscreen/openscreen/pull/493#issuecomment-5415093217) —+the workload is **memory-bandwidth-bound per pixel**; input resolution is the lever+(192×112 = 1.53× at IoU 0.976, 128×80 = 2.64× at IoU 0.949).----## Hard constraints+## The question-Unchanged from round 1: **no production code touched** (nothing under `src/`, `electron/`,-`crates/compositor/`), **no dependency added to the app**, **nothing pushed**, and **no model-weights downloaded without the source being named and approved.** Everything here uses files-already in the repo.+**Does the CPU execution provider beat DirectML once both are running next to the compositor?**-Protocol per [rendering-performance.md](rendering-performance.md) §C.2 — warm-up sweep discarded,-`--repeat 3`, interleaved arms, **any arm above 15 % spread is VOID**, quiet machine, and **only-within-run ratios transfer**. Round 1 caught a fake result this way (a "60 Hz" load actually-running at 38 Hz, reporting a reassuring and wrong 0.945); assume the same traps are still there.+It is the only unknown left that changes the architecture. The CPU EP already measures **21 %+faster than DirectML** in isolation here (2.476 vs 3.119 ms p10) and it never touches the+contended GPU queue. If that holds under load, it removes the D3D11↔D3D12 shared-handle interop,+the adapter-LUID matching, the cross-queue fence and the DirectML packaging cost — on all three+platforms at once.-**Report the hardware again**, and if this is not the same box as round 1, say so — the round-1-absolutes do not transfer to it.+The risk that could kill it: this box is a **4-core / 8-thread** Ryzen 5 7520U. An ONNX Runtime+CPU session that grabs every core will fight the compositor's own CPU work. **Thread count is the+tuning knob and must be swept, not left at default.**-## E0 — prove the bound *(do this first; it decides the rest)*+## Hard constraints++Unchanged: **no production code touched** (nothing under `src/`, `electron/`,+`crates/compositor/`), **no dependency added to the app**, **nothing pushed**, **no model weights+downloaded** without the source being named and approved.-Sweep the input resolution and see whether time tracks pixels.+Protocol per [rendering-performance.md](rendering-performance.md) §C.2 — warm-up discarded,+interleaved arms, **any arm above 15 % spread is VOID**, quiet machine, **only within-run ratios+transfer**. Round 2 only became admissible after moving to **iteration-level interleaving with a+p10 statistic**; start there rather than rediscovering it. Round 2 also needed a 300 s cooldown+between sweeps — budget for it.-- 256×144 (the shipped landscape variant), then 192×108, 128×72, 64×36.-- The square variant is **already vendored** at- `public/mediapipe/selfie_segmentation/selfie_segmentation.tflite` — use it for a 256×256 point,- at zero supply-chain cost.-- **Prediction to falsify:** 64×36 has 16× fewer pixels and will *not* be 16× faster — expect- roughly 2.5–3.5 ms against 3.803. If time is flat across the sweep, the workload is- overhead-bound and E1–E3 are where the milliseconds live. If it tracks pixels, the hypothesis- is wrong, and fp16/int8 become live again.+Report the hardware and the battery state. Round 1's absolutes were depressed by a charging+battery; round 2's were not. Say which you have.-Also worth one profiler pass: per-node timings. The claim to check is that the ten-Squeeze-and-Excitation blocks — `MEAN → CONV1×1 → RELU → CONV1×1 → LOGISTIC → MUL`, some doing-**128 MACs in a whole dispatch** — cost comparable wall time to convolutions doing 2.36 M MACs.-A ~500× arithmetic difference showing up as ~1× time difference is the signature.+## The arms-## E1 — 30 Hz instead of 60+Four, interleaved at iteration level. **Keep the no-op control** — without it a drop cannot be+attributed to the GPU rather than to the load generator stealing CPU.-The largest single win available, and it is a scheduling change, not engineering. A silhouette-does not meaningfully change in 16 ms. Expected: **+1.5 ms of headroom** (2.59 → 4.09 ms).+| arm | load |+|---|---|+| **A** | compositor alone |+| **N** | pacing loop only, no inference — control |+| **B-dml** | + DirectML inference at 30 Hz |+| **B-cpu** | + CPU EP inference at 30 Hz |-Re-run the round-1 contention bench with the load generator at 30 Hz. Verify the achieved rate-inside every arm — round 1's void was caused by exactly this going unverified.+Run the whole set at **two input resolutions: 256×144 and 128×80**, so the EP choice and the+resolution lever can be read separately rather than confounded.-## E2 — ONNX Runtime session hygiene+**Verify the achieved load rate inside every arm.** Round 1's void came from a "60 Hz" load+silently running at 38 Hz and reporting a reassuring, wrong result.-DirectML (3.803 ms) and the CPU EP (3.575 ms) agreeing within 6.4 % across two unrelated engines-points at a shared constant of ~2–2.5 ms **outside both providers**, in ORT's per-`Run()` path.+## What to sweep on the CPU arm-- **Predicted finding, stated so it can be falsified:** whole-graph fusion was *off* in the- round-1 run — a run with it on would not report 32 separate `DmlFusedConv` nodes. If that is- right, this is a config change worth more than everything else combined.-- Get the authoritative config keys from `onnxruntime_session_options_config_keys.h` in the- installed package. **Do not trust remembered spellings** — an unknown key throws, which is a- cheap way to check.-- Expect the DML EP to want `enable_mem_pattern = False` and `ORT_SEQUENTIAL`; graph capture, if- available, additionally wants static shapes (satisfied — this graph is fully static) and- pre-bound, address-stable I/O via `IOBinding`.-- Measure with `IOBinding` to device-resident tensors versus the naive numpy round-trip. The gap- is the per-`Run()` overhead.+`intra_op_num_threads` at **1, 2, 4, and default**. For each, report both the inference latency+*and* the compositor's ratio against arm A. The interesting answer is almost certainly not the+fastest inference — it is the thread count where inference is fast enough and the compositor is+untouched.-## E3 — CPU EP under contention+Also report `inter_op_num_threads` if you change it, and which `ExecutionMode` you used.-The arm that could keep the **full 5.6 ms** of compositor headroom, because it never touches the-contended GPU queue — and it removes the D3D11↔D3D12 interop from the design entirely.+## What else to watch-Re-run the contention bench with a **CPU-side** inference load instead of a GPU-side one. Keep-the no-op control arm from round 1: without it, a drop cannot be attributed.+- **Does the compositor's own CPU work suffer?** Decode and mux are CPU-side. Report whether arm+ B-cpu costs the compositor more in *CPU* time even where it costs nothing in GPU time.+- The encoder mattered enormously in round 1 (−21.4 % with it, −6.5 % without). Say whether your+ bench arm has the encoder in the loop, because the CPU EP contends differently from DirectML.+- **Total system headroom**, not just the compositor's: if the CPU EP saturates the box, the app+ is unusable even with a happy compositor.-Report how many cores the load occupies, and whether the compositor's own CPU work (decode, mux)-starts to suffer — on Linux especially, where the export path is already CPU-heavy.+## Correctness check, not just timing-## E4 — a hand-fused Squeeze-and-Excitation block+IoU 0.949 at 128×80 is a number, not a verdict. Render the mask at the two sizes it will actually+be seen at and look:-Only if E0 confirms overhead-bound. This decides whether hand-written compute is worth three-implementations.+- as a **picture-in-picture** at roughly 25 % of frame width — the common case;+- **camera fullscreen**, where a 128×80 mask is upscaled ~15× and edges will be at their worst.-Write one fused depthwise-separable + SE block as a compute shader (HLSL `cs_5_0` is fine for the-probe), time it against the same block as the runtime executes it, and extrapolate. The estimate-to check: fusing away ~19 SE dispatches ≈ **1.6–2.2 ms**, more than fp16 and int8 combined could-plausibly deliver.+Say plainly whether 128×80 is shippable, whether 192×112 is the safer pick, and what the edge+artefacts actually look like. A visual call here is worth more than another decimal place.## What to report-The round-1 table shape, plus per experiment: the number, the spread, whether it was admissible,-and **whether it confirmed or falsified the stated prediction**. A falsified prediction is the-most valuable thing you can bring back.+Per arm and per resolution: the number, the spread, admissible or VOID, and the ratio against A.+Then, in prose:-Then: which lever you would pull first, and what you would stop pursuing.+- **which EP you would ship, and at which resolution and thread count**;+- whether the CPU EP removes the need for the D3D11↔D3D12 interop — the actual decision this+ round exists to make;+- every run discarded and why. A prediction falsified is the most valuable thing you can return —+ round 2's falsification of the overhead hypothesis saved building two levers that did not exist.## Do not pursue-- ~~int8 in any form~~ — **E0 falsified the overhead-bound finding, so precision is live again**,- and now for a positive reason: the workload is bandwidth-bound per pixel, so halving precision- halves the dominant cost. Still read any int8 result against the 110 `DEQUANTIZE` nodes in the- shipped `.tflite` — the weights are already fp16 at rest.-- **RobustVideoMatting** — GPL-3.0 against an MIT app. A licence landmine, before its recurrent- state is even relevant.-- MODNet, BiSeNet, SelfieMulticlass, ROI-tracking-as-a-perf-lever. Only **PP-HumanSeg v2 Lite** is- worth an hour, and only to count its operators against this model's 136.+- ORT session hygiene and hand-fused SE compute shaders — round 2 measured the total fixed cost at+ 0.43 ms, so both cap at ~14 %.+- Inputs below 128×80: at 64×48 the model emits an all-background mask. It breaks, it does not+ degrade. Both dimensions must also be **divisible by 16** or the skip-connection `Add`s fail.+- **RobustVideoMatting** — GPL-3.0 against an MIT app.+- MODNet, BiSeNet, SelfieMulticlass, ROI-tracking as a perf lever.++fp16/int8 is live again after round 2, but it is **round 4** — settle the provider first, since+precision interacts with which one you pick.