@@ -109,22 +109,58 @@ jobs:
109109 fi
110110 shell : bash
111111
112- # [DIAG] arm64-only experiment to characterise the slow/variable Electron app-ready time and
113- # whether disabling the (failing) GPU init cuts & stabilises it. Runs regardless of the gating
114- # smoke test above (if: always()) and never fails the build (continue-on-error). Each iteration
115- # emits the full [DIAG][T+...] timeline incl. app-ready uptime. Remove with the rest of the diags.
116- - name : " [DIAG] arm64 startup-timing A/B (baseline vs --disable-gpu)"
117- if : ${{ always() && matrix.platform == 'linux' && matrix.arch == 'arm64' }}
112+ # [DIAG] Cold-start breakdown: figure out *where* the slow first-launch time goes (Electron
113+ # app-ready is ~14-20s cold vs ~0.7s warm). We deterministically reconstruct cold state with
114+ # drop_caches + cache resets and isolate each suspected cost. Runs on both linux arches so we
115+ # can also compare arm64 vs x64. Diagnostic only: always runs, never fails the build.
116+ # Read the "[DIAG][T+... uptime=Xs] app ready" line emitted by each launch to compare conditions.
117+ - name : " [DIAG] cold-start breakdown (fontconfig vs cold-reads vs first-run)"
118+ if : ${{ always() && matrix.platform == 'linux' }}
118119 continue-on-error : true
119120 run : |
120- for i in 1 2 3; do
121- echo "===================== BASELINE run $i ====================="
122- xvfb-run --auto-servernum npm test || true
123- done
124- for i in 1 2 3; do
125- echo "================== DISABLE_GPU run $i ====================="
126- HTK_DIAG_DISABLE_GPU=true xvfb-run --auto-servernum npm test || true
127- done
121+ set +e
122+ ELECTRON_DIR="$PWD/node_modules/electron/dist"
123+ USERDATA="$HOME/.config/HTTP Toolkit"
124+
125+ now_ms() { date +%s%3N; }
126+ timed() { local s; s=$(now_ms); "$@"; local e; e=$(now_ms); echo " -> $((e - s)) ms wall"; }
127+ drop_caches() { sync; sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' 2>/dev/null && echo "[page cache dropped]" || echo "[drop_caches FAILED - no sudo?]"; }
128+ clear_fonts() { rm -rf "$HOME/.cache/fontconfig" 2>/dev/null; sudo rm -rf /var/cache/fontconfig/* 2>/dev/null; }
129+ clear_userdata() { rm -rf "$USERDATA" 2>/dev/null; }
130+ warm_electron() { find "$ELECTRON_DIR" -type f -print0 2>/dev/null | xargs -0 cat > /dev/null 2>&1; }
131+ # Capture the full electron timeline ([DIAG][T+...]) + test markers ([DIAG][test...]),
132+ # but drop the noisy renderer/CSP console spam. In cold runs 'app ready' is emitted before
133+ # Playwright attaches its stdout handler, so grabbing the whole T+ timeline is more reliable.
134+ launch() { xvfb-run --auto-servernum npx playwright test 2>&1 | grep -E "\[DIAG\]\[T\+|\[DIAG\]\[test" || true; }
135+
136+ echo "##################### HARDWARE / FILESYSTEM #####################"
137+ uname -a; echo "nproc: $(nproc)"; free -h
138+ grep -m1 -iE 'model name|CPU implementer|Features' /proc/cpuinfo
139+ echo "--- workspace mount ---"; findmnt -T "$PWD" 2>/dev/null || df -h "$PWD"
140+ echo "--- sizes ---"; du -sh "$ELECTRON_DIR" 2>/dev/null; du -sh "$PWD/node_modules" 2>/dev/null
141+
142+ echo "##################### RAW DISK READ of electron/dist #####################"
143+ drop_caches
144+ echo "cold read of electron/dist:"; timed warm_electron
145+ echo "warm read of electron/dist:"; timed warm_electron
146+
147+ echo "##################### FONTCONFIG BUILD COST #####################"
148+ clear_fonts
149+ echo "fc-cache -f (cold build):"; timed fc-cache -f
150+ echo "fc-cache -f (already built):"; timed fc-cache -f
151+
152+ echo "##################### ELECTRON app-ready BREAKDOWN #####################"
153+ echo "Compare the 'uptime=Xs' at app-ready across conditions:"
154+ echo "===== A: FULLY COLD (fonts cleared, userdata cleared, page cache dropped) ====="
155+ clear_fonts; clear_userdata; drop_caches; launch
156+ echo "===== B: fontconfig PRE-BUILT, else cold (A minus B = fontconfig BUILD cost) ====="
157+ clear_fonts; fc-cache -f >/dev/null 2>&1; clear_userdata; drop_caches; launch
158+ echo "===== C: electron PRE-READ (page warm), fonts cleared (A minus C = COLD-READ cost) ====="
159+ clear_fonts; clear_userdata; warm_electron; launch
160+ echo "===== E: fonts+page WARM, userdata cleared (E minus D = Chromium FIRST-RUN cost) ====="
161+ clear_userdata; warm_electron; launch
162+ echo "===== D: FULLY WARM (everything cached) ====="
163+ launch
128164 shell : bash
129165
130166 - uses : actions/upload-artifact@v6
0 commit comments