Optimize startup latency: dependency caching, parallel init, and optional browser daemon #729
DrEden33773
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
Reduce VHS startup delay. Currently, every
vhs <tape>invocation goes through a fully serial pipeline — dependency checks, ttyd startup, Chromium cold-start, page navigation — before any recording begins. On most systems this adds 2–6 seconds of idle wait time.I've analyzed the bottlenecks and built an implementation across three incremental optimizations, each backward-compatible:
ttyd --versionevery time. Results are now cached to disk with a 1h TTL.vhs daemon) — optionally keep a headless Chromium running in the background. When available, VHS reuses it instead of cold-starting a new browser, eliminating the single largest bottleneck.Root cause analysis
The startup call chain is fully serial:
The dominant cost is Chromium cold-start (1–5s), followed by the serial ordering of ttyd and browser init, and redundant dependency checks on every run.
Proposed solution
Phase 1 & 2: transparent optimizations (no user-facing changes)
go-app-pathsDataPath (JSON, 1h TTL)sync.WaitGroupfor concurrent ttyd + Chromium launchPhase 3:
vhs daemonsubcommand (new feature)When no daemon is running, VHS falls back to the existing behavior (now with Phase 1+2 optimizations).
Cross-platform service registration uses kardianos/service (new dependency).
Implementation
A working implementation is available on my fork: DrEden33773/vhs@feat/optimize-startup-latency
Key files:
vhs daemonsubcommands +kardianos/serviceintegrationAll existing tests pass (
go test ./...), lint is clean (golangci-lint).Related
Beta Was this translation helpful? Give feedback.
All reactions