diff --git a/docs/design/gpui-spikes.md b/docs/design/gpui-spikes.md index 552ec48..04617e4 100644 --- a/docs/design/gpui-spikes.md +++ b/docs/design/gpui-spikes.md @@ -10,11 +10,16 @@ with the conditions under "Settled for step 3". The work was started on 2026-10-25 by an attempt that was interrupted before it committed anything or measured the video cases; its code was judged and kept (with the changes listed in "History"), and every figure and check below was run again on -2026-10-27. +2026-10-27. The review of that day's report found three minors, closed in +the commits after it: nightly clippy is clean (`as_chunks` in `bgra.rs`, and +a second lint that the first hid), the video headline says "raw" with the +quiet-window pipeline figure beside it, and the `--no-drop` row's XDamage +exception is explained (a counter window longer than the case). `gpui-kit` +0.8.1 of 2026-10-26 is still unmeasured, as "The version to pin" says. | Spike | The plan's no-go | Seen (software rendering, see Setup) | Verdict | |---|---|---|---| -| 1. Video | below 30 fps at 1440p60 with no custom-element way out | `img()` with the port of `video.rs`' delivery: 42 to 49 fps at 1440p60, 55 to 58 at 1080p60, on lavapipe; `cx.drop_image` keeps the atlas flat; a new 1440p picture costs GPUI's thread 6 to 7 ms; a persistent texture needs a GPUI change | **go**, with a GPU run first in the viewer slice | +| 1. Video | below 30 fps at 1440p60 with no custom-element way out | `img()` with the port of `video.rs`' delivery, **raw (frames from memory, no decoder)**: 42 to 49 fps at 1440p60, 55 to 58 at 1080p60, on lavapipe; with the real VP8 encoder and decoder in the same process (pipeline) 40.8 fps at 1440p60 in a quiet window (the reviewer's run) and 10 at a busy one (the pipeline scales with free CPU); `cx.drop_image` keeps the atlas flat; a new 1440p picture costs GPUI's thread 6 to 7 ms; a persistent texture needs a GPUI change | **go**, with a GPU run first in the viewer slice | | 2. Composer, IME, chat lines | no usable preedit | X11 preedit with fcitx5 and Pinyin works (marked text, candidate window at the caret, commit); emoji at the caret, paste, Ctrl+Enter, `TextRun`s as `StyledText` with links all work; Wayland preedit not exercised headless; colour emoji need a one-line GPUI patch | **go** | | 3. Second window | the second window cannot share state or steal the hotkey | one root entity in two windows, both change it, focus, fullscreen and close work, the X11 global hotkey reaches the model while the second window has focus, the preview is one shared `RenderImage` (+46 % of a core on lavapipe for the second window) | **go** | @@ -50,8 +55,9 @@ window takes the newest from the `Latest` in `render`, shows it with `img()` and drops the one it replaces from every window's atlas (`cx.drop_image`). `--mode pipeline` is `Video::demo`'s source (`LocalPreview` with `SourceId::Synthetic`, the real VP8 encoder and -decoder, in the same process); `--mode raw` hands I420 frames from memory to -the converter at 60 fps, so what is lost is GPUI's; `--mode static` is the +decoder, in the same process); `--mode raw` hands I420 frames from memory +(no encoder, no decoder) to the converter at 60 fps, so what is lost is +GPUI's, and "raw" below always means this source; `--mode static` is the control: one picture uploaded once, the window repainted every frame. `Buffers`' reuse cannot be ported: a `RenderImage` owns its pixels and gives no way back to them, so every picture is a new buffer. @@ -84,6 +90,7 @@ thread): | raw 1920x1080, earlier run | 57.6 | 410 % | 376 % | 18.1 % | 7.8 % | flat | 43 / 43 | | pipeline 1920x1080 (encoded 26.3 fps) | 22.9 | 1085 % | 135 % | 7.1 % | 2.4 % | flat | 34 / 43 | | pipeline 2560x1440 (encoded 10.8 fps) | 9.6 | 1131 % | 102 % | 9.9 % | 1.9 % | flat | 43 / 53 | +| pipeline 2560x1440, **a quiet window** (the reviewer's run of 2026-10-27; encoded 50.4 fps, decoded 49.5) | **40.8** (XDamage 41.3) | 1047 % (encoder 454 %) | 476 % | 28.7 % | 9.5 % | flat (499 MiB) | 24 / 31 | | pipeline 2560x1440, voelin-media's RGBA (encoded 13.3) | 12.5 | 1259 % | 131 % | 12.9 % | 2.2 % | flat | 53 / 61 | | **no `drop_image`**, pipeline 2560x1440 at 15 fps, 12 s | 13.9 | 1219 % | 146 % | 17.8 % | 2.3 % | **+1.9 GiB in 10 s** (827 to 2,816 MiB) | 61 / 45 | | pipeline 1280x720 at 30 fps, 4.6 Mbit/s (`Video::demo`'s settings) | 28.5 (of 29.6 decoded) | 317 % | 79 % | 6.0 % | 1.2 % | flat (253 MiB) | 45 / 36 | @@ -91,15 +98,27 @@ thread): The X server counted as many content changes of the window (XDamage, from outside the process) as the spike counted frames shown, within 0.3 fps, in -every case but the `--no-drop` one. +every case, the `--no-drop` one included. That case's summary line says +otherwise (13.9 frames shown a second against an XDamage mean of 0.5; the +reviewer's run: 5.0 against 0.1) and the summary is what is off, not the +frames: `measure.sh` runs `damage-count` for the 69 s of the 70-second cases +with the first 10 not counted, but this case lasts 12 s with 2 s of warm-up, +so its mean spreads the last two seconds of a window over 59. Second by +second, while the window lived, the X server counted 11 to 16 changes (13.8 +on average) against 13.6 frames shown (the reviewer's run: 5.2 against 5.1), +and a re-run with `damage-count spike-video 11 2`, the case's own length, +gave 6.8 against 7.0 (Xvfb `:93`, lavapipe, load 43 / 47, hence the lower +rate): the frames shown here were frames the X server saw. What the figures say: - **`img()` holds 1440p60 above the plan's 30 fps on a software device** - (42 and 49 fps in two runs, 55 and 58 at 1080p), with GPUI's thread a - quarter to a third busy. The static control repaints the same window at - 60 to 62 fps, so what the raw cases lose is the cost of a new picture per - frame, not of drawing the window. + (raw, frames from memory with no decoder: 42 and 49 fps in two runs, 55 + and 58 at 1080p; with the VP8 encoder and decoder in the process, 40.8 fps + in a quiet window), with GPUI's thread a quarter to a third busy. The + static control repaints the same window at 60 to 62 fps, so what the raw + cases lose is the cost of a new picture per frame, not of drawing the + window. - **The cost of a new picture on GPUI's thread:** main-thread CPU per frame goes from 0.8-0.9 ms (static) to 2.8-3.1 ms at 1080p and 6.7-8.0 ms at 1440p (raw), so a new 1440p picture costs GPUI's thread 6 to 7 ms. In @@ -113,11 +132,19 @@ What the figures say: picture's size (14 MiB) of where they started; without it every picture stays in the atlas (lavapipe's textures are process memory: +1.9 GiB in 10 s at 15 fps, 11.6 GiB a minute). -- **The pipeline cases are bound by the encoder**, not by GPUI: the - synthetic sender's VP8 encoder runs in the same process and kept up with - 26 fps at 1080p and 11 at 1440p at this load (9 to 11 cores busy), and - the window showed nearly every frame decoded. In the client, the encoder - runs on the streamer's machine. +- **The pipeline cases are bound by CPU contention, the encoder being the + largest user**, not by GPUI: the synthetic sender's VP8 encoder runs in + the same process, takes 450 to 1000 % of the CPU, and kept up with 26 fps + at 1080p and 11 at 1440p at the loads of these runs (34 to 53), when the + window showed nearly every frame decoded. So the pipeline rows above (22.9 + fps at 1080p, 9.6 at 1440p) scale with the free CPU and say more about the + machine's load that day than about GPUI: in a quiet window (the reviewer's + run, load 24 to 31, not repeated here: the load stayed above 40 while this + page was revised) the same 1440p60 case encoded 50.4 fps and decoded 49.5, + and the window showed 40.8 (XDamage 41.3) on 1047 % of CPU (encoder 454 %, + llvmpipe 476 %, memory flat), in line with the raw case's 42 to 49; at a + load of about 100 (104 before, 97 after) the same case showed 2 fps + (encoded 2.1). In the client, the encoder runs on the streamer's machine. - **Against Slint, same machine and display** (the only rate the demo stream offers is `StreamerConfig::default()`'s 1280x720 at 30 fps; Slint at 1440p60 would need a change in `voelin-ui`, out of this task's scope): @@ -154,7 +181,9 @@ rendering, it is an optimisation for 4K and high refresh rates, not a condition of the go. **Go.** The video path works on `img()` with the port of today's delivery, -above the plan's threshold at 1440p60 on a software device, with a flat +above the plan's threshold at 1440p60 on a software device (raw, frames from +memory with no decoder, 42 to 49 fps; with the VP8 pipeline in the process, +40.8 fps in a quiet window, less when the machine is busy), with a flat atlas; the conditions are a GPU run in slice 6 and the per-picture cost above. @@ -406,11 +435,12 @@ session. What it needs: a new picture (spike 1) stays on the CPU's side as two copies of the picture. - **Software only** (a VM, a remote desktop): lavapipe works and is what - these figures measure. A 2560x1440 window repaints at 60 fps with - nothing new to upload and at 42 to 49 with a new picture every frame, on - 5 to 7 of this CPU's cores; the UI around it costs little (spike 3's - windows, 1000x900 and 1200x900, cost half a core each at 15 frames a - second). + these figures measure. A 2560x1440 window repaints at 60 fps with nothing + new to upload and at 42 to 49 with a new picture every frame (raw: from + memory, no decoder; 41 with the VP8 pipeline in the process, in a quiet + window), on 5 to 7 of this CPU's cores; the UI around it costs little + (spike 3's windows, 1000x900 and 1200x900, cost half a core each at 15 + frames a second). - X11 needs a window manager for fullscreen, activation and close requests (openbox here); GPUI asks for XInput 2.4 and logs "Found no xinput mouse pointers" on Xvfb, harmlessly. On Wayland, GPUI needs a seat (weston's diff --git a/spikes/gpui/video/README.md b/spikes/gpui/video/README.md index 4940473..8c77039 100644 --- a/spikes/gpui/video/README.md +++ b/spikes/gpui/video/README.md @@ -54,7 +54,7 @@ average before and after) and a screenshot from the warm-up to `$OUT` | `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) | +| `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` |