mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
The slowest user-felt path is typing into the composer while the assistant is streaming. Profile (scripts/profile-under-stream.mjs): FadeText measureOverflow self time: 35.8 ms → 18.1 ms (-50%) total active CPU during 7s window: ~150 ms → ~50 ms Two changes in src/components/ui/fade-text.tsx: 1. Drop the `useEffect([children])` that re-ran `measureOverflow` (reads scrollWidth + clientWidth — forced layout) on every parent re-render. `useResizeObserver` already fires the same callback on mount and whenever the host span's box size changes; that covers the only case where overflow state can legitimately change. The previous explicit useEffect was a forced-layout flush on every parent render, which during streaming meant every token tick. 2. Wrap the component in `memo` with a custom comparator that short-circuits the entire render when scalar string `children` and the className/fadeWidth/style props are unchanged. The hot path was tool-fallback's title chips being re-rendered by parent streaming updates even though their text was stable; memo+ comparator skips that. Also adds two harness scripts under apps/desktop/scripts/: - latency-under-stream.mjs (key→paint latency while a turn streams) - profile-under-stream.mjs (CPU profile while a turn streams) Updates profile-typing-lag.md with the streaming numbers and confirms the Enter→paint submit path is already fast (≤320ms on the populated session; the 2s "stall after Enter" the user noticed once was a one-time cold-start, not reproducible at the UI layer). I'd guess the felt jank in real use is fast-burst typing during a long-form streaming reply (code blocks + markdown lists multiply the per-token render cost). The CPU savings here scale linearly with token volume. |
||
|---|---|---|
| .. | ||
| assert-root-install.cjs | ||
| before-build.cjs | ||
| click-session.mjs | ||
| dev-no-hmr.mjs | ||
| diag-submit.mjs | ||
| dump-state.mjs | ||
| latency-under-stream.mjs | ||
| leak-typing.mjs | ||
| measure-latency.mjs | ||
| measure-submit.mjs | ||
| notarize-artifact.cjs | ||
| notarize.cjs | ||
| probe-renderer.mjs | ||
| profile-typing-lag.md | ||
| profile-typing.mjs | ||
| profile-under-stream.mjs | ||
| reload-renderer.mjs | ||
| stage-native-deps.cjs | ||
| test-desktop.mjs | ||
| write-build-stamp.cjs | ||