Skip to content

Visual Studio Code, rebuilt in Rust

Rust

chore(port): measure idle CPU in one window after launch for both apps

rokarturd406b3859865
diff --git a/README.md b/README.md
index 83b7dd88166..63d5144ea9e 100644
--- a/README.md
+++ b/README.md
@@ -26,16 +26,16 @@ Builds for macOS and Linux; Windows is in progress.
## Benchmark
-Opening the VS Code 1.147.0 source (21,462 files) with warm caches, median of 5 runs:
+Opening the VS Code 1.148.0 source (21,627 files) with warm caches, median of 5 runs:
-| | VSRustium | VS Code 1.147.0 |
+| | VSRustium | VS Code 1.148.0 |
|---|---|---|
-| Window with the folder | **0.79 s** | 0.99 s |
-| Ready (CPU settled) | **2.5 s** | 12.1 s |
-| Memory (footprint, all processes) | **218 MiB** | 975 MiB |
-| CPU time until ready | **2.5 s** | 10.1 s |
-| Idle CPU | 1.9 % of a core | **0.2 %** of a core |
-| Quit | **0.14 s** | 0.23 s |
+| Window with the folder | **0.65 s** | 2.38 s |
+| Ready (CPU settled) | **6.2 s** | 13.4 s |
+| Memory (footprint, all processes) | **218 MiB** | 584 MiB |
+| CPU time until ready | **2.2 s** | 9.4 s |
+| Idle CPU, 60 to 90 s after launch | 0.4 % of a core | **0.3 %** of a core |
+| Quit | **0.15 s** | 1.28 s |
Release builds of both with default settings and the same built-in extensions, AI features off in VS Code (VSRustium leaves them out), on a Mac Studio (M1 Max, 32 GB, macOS 27). Both are measured from outside the same way: [`port/tools/bench`](port/tools/bench) runs it, and [port/results/benchmark.md](port/results/benchmark.md) has the method, the raw samples and the command.
diff --git a/port/results/benchmark.md b/port/results/benchmark.md
index 97bd674738b..7a4515b1bc0 100644
--- a/port/results/benchmark.md
+++ b/port/results/benchmark.md
@@ -1,48 +1,47 @@
# Benchmark
-VSRustium against VS Code 1.147.0, both packaged release builds, opening the VS Code 1.147.0 checkout (21462 files, a git repository with its `node_modules`), measured from outside with `port/tools/bench`. Median of 5 runs after one warm-up run per app, runs alternating between the apps.
+VSRustium against VS Code 1.148.0, both packaged release builds, opening the VS Code 1.148.0 checkout (21627 files, a git repository with its `node_modules`), measured from outside with `port/tools/bench`. Median of 5 runs after one warm-up run per app, runs alternating between the apps.
-| | VSRustium | VS Code 1.147.0 |
+| | VSRustium | VS Code 1.148.0 |
|---|---|---|
-| Window with the folder | 0.79 s | 0.99 s |
-| Ready (CPU settled) | 2.47 s | 12.10 s |
-| CPU time until ready | 2.52 s | 10.07 s |
-| Memory (footprint, all processes) | 218 MiB | 975 MiB |
-| of which the extension host | 74 MiB | 195 MiB |
-| Idle CPU, 10 s after ready | 1.9 % of a core | 0.2 % of a core |
-| Quit | 0.14 s | 0.23 s |
+| Window with the folder | 0.65 s | 2.38 s |
+| Ready (CPU settled) | 6.21 s | 13.38 s |
+| CPU time until ready | 2.19 s | 9.35 s |
+| Memory (footprint, all processes) | 218 MiB | 584 MiB |
+| of which the extension host | 76 MiB | 108 MiB |
+| Idle CPU, 60 to 90 s after launch | 0.4 % of a core | 0.3 % of a core |
+| Quit | 0.15 s | 1.28 s |
Setup:
-- Machine: Mac Studio, Apple M1 Max (10 cores), 32 GB, macOS 27.2.1. The Studio is shared with other build and test jobs (load average 28 to 36 during the runs), so single runs vary; the medians are steadier.
-- VSRustium: `port/tools/package-app` of `vsrustium/main` at 161bc73f69f (a release build, ad-hoc signed, the reference's built-in extensions).
-- VS Code: the official 1.147.0 darwin-arm64 build from `update.code.visualstudio.com`, started with `--disable-extension GitHub.copilot-chat`: the port leaves Copilot Chat out by decision (`port/notes.md`), so both run the same built-in extensions.
+- Machine: Mac Studio, Apple M1 Max (10 cores), 32 GB, macOS 27.2.1. The Studio is shared with other build and test jobs (load average 17 to 32 during the runs), so single runs vary; the medians are steadier.
+- VSRustium: `port/tools/package-app` of the `worktree-idle-reveal` branch at f461b689c0d, on `vsrustium/main` bbf7e6dd0ca (a release build, ad-hoc signed, the reference's built-in extensions).
+- VS Code: the official 1.148.0 darwin-arm64 build from `update.code.visualstudio.com`, started with `--disable-extension GitHub.copilot-chat`: the port leaves Copilot Chat out by decision (`port/notes.md`), so both run the same built-in extensions.
- Both: default settings except `"chat.disableAIFeatures": true` (without it VS Code opens its Copilot sign-in dialog on every start of a fresh profile and keeps a core busy drawing it), `--disable-workspace-trust` (otherwise both open the folder in Restricted Mode, without git and most extensions), an empty extensions folder, and one user data folder per app for all its runs, so caches are warm after the warm-up.
-Method (`port/tools/bench`, header): window is launch to the first on-screen window of the launched process; ready is launch to the start of the first 2 s after the window in which the process tree used under 10% of a core in each 0.5 s; CPU time is the tree's at ready, without processes that exited before; idle CPU is the tree's over the 10 s after ready; memory is `footprint` summed over the tree after that; quit is the quit Apple event until every process of the tree is gone.
+Method (`port/tools/bench`, header): window is launch to the first on-screen window of the launched process; ready is launch to the start of the first 2 s after the window in which the process tree used under 10% of a core in each 0.5 s; CPU time is the tree's at ready, without processes that exited before; idle CPU is the tree's from 60 s to 90 s after launch; memory is `footprint` summed over the tree after that; quit is the quit Apple event until every process of the tree is gone.
Read with care:
-- VS Code's ready is bimodal: in 2 of 5 runs a 2 s pause at about 5 s passed as settled, and those runs then used 20% of a core in the idle window; in the other 3 the tree settled at about 12 s and idled at 0.2%. The median is one of the latter.
-- VSRustium idles at 1.9% of a core in the 10 s after ready, VS Code at 0.2%: VS Code wins this row. Not investigated.
-- VSRustium's run 5 (window 2.28 s, ready 8.18 s) and VS Code's quit in run 5 (22.3 s) are outliers that the shared Studio's load may explain; they stay in the samples.
+- The idle window changed: it was the 10 s after each app's own ready, and is now the same 60 to 90 s after launch for both, and memory moved with it. From ready, the window caught each app in a different state: VSRustium's ready (2 to 8 s) comes before its extension activation ends (git and the extension host busy until about 9 s), and VS Code's ready is bimodal (a 2 s pause at about 5 s passes as settled) and VS Code 1.148.0 has a burst of 30 to 50 % of a core at about 30 s after launch. Per-second traces of both trees from 20 to 60 s after launch show that burst as the last busy stretch of either app. The 1.147.0 numbers from the old window (VSRustium 1.9 %, VS Code 1.147.0 0.2 %) are in this file's git history.
+- VS Code's window and quit medians carry load outliers (window 0.53 to 2.64 s, quit 0.20 to 2.29 s); VSRustium's ready spreads from 2.12 to 8.01 s with the load. All stay in the samples.
Samples (s, %, MiB), in run order:
-| metric | VSRustium | VS Code 1.147.0 |
+| metric | VSRustium | VS Code 1.148.0 |
|---|---|---|
-| window | 0.98 0.72 0.75 0.79 2.28 | 0.95 0.96 1.00 1.01 0.99 |
-| ready | 3.19 2.40 2.43 2.47 8.18 | 4.84 12.10 5.04 12.26 12.80 |
-| CPU until ready | 2.95 2.57 2.52 2.51 2.38 | 7.70 10.07 7.97 10.19 10.70 |
-| idle CPU | 1.9 1.7 1.9 2.0 1.0 | 19.6 0.2 20.5 0.2 0.2 |
-| memory | 218 217 219 219 217 | 975 874 925 986 984 |
-| extension host | 73 74 75 74 73 | 196 197 193 195 195 |
-| quit | 0.13 0.13 0.16 0.15 0.14 | 0.23 0.20 0.23 1.10 22.30 |
+| window | 0.65 1.30 0.64 1.46 0.48 | 1.71 0.53 2.40 2.38 2.64 |
+| ready | 6.21 8.01 2.94 7.28 2.12 | 13.38 12.04 13.45 6.28 14.44 |
+| CPU until ready | 1.65 2.19 2.90 2.08 2.28 | 10.02 8.78 9.35 7.05 10.35 |
+| idle CPU | 0.5 0.4 0.4 0.4 0.4 | 0.2 0.3 0.3 0.6 0.2 |
+| memory | 229 215 217 218 219 | 583 603 611 580 584 |
+| extension host | 84 70 76 76 79 | 108 112 111 107 107 |
+| quit | 0.23 0.12 0.15 0.14 0.24 | 2.29 0.26 1.28 0.20 1.58 |
To rerun, on the Studio after a release build and `port/tools/package-app`, with the VS Code build unpacked in `/tmp/vscode`:
```
-FOLDER=$HOME/Developer/vscode-ref SETTINGS='{"chat.disableAIFeatures": true}' \
+FOLDER=$HOME/Developer/vscode-ref-1.148.0 SETTINGS='{"chat.disableAIFeatures": true}' \
APPS='vsrustium=native/target/VSRustium.app/Contents/MacOS/vsrustium;vscode="/tmp/vscode/Visual Studio Code.app/Contents/MacOS/Code" --disable-extension GitHub.copilot-chat' \
port/tools/bench
```
diff --git a/port/tools/bench b/port/tools/bench
index 113c18c3af1..0faf676d080 100755
--- a/port/tools/bench
+++ b/port/tools/bench
@@ -6,7 +6,8 @@
# ready: launch to the start of the first 2 s, after the window, in which the process tree used under 10% of a core in
# each 0.5 s
# cpu: CPU time of the process tree at ready (processes that exited before are not counted)
-# idle: CPU of the tree over IDLE_SECONDS after ready, % of a core
+# idle: CPU of the tree from IDLE_FROM s after launch over IDLE_SECONDS, % of a core: one window for every app, past
+# startup and extension activation (VS Code 1.148.0 bursts at about 30 s)
# memory: footprint(1) summed over the tree after that, and the part of it in extension host processes
# quit: the quit Apple event to the launched process until every process of the tree is gone
# Prints one TSV row per app and metric: the median and the samples.
@@ -14,12 +15,13 @@
# APPS="name1=command1;name2=command2" FOLDER=<dir> port/tools/bench
# Each command gets --disable-workspace-trust --user-data-dir <dir> --extensions-dir <dir> <FOLDER> appended; the
# command must exec the app's binary (the process that owns its windows). SETTINGS (a JSON object) becomes every
-# app's user settings.json. RUNS (5) and IDLE_SECONDS (10) override the defaults.
+# app's user settings.json. RUNS (5), IDLE_FROM (60) and IDLE_SECONDS (30) override the defaults.
set -euo pipefail
source "$(dirname "$0")/gui-lock.sh"
RUNS=${RUNS:-5}
-IDLE_SECONDS=${IDLE_SECONDS:-10}
+IDLE_FROM=${IDLE_FROM:-60}
+IDLE_SECONDS=${IDLE_SECONDS:-30}
FOLDER=${FOLDER:?set FOLDER=<folder to open>}
IFS=';' read -r -a apps <<< "${APPS:?set APPS=\"name=command;...\"}"
scratch=$(mktemp -d)
@@ -101,9 +103,11 @@ measure_once() {
return 1
fi
done
+ local idle idle_start
+ sleep "$(awk -v s="$start" -v n="$(now)" -v f="$IDLE_FROM" 'BEGIN { d = s + f - n; print (d > 0 ? d : 0) }')"
+ idle_start=$(tree_cpu "$pid")
sleep "$IDLE_SECONDS"
- local idle
- idle=$(awk -v a="$(tree_cpu "$pid")" -v b="$after" -v s="$IDLE_SECONDS" 'BEGIN { printf "%.1f", (a - b) / s * 100 }')
+ idle=$(awk -v a="$(tree_cpu "$pid")" -v b="$idle_start" -v s="$IDLE_SECONDS" 'BEGIN { printf "%.1f", (a - b) / s * 100 }')
for p in $(descendant_pids "$pid"); do
kb=$(footprint_kb "$p") || continue
total=$((total + kb))