Open
Conversation
Skip upfront API status checks — just fire SSH immediately with a 5s connect timeout. If SSH succeeds (especially via a reused multiplexed connection), return instantly. If it fails, then check instance status and give helpful error messages suggesting brev ls. Add ControlMaster/ControlPath/ControlPersist to all SSH config templates so subsequent connections reuse the master socket (~0.6s vs ~3s). Suppress noisy SSH output (Agent pid, PTY warnings, known hosts warnings).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
brev execnow runs SSH immediately with a 5s connect timeout instead of making API calls to check instance status first. If SSH succeeds (especially via multiplexed connection), returns instantly with zero API overhead.ControlMaster auto/ControlPath/ControlPersist 10mto all SSH config templates. First connection ~3s, subsequent connections ~0.6s (5x speedup).brev ls.What changed
Before
Every
brev execcall would:brev refreshto sync SSH configEven if the instance was already running and SSH was ready, every single exec paid the cost of multiple API round-trips before doing anything.
After
With SSH multiplexing enabled, the first connection to an instance takes ~3s (normal SSH handshake). Every subsequent
brev execwithin 10 minutes reuses the master connection and completes in ~0.6s.SSH multiplexing
Added to all three SSH config templates (
ssh.go,sshconfigurer.goV2 and V3):ControlMaster auto— reuse an existing master connection if available, otherwise create oneControlPath— socket file stored per user/host/port comboControlPersist 10m— master stays alive 10 minutes after last session disconnectsSuppressed noisy output
eval $(ssh-agent -s) > /dev/null— hides "Agent pid 12345"ssh -T— disables PTY allocation, hides "Pseudo-terminal will not be allocated because stdin is not a terminal"-o LogLevel=ERROR— hides "Warning: Permanently added '1.2.3.4' (ED25519) to the list of known hosts"Benchmark
Test plan
brev exec <running-instance> "echo ok"— should succeed immediatelybrev exec <stopped-instance> "echo ok"— should fail fast (5s), then start instance and retrybrev exec <nonexistent-instance> "echo ok"— should fail with helpful message