hermes-agent/apps/desktop/scripts
Brooklyn Nicholson 7003df708c perf(desktop): floor assistant-text flush gap to 33ms for predictable batching
`scheduleDeltaFlush` previously coalesced via `requestAnimationFrame`
only. The "at most one flush per frame" guarantee that gives you is fine
for fast streams (>~80 tok/sec) where multiple tokens arrive within a
single frame, but breaks down at typical LLM token rates (30-80 tok/sec)
where each token arrives slower than the rAF cadence and triggers its
own React commit + Streamdown markdown re-parse.

Track `lastFlushAt` and require at least 33 ms between two flushes.
React 18+ auto-batching probabilistically already collapsed some of
these, but the floor makes it deterministic.

A/B on the 34 MB session, 300 tokens at 50 tok/sec (markdown chunks):

| | avgFps | p99 frame | LTs / 5 s | max LT |
|---|---|---|---|---|
| no floor (current rAF) | 54.0 | 38 ms | 2.0 | 145 ms |
| 33 ms floor (this PR) | 54.3 | 41 ms | 1.7 | 110 ms |

`inter-mutation` p50 also tightens from 22-28 ms to a clean 33 ms,
which is the expected signature of a deterministic floor. Doesn't fully
solve the user's perceived hitches — Streamdown's per-Block parse cost
when the last block grows past ~2 k chars is still the elephant — but
it consistently shaves the worst-case longtask and makes the streaming
cadence visibly steadier.

Also threads a matching `flushMinMs` option through the synthetic
stream driver in `perf-probe.tsx` + `scripts/measure-synthetic-stream.mjs`
so the harness can A/B both regimes without spending LLM credits.

See `scripts/profile-typing-lag.md` for the full investigation.
2026-05-21 20:08:49 -05:00
..
assert-root-install.cjs Improve desktop runtime UX by surfacing inference readiness in gateway status and hardening WSL link opening. 2026-05-15 16:33:04 -05:00
before-build.cjs feat(desktop): thin installer + first-launch install.ps1 bootstrap 2026-05-18 02:26:46 -04:00
click-session.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
dev-no-hmr.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
diag-jump.mjs perf(desktop): fix "Enter jumps up" on long threads 2026-05-21 17:45:55 -05:00
eval.mjs chore(desktop): synthetic-stream perf harness + scripts 2026-05-21 19:38:26 -05:00
leak-typing.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
measure-jump.mjs perf(desktop): fix "Enter jumps up" on long threads 2026-05-21 17:45:55 -05:00
measure-latency.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
measure-real-stream.mjs chore(desktop): synthetic-stream perf harness + scripts 2026-05-21 19:38:26 -05:00
measure-submit.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
measure-synthetic-stream.mjs perf(desktop): floor assistant-text flush gap to 33ms for predictable batching 2026-05-21 20:08:49 -05:00
notarize-artifact.cjs fix(desktop): address CodeQL alerts on PR #20059 2026-05-11 16:52:32 -04:00
notarize.cjs ci(desktop): automate desktop releases 2026-05-05 13:04:33 -05:00
probe-renderer.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
probe-thread.mjs perf(desktop): fix "Enter jumps up" on long threads 2026-05-21 17:45:55 -05:00
profile-long-stream.mjs perf(desktop): rate-limit thread auto-pin during streaming 2026-05-21 18:02:26 -05:00
profile-real-stream.mjs chore(desktop): synthetic-stream perf harness + scripts 2026-05-21 19:38:26 -05:00
profile-synth-stream.mjs chore(desktop): synthetic-stream perf harness + scripts 2026-05-21 19:38:26 -05:00
profile-typing-lag.md perf(desktop): floor assistant-text flush gap to 33ms for predictable batching 2026-05-21 20:08:49 -05:00
profile-typing.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
reload-renderer.mjs Revert "Revert "perf(desktop): cut per-keystroke layout + listener churn in chat composer"" 2026-05-21 18:57:18 -05:00
reload.mjs chore(desktop): synthetic-stream perf harness + scripts 2026-05-21 19:38:26 -05:00
stage-native-deps.cjs desktop: swap node-pty fork for upstream microsoft/node-pty 1.1.0 2026-05-18 21:50:53 -07:00
test-desktop.mjs desktop: swap node-pty fork for upstream microsoft/node-pty 1.1.0 2026-05-18 21:50:53 -07:00
write-build-stamp.cjs feat(desktop): thin installer + first-launch install.ps1 bootstrap 2026-05-18 02:26:46 -04:00