feat: negative-cache unreachable destinations and grow startup pre-warm#280
Merged
therealaleph merged 1 commit intotherealaleph:mainfrom Apr 26, 2026
Conversation
therealaleph
added a commit
that referenced
this pull request
Apr 26, 2026
#275: youtube_via_relay no longer routes video/image CDNs through Apps Script. The flag now correctly carves out only the API/HTML hosts where Restricted Mode is enforced; video chunks come direct from googlevideo.com (which was missing from the SNI rewrite list entirely — fixed). Long videos no longer hit Apps Script's 6-min execution cap, and single-chunk timeouts no longer abort playback. #280: TunnelMux now caches "destination unreachable" responses from the tunnel-node (Network is unreachable / No route to host) for 30 seconds, short-circuiting subsequent CONNECTs to that destination with 502 (HTTP) or 0x04 (SOCKS5). Saves ~5 batches/second on IPv6-only host probes. Startup pre-warm pool grew 12→24. 143/143 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Two small perf fixes driven by an Android log review.
1. Negative-cache unreachable destinations
On a device without IPv6, OS/app probes to IPv6-only hostnames (e.g.
ds6.probe.whatismyipaddress.com) fail withNetwork is unreachable (os error 101). The probe gets retried every ~1.5s, and each retry was burning a fresh tunnel batch round-trip on a guaranteed failure — 5+ wasted sessions per probe in the logs.TunnelMuxnow keeps a 30s, 256-entry negative cache keyed by(host, port). When the tunnel-node returnsNetwork is unreachable/No route to host, the destination is remembered. The proxy front-end short-circuits subsequent CONNECTs:502 Bad Gateway0x04 Host unreachableCache write rules (after review feedback):
TunnelResponse.e— the tunnel-node's own connect result. Outer transport errors (relay → Apps Script never reached the tunnel-node) are never cached, so a momentary client-side WAN blip doesn't poison destinations.Example.COM.:443andexample.com:443share an entry.2. Bigger startup pre-warm pool
warm(3)was sized for one deployment. With multi-deployment configs, requests 4–10 of the opening burst paid a fresh TLS handshake each (~300ms). Now scales with deployment count:warm(num_scripts().clamp(6, 16)).Test plan
cargo test --lib(143 passed)