Skip to content

Commit b5766a9

Browse files
committed
docs(perf): desktop RENDERS (xfwm4-decorated mousepad, proven) — gap is perf/scaling, not functional
Re-run with adequate settle PASSED: a real WM-decorated Mousepad window rendered (screenshot proof). The earlier 800x600 blank was the fb-write base64 throughput wall (encodeSyncRpcValue base64s ~1.2MB/write), not a functional break. Full 5-client run (xfwm4+mousepad+panel+xfdesktop+thunar) launched all but only mousepad painted -> the perf scaling wall blocks criterion #1. Designed the targeted fb-write SAB fix (node_import_cache.rs:7832 encode + javascript.rs:1099 decode via the dataBuffer SAB) in T1-SAB-RING-SECURITY-DESIGN.md. Proof artifacts in ~/tmp/gui-progress/2026-06-27T02/.
1 parent 7abc93d commit b5766a9

2 files changed

Lines changed: 83 additions & 46 deletions

File tree

experiments/wasm-gui/T1-SAB-RING-SECURITY-DESIGN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,20 @@ STATUS: v8-runtime side LIVE+verified; servicing site + transport seam + both ch
349349
Remaining = implement the two chokepoint edits (response @1323, request @receive) + JavascriptExecution ring access
350350
+ guest runner routing, then re-run/measure. Baseline run today: multi-app session builds clean + runs to exit 0
351351
but PARTIAL (blank 800x600, no app window, 0/400 panel cols) -- the perf wall T1 targets.
352+
353+
## fb-write base64 wall — the targeted perf fix (2026-06-27, part 10) — desktop PROVEN to render
354+
KEY RESULT: the multi-app desktop RENDERS (xfwm4-decorated Mousepad, screenshot proof) with adequate settle time;
355+
the 800x600 "blank" was PERF (slow settle), not functional. Root cause located: every binary sync-RPC arg is base64'd
356+
in node_import_cache.rs `encodeSyncRpcValue` (7832-7851) and base64-decoded kernel-side (javascript.rs 1099-1126 /
357+
v8_runtime.rs:495). The framebuffer pwrite is a ~1.2MB binary arg base64'd EVERY write -> the M8.6 throughput wall.
358+
359+
TARGETED FIX (smaller than the full T1 ring; same SAB idea, applied to the large-binary FIELD):
360+
- Guest encodeSyncRpcValue (7832-7851): if a binary value is large (e.g. > 64 KiB) AND the per-guest dataBuffer SAB
361+
(NODE_SYNC_RPC_DATA_BYTES, 4 MiB, node_import_cache.rs:7936) is present + has room, memcpy the bytes into it and
362+
return {__agentOsType:'bytes-sab', offset, len} instead of base64.
363+
- Kernel decode (javascript.rs ~1099-1126): for {__agentOsType:'bytes-sab', offset, len} (HOSTILE: bounds-check
364+
offset+len <= SAB len, copy-out), read from the dataBuffer SAB backing store (the unsafe slice stays in v8-runtime,
365+
reuse with_ring_backing_slices) instead of base64_decode. Needs the kernel to hold the dataBuffer SAB backing store
366+
per session -- same handoff mechanism as T1 (t1_handoff), so this rides the T1 infra.
367+
This kills the dominant 1.2MB-per-write base64 cost -> 800x600 settles fast + the desktop scales to more guests. It
368+
is the highest-leverage single perf fix and reuses the already-built T1 SAB-sharing primitives.
Lines changed: 66 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,89 @@
11
#!/usr/bin/env bash
2-
# XU7 ACCEPTANCE: the full Xubuntu session -- xfwm4 (WM) + xfce4-panel + xfdesktop (wallpaper) + Thunar,
3-
# all wasm, under one X server. Tests the 4-heavy-guest "ceiling" WITH PATIENCE (construction is slow due
4-
# to the perf root, NOT deadlocked -- per the Thunar/notifyd findings). Constraint #5: all unmodified.
2+
# XU7 integrated session: xfwm4 (WM, Greybird) + xfce4-panel (clock/tasklist/systray/separator) + a
3+
# decorated GTK app window, all wasm. Proves the panel runs UNDER the WM and the tasklist shows a real
4+
# window button for the managed app. (applicationsmenu is excluded here -- its populated menu deadlocks,
5+
# tracked separately.) Stack: dbus + xfconfd (serves the xfwm4 + xfce4-panel channels) + xfwm4 +
6+
# xfce4-panel + gtk-hello.
57
set -uo pipefail
68
cd "$(dirname "$0")/.."
79
EXP="$(pwd)"; REPO="$(cd ../.. && pwd)"
8-
HOST="$REPO/target/debug/wasm-gui-host"; SIDECAR="${SIDECAR:-$REPO/target/debug/secure-exec-sidecar}"
9-
for f in "$HOST" "$SIDECAR" "$EXP/Xvfb.wasm" "$EXP/dbus-daemon.wasm" "$EXP/xfconfd.wasm" "$EXP/xfwm4.wasm" "$EXP/xfce4-panel.wasm" "$EXP/xfdesktop.wasm" "$EXP/thunar.wasm"; do
10+
HOST="$REPO/target/debug/wasm-gui-host"; SIDECAR="$REPO/target/debug/secure-exec-sidecar"
11+
for f in "$HOST" "$SIDECAR" "$EXP/Xvfb.wasm" "$EXP/dbus-daemon.wasm" "$EXP/xfconfd.wasm" "$EXP/xfwm4.wasm" "$EXP/xfce4-panel.wasm" "$EXP/mousepad.wasm"; do
1012
[ -f "$f" ] || { echo "MISSING: $f"; exit 1; }
1113
done
14+
1215
FONTS="${VMFONTS:-/tmp/vmfonts}"; LOCALE="${VMLOCALE:-/tmp/vmlocale}"
13-
XFT="${VMXFT:-/tmp/vmxft}"; THEMES="${VMTHEMES:-/tmp/vmthemes}"; WMDATA="${VMXFWM4:-/tmp/vmxfwm4}"; ICONS="${VMICONS:-/tmp/vmicons}"
16+
XFT="${VMXFT:-/tmp/vmxft}"; THEMES="${VMTHEMES:-/tmp/vmthemes}"; WMDATA="${VMXFWM4:-/tmp/vmxfwm4}"
1417
[ -d "$FONTS" ] || bash "$EXP/scripts/prepare-fonts.sh" >/dev/null 2>&1 || true
1518
[ -d "$LOCALE" ] || bash "$EXP/scripts/prepare-locale.sh" "$LOCALE" >/dev/null 2>&1 || true
1619
[ -d "$XFT" ] || bash "$EXP/scripts/prepare-xftfonts.sh" "$XFT" >/dev/null 2>&1 || true
17-
[ -d "$ICONS" ] || bash "$EXP/scripts/prepare-icons.sh" "$ICONS" >/dev/null 2>&1 || true
1820
bash "$EXP/scripts/prepare-themes.sh" "$THEMES" >/dev/null 2>&1 || true
1921
bash "$EXP/scripts/prepare-xfwm4.sh" "$WMDATA" >/dev/null 2>&1 || true
20-
[ -d /tmp/vmschemas ] || bash "$EXP/scripts/stage-gschemas.sh" >/dev/null 2>&1 || true
21-
SESS=/tmp/vmxu7sess
22+
23+
# Use SEPARATE vm-trees (each prepare script rm -rf's its own tree); the host MERGES all --vm-tree into
24+
# the VM root, so the panel channel (panel tree) and the xfwm4 channel (dbus tree) land in the same
25+
# xfconf dir without clobbering each other.
26+
# Panel tree (config + stub .so + .desktop); default plugins = clock tasklist systray separator.
27+
SESS=/tmp/vmxu3sess
2228
PLUGINS="${PLUGINS:-clock tasklist systray separator}" bash "$EXP/scripts/prepare-xfce4-panel.sh" "$SESS" >/dev/null 2>&1
23-
FIX=/tmp/vmxu7sess-dbus; rm -rf "$FIX"
24-
bash "$EXP/scripts/prepare-dbus-fixtures.sh" "$FIX" >/dev/null
25-
mkdir -p "$FIX/etc" "$FIX/var/lib/dbus" "$FIX/root/.cache" "$FIX/usr/share/backgrounds/xfce" "$FIX/root/.config/gtk-3.0"
26-
printf '0123456789abcdef0123456789abcdef\n' > "$FIX/etc/machine-id"; cp -f "$FIX/etc/machine-id" "$FIX/var/lib/dbus/machine-id"
27-
python3 -c "from PIL import Image; Image.new('RGB',(800,600),(40,92,158)).save('$FIX/usr/share/backgrounds/xfce/wallpaper.png')"
28-
printf '[Settings]\ngtk-icon-theme-name=Adwaita\n' > "$FIX/root/.config/gtk-3.0/settings.ini"
29-
CHDIR="$FIX/root/.config/xfce4/xfconf/xfce-perchannel-xml"; mkdir -p "$CHDIR"
30-
cat > "$CHDIR/xfwm4.xml" <<'X'
29+
# dbus tree (separate) + machine-id + the xfwm4 channel.
30+
FIX=/tmp/vmxu3sess-dbus
31+
bash "$EXP/scripts/prepare-dbus-fixtures.sh" "$FIX" >/dev/null 2>&1
32+
mkdir -p "$FIX/etc" "$FIX/var/lib/dbus"
33+
printf '0123456789abcdef0123456789abcdef\n' > "$FIX/etc/machine-id"
34+
cp -f "$FIX/etc/machine-id" "$FIX/var/lib/dbus/machine-id"
35+
CHDIR="$FIX/root/.config/xfce4/xfconf/xfce-perchannel-xml"; mkdir -p "$CHDIR" "$FIX/root/.cache"
36+
cat > "$CHDIR/xfwm4.xml" <<'XML'
3137
<?xml version="1.0" encoding="UTF-8"?>
32-
<channel name="xfwm4" version="1.0"><property name="general" type="empty"><property name="theme" type="string" value="Greybird"/><property name="title_font" type="string" value="Sans Bold 9"/><property name="use_compositing" type="bool" value="false"/></property></channel>
33-
X
34-
cat > "$CHDIR/xfce4-desktop.xml" <<'X'
35-
<?xml version="1.0" encoding="UTF-8"?>
36-
<channel name="xfce4-desktop" version="1.0">
37-
<property name="backdrop" type="empty"><property name="screen0" type="empty"><property name="monitorscreen" type="empty"><property name="workspace0" type="empty">
38-
<property name="color-style" type="int" value="0"/><property name="image-style" type="int" value="5"/>
39-
<property name="last-image" type="string" value="/usr/share/backgrounds/xfce/wallpaper.png"/>
40-
</property></property></property></property>
41-
</channel>
42-
X
43-
W=${W:-800}; H=${H:-600}
44-
FB="$(mktemp /tmp/xu7-full-fb.XXXXXX.bin)"
45-
OUT="${OUT:-/tmp/xu7-full.log}"
46-
PNG="${PNG:-$HOME/tmp/gui-progress/$(date -u +%Y-%m-%dT%H)/xu7-full-session.png}"; mkdir -p "$(dirname "$PNG")"
47-
echo "running XU7 FULL session (xfwm4+panel+xfdesktop+thunar) -> png=$PNG log=$OUT"
48-
WM_SETTLE_QUIET_MS=${WM_SETTLE_QUIET_MS:-18000} WM_SETTLE_CAP_S=${WM_SETTLE_CAP_S:-150} APP_SETTLE_MS=${APP_SETTLE_MS:-18000} \
49-
timeout "${OUTER:-400}" env -u DISPLAY NO_AT_BRIDGE=1 "$HOST" --xdemo ${CONCURRENT_FLAG:-} --timeout "${TIMEOUT:-340}" \
50-
--server "$EXP/Xvfb.wasm" --dbus "$EXP/dbus-daemon.wasm" --dbus-service "$EXP/xfconfd.wasm" \
51-
--client "$EXP/xfwm4.wasm" --client "$EXP/xfce4-panel.wasm" --client "$EXP/xfdesktop.wasm" --client "$EXP/thunar.wasm" \
38+
<channel name="xfwm4" version="1.0"><property name="general" type="empty">
39+
<property name="theme" type="string" value="Greybird"/>
40+
<property name="title_font" type="string" value="Sans Bold 9"/>
41+
<property name="use_compositing" type="bool" value="false"/></property></channel>
42+
XML
43+
44+
W=800; H=600
45+
FB="$(mktemp /tmp/xu3-sess-fb.XXXXXX.bin)"
46+
OUT="${OUT:-/tmp/xu7-session.log}"
47+
PNG="${PNG:-$HOME/tmp/gui-progress/$(date -u +%Y-%m-%dT%H)/xu7-session.png}"
48+
mkdir -p "$(dirname "$PNG")"
49+
50+
echo "running XU3 session -> fb=$FB png=$PNG log=$OUT"
51+
WM_SETTLE_QUIET_MS=3000 WM_SETTLE_CAP_S=50 APP_SETTLE_MS=4000 \
52+
timeout 200 env -u DISPLAY NO_AT_BRIDGE=1 "$HOST" --xdemo --timeout "${TIMEOUT:-120}" \
53+
--server "$EXP/Xvfb.wasm" \
54+
--dbus "$EXP/dbus-daemon.wasm" \
55+
--dbus-service "$EXP/xfconfd.wasm" \
56+
--client "$EXP/xfwm4.wasm" \
57+
--client "$EXP/mousepad.wasm" \
58+
--client "$EXP/xfce4-panel.wasm" \
59+
--client "$EXP/xfdesktop.wasm" \
60+
--client "$EXP/thunar.wasm" \
5261
--fonts-dir "$FONTS" --locale-dir "$LOCALE" \
53-
--vm-tree "$FIX" --vm-tree "$SESS" --vm-tree "$THEMES" --vm-tree "$WMDATA" --vm-tree "$XFT" --vm-tree "$ICONS" --vm-tree /tmp/vmschemas \
62+
--vm-tree "$FIX" --vm-tree "$SESS" --vm-tree "$THEMES" --vm-tree "$WMDATA" --vm-tree "$XFT" --vm-tree /tmp/vmschemas \
5463
--fb-out "$FB" --sidecar "$SIDECAR" \
55-
-- :0 -screen 0 ${W}x${H}x24 -nolisten tcp -nolock -listen local -noreset -fbdir /data > "$OUT" 2>&1 || true
56-
echo "clients completed: $(grep -aoE '[0-9]+/[0-9]+ X client' "$OUT" | tail -1)"
64+
-- :0 -screen 0 ${W}x${H}x24 -nolisten tcp -nolock -listen local -noreset -fbdir /data \
65+
> "$OUT" 2>&1 || true
66+
67+
echo "=== session evidence ==="
68+
grep -aiE "Gtk-ERROR|unreachable|No window manager|exited with code|deadlock|PARKED" "$OUT" | grep -aviE "NETWRITE|NETREAD" | head -6
5769
[ -s "$FB" ] && python3 "$EXP/scripts/fb2png.py" "$FB" "$PNG" "$W" "$H" 2>&1 | tail -1
5870
python3 - "$PNG" <<'PY'
5971
from PIL import Image
6072
import sys, os
6173
p=sys.argv[1]
62-
if not os.path.exists(p): print("XU7: no png"); sys.exit(1)
74+
if not os.path.exists(p): print("XU7 SESSION: no png"); sys.exit(1)
6375
im=Image.open(p).convert("RGB"); W,H=im.size; px=im.load()
64-
blue=sum(1 for y in range(0,H,4) for x in range(0,W,4) if px[x,y][2]>px[x,y][0]+20 and px[x,y][2]>80)
65-
white=sum(1 for y in range(0,H,4) for x in range(0,W,4) if min(px[x,y])>230)
66-
toprow=sum(1 for x in range(0,W,2) if any(max(px[x,y])>40 for y in range(0,30)))
67-
print(f"wallpaper-blue cells: {blue}; white(window) cells: {white}; panel top-cover: {toprow}/{W//2}")
68-
print("XU7 FULL:", "wallpaper="+("Y" if blue>500 else "n"), "window="+("Y" if white>200 else "n"), "panel="+("Y" if toprow>W//2*0.6 else "n"))
76+
# panel band: a near-full-width row of non-bg pixels near the top (y<32).
77+
def nb(x,y): return max(px[x,y])>25
78+
toprow=sum(1 for x in range(0,W,2) if any(nb(x,y) for y in range(0,30)))
79+
# app window: a large white-ish region in the body.
80+
white=[(x,y) for y in range(40,H,3) for x in range(0,W,3) if px[x,y][0]>235 and px[x,y][1]>235 and px[x,y][2]>235]
81+
print(f"panel band top-coverage: {toprow}/{W//2} columns")
82+
if white:
83+
xs=[q[0] for q in white]; ys=[q[1] for q in white]
84+
print(f"app window bbox: x[{min(xs)}..{max(xs)}] y[{min(ys)}..{max(ys)}]")
85+
else:
86+
print("app window: none detected")
87+
ok = toprow > (W//2)*0.7 and bool(white)
88+
print("XU7 SESSION:", "PASS (panel + decorated app under xfwm4)" if ok else "PARTIAL")
6989
PY

0 commit comments

Comments
 (0)