Files
faumarayandClaude Sonnet 5.5 6f2c64aa63 docs/design/gpui-spikes.md: video headline labelled raw, quiet-window pipeline figure, the --no-drop XDamage row explained
The headline video figure (status table, the go paragraph, the software
bullet) is the raw source, frames from memory with no decoder: it now
says so. The pipeline rows (22.9 fps at 1080p, 9.6 at 1440p) were load
artifacts: the page now carries the reviewer's quiet-window run of
pipeline-1440p60 (40.8 fps shown, XDamage 41.3, encoded 50.4, decoded
49.5, process 1047 %, encoder 454 %, llvmpipe 476 %, memory flat, load
23.5 / 30.6; not repeated here, the load stayed above 40), says the
pipeline rows scale with free CPU (the in-process encoder takes 450 to
1000 %) and that the cases are bound by CPU contention, the encoder being
the largest user. The go verdict stays.

The XDamage exception of the --no-drop case is a measurement artifact,
not frames counted and not presented: measure.sh runs damage-count for
69 s with 10 s of warm-up while the case lasts 12 s with 2 s, so the mean
spreads two seconds of window over 59. Second by second the counts match
(13.8 against 13.6; the reviewer's run 5.2 against 5.1) and a re-run with
the counter set to the case's own length gave 6.8 against 7.0 (Xvfb :93,
lavapipe, load 43 / 47). The video README's case row says so. No code
change.

The status paragraph records this round in two sentences (gpui-kit 0.8.1
of 2026-10-26 still unmeasured).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 04:51:49 +03:00

73 lines
4.5 KiB
Markdown

# Spike 1: the video path
`spike-video` shows the synthetic test pattern in a GPUI window the way
`voelin-ui` shows a watched stream:
- **Source.** `--mode pipeline` runs `voelin_core::media::LocalPreview` with
`SourceId::Synthetic`, as `Video::demo` (`crates/voelin-ui/src/video.rs`)
does: capture, the VP8 encoder (libvpx), the decoder, no server.
`--mode raw` hands decoded-looking I420 frames from memory at `--fps`
straight to the converter, so a frame rate below the source's belongs to
the conversion and GPUI alone.
- **Delivery** (`src/frames.rs`): the port of `video.rs`' `deliver`,
`FrameSlot`, `Handoff` and `Buffers`. The decoder hands over its newest
frame only; a converter thread (`voelin-picture`) turns it into an
`Arc<RenderImage>` (BGRA, `spike_common::bgra::to_bgra`, the BGRA twin of
`voelin_media::convert::to_rgba`) and puts it into a `Latest`; the window
is woken through a channel only when the slot was empty (GPUI's
`AsyncApp` is not `Send`). A `RenderImage` owns its pixels and gives no
way back to them, so the buffer reuse of `Buffers` cannot be ported: every
picture is a new buffer.
- **Window** (`src/main.rs`): `img(ImageSource::Render(..))`, the picture
taken from `Latest` in `render`, the one it replaces dropped from every
window's sprite atlas with `cx.drop_image` (`--no-drop` leaves it: the
negative control). `inactive_frame_interval: None`: GPUI throttles
animation frames of an unfocused window to 30 fps by default.
Once a second it prints a JSON line (CPU of the process and of each thread
group in percent of one core, resident memory, and per second: frames
captured, encoded, decoded, handed to the converter, converted, shown and
rendered, conversion time); at the end a summary over the steady part.
## Reproducing the measurements
Build, then run every case on the headless display (Xvfb `:91`, openbox,
lavapipe through wgpu's Vulkan backend; see [../README.md](../README.md)):
```sh
spikes/gpui/shell.sh sh -c 'cd spikes/gpui && cargo build --locked --release'
# the Slint app, for its demo stream (the root workspace, Rust 1.94):
TOOLCHAIN=1.94 spikes/gpui/shell.sh cargo build --locked --release -p voelin-ui
spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/video/measure.sh
```
`measure.sh` runs, 70 s each with 10 s of warm-up not averaged
(`SECONDS_RUN`, `WARMUP`), and writes `<case>.jsonl`, `<case>-damage.jsonl`
(the X server's count of the window's content changes), `<case>.load` (load
average before and after) and a screenshot from the warm-up to `$OUT`
(default `.scratch/gpui-spikes-results`):
| Case | Command |
|---|---|
| `bench` | `spike-video --bench --iterations 300` (RGBA against BGRA, 1080p and 1440p, into a reused and a new buffer, and as a `RenderImage`) |
| `static-1080p60`, `static-1440p60` | `spike-video --mode static --size …`: one picture, the window repainted every frame (the control: what GPUI and the renderer manage with no upload) |
| `raw-1080p60`, `raw-1440p60` | `spike-video --mode raw --size 1920x1080` (or `2560x1440`) `--fps 60` |
| `pipeline-1080p60`, `pipeline-1440p60` | `spike-video --mode pipeline --size … --fps 60` (bitrate automatic, as the share dialog's default) |
| `pipeline-1440p60-rgba` | the same with `--convert rgba` (voelin-media's conversion; red and blue show swapped) |
| `nodrop-1440p` | `spike-video --mode pipeline --size 2560x1440 --fps 15 --no-drop --seconds 12 --warmup 2` (memory grows by a picture per frame; its `-damage.jsonl` summary averages over a 59-s window set for the other cases, so read the per-second lines or run `damage-count spike-video 11 2` beside it) |
| `pipeline-720p30` | `spike-video --mode pipeline --size 1280x720 --fps 30 --bitrate 4608`: `Video::demo`'s own settings (`StreamerConfig::default()`) |
| `slint-720p30` | `voelin` with `VOELIN_DEMO_STREAM=1 SLINT_BACKEND=winit-software`, measured from outside with `proc-meter` and `damage-count` |
One case: `spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/video/measure.sh raw-1440p60`.
GPUI's Wayland backend, on sway's headless backend with a 2560x1440
output (the window is tiled to it; no damage count there):
```sh
spikes/gpui/shell.sh spikes/gpui/headless-wayland.sh -s 2560x1440 -- sh -c \
'mkdir -p .scratch/gpui-spikes-results && target/release/spike-video --mode raw --size 2560x1440 --fps 60 --seconds 40 --warmup 10 --out .scratch/gpui-spikes-results/wayland-raw-1440p60.jsonl'
```
The figures and what they mean are in
[docs/design/gpui-spikes.md](../../../docs/design/gpui-spikes.md#spike-1-the-video-path).