Skip to content

Visual Studio Code, rebuilt in Rust

Rust

docs(notes): scroll frame costs per surface and what is left

rokartur9837373151f1
diff --git a/port/notes.md b/port/notes.md
index 08084cc1128..b4d3f796670 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -992,6 +992,7 @@ What to do (milestone 21, in order):
- `port/tools/bench`: Wu's `script/memory-benchmark` method generalized to N apps (`APPS="name=cmd;..."`), plus an extension host line per app.
- Wu's `.cargo/config.toml` links with Homebrew lld on aarch64-apple-darwin; the Studio has no lld, so Wu is built with `RUSTFLAGS="-C symbol-mangling-version=v0 --cfg tokio_unstable"` (same flags, Apple ld). Env `CARGO_TARGET_*_RUSTFLAGS` does not work for this: cargo appends it to the config array.
- Scroll frame costs (branch port-fix-settings-scroll): `settings_scroll_frame_time` (ignored test, `cargo test --release -p app -- --ignored settings_scroll_frame_time --nocapture`) scrolls the whole settings tree (1810 rows) in a headless 1440x900 workbench with gpui's NoopTextSystem, 600 frames of a 30px trackpad delta. Before: median 37.1 ms, p95 51.2 ms; `sample` put about 90% of the frame in `wordify_key` compiling 14 regexes per call, twice per visible row, and a third of the rest in `trim_category_for_group` compiling its group id patterns. With the regexes compiled once: median 3.3 ms, p95 3.7 ms. With the `config.*` context keys kept by `Configuration` until a layer changes (they were flattened again on every `key_context` call): median 1.7 ms, p95 2.1 ms (3 runs). The real app (Settings, search "editor", 572 rows; scratch CGEvent probe at 120 Hz on the Studio lane, main thread sampled): `Window::draw` held the main thread 93 to 97% of the time before, 56% after with the same input; what is left is the whole Workbench rendering on each frame (the layout row's gap). CoreText needs the main thread, which libtest never gives, so the headless check cannot use real text shaping.
+- Scroll frame costs, every surface (branch port-fix-settings-scroll): `workbench/scroll_frame_time.rs` holds one ignored test per surface (`cargo test --release -p app -- --ignored scroll_frame_time --nocapture --test-threads=1`) on one fixture: a folder of 801 files with a 20000-line `large.ts` open, every built-in extension installed and running, 1440x900, gate median and p95 under 8 ms. Median / p95 ms for Explorer, Editor, Extensions @builtin and Settings (now with a folder open, so not comparable to the paragraph above): at abfb67458da 194.0 / 281.5, 236.2 / 252.2, 4.3 / 11.0, 190.8 / 228.0; with the Explorer drawing only the rows in view (taffy laid out all 801 rows) 35.8 / 41.0, 84.5 / 89.5, 4.2 / 4.5, 37.5 / 54.4; with `FileTree` reading a folder again only when its mtime changes (`rows()` listed and stat-ed every expanded folder, several times per frame through `key_context`) and glob patterns parsed once as glob.ts `CACHE` does (`resource_editors` compiled a regex per custom editor selector per `key_context` call) 13.3 / 39.2, 22.8 / 54.0, 4.3 / 5.5, 14.6 / 16.1. The Studio is shared, so runs vary by about 30%. What is left, from `sample`: in the Explorer half the frame is taffy laying out the whole workbench tree, where a nested flex item is measured twice per level; in the Editor render is 60% of the frame, of which the minimap 20% (`minimap_runs` resolves each token's theme style on every frame, where vscode-textmate keeps it in the token's metadata) and `key_context` 16% (built in full by the menubar, the timeline toolbar three times, the editor title actions, the outline pane and the floating menu). The Extensions badge the layout gap names does not show in a sample of the harness. Cached part views (`AnyView::cached`) would skip render and layout of the parts a scroll does not touch, but in the vendored gpui a notify of a rendered entity invalidates that entity's view only and fires no observers, so a part view drawn from the Workbench's state would not redraw when that state changes: this needs the parts' state in their own entities or a gpui change.
## GUI lanes (Studio)