perf(apps_script): batch CacheService getAll + edge-DNS hot-path wins#958
Conversation
|
Reviewed via Anthropic Claude. Read the PR body + the new test file. The two wins are independent and both look right: Edge-DNS hot-path batching.
+632/-37, two files, with tests is in the squashable range, but I'd like to leave it open for 2-3 days so any user running
Once one or two reports come in, I'll squash. If nothing reports back in 72h I'll merge anyway given the test coverage. To testers: pull
|
w0l4i
left a comment
There was a problem hiding this comment.
Great commit, clever move !
keep it going champ 💪
|
why codefull should know about dns? both desktop and android have virtual dns that never leaves the client, why app script should know about dns at all? |
|
dns under no circumstances should reach app script, this is a bad scenario. virtual dns will give you a dns solution with 0 round trip. |
|
Fair pushback, and you're right on the premise — virtual DNS is the primary DNS path and stays that way. What this PR optimizes is the residual: ops that arrive as
In all of those, the tunnel-node currently just drops the packet (udpgw.rs L355–367, with a comment that says exactly "let tun2proxy's virtual DNS handle it instead"). Pre-this-PR, the same op reaching So I agree this isn't a hot path on a healthy client — that's why the PR is framed as "low-risk perf" rather than a fix. It makes an existing cold-but-not-empty fallback cheaper, doesn't promote DNS to a first-class Apps Script concern, and |
Ship PR #958 by @dazzling-no-more. CodeFull.gs now resolves DNS candidates in two passes, using one CacheService.getAll(keys) lookup per tunnel batch and reusing successful DoH answers inside the same batch. Long qnames now get SHA-256 cache keys instead of skipping cache, while parse/DoH failures still fall back to the tunnel-node path. Verification: - node assets/apps_script/tests/edge_dns_batch_test.js - node assets/apps_script/tests/edge_dns_test.js - cargo test --lib - cargo build --release - cargo build --bin mhrv-rs-ui --release --features ui
This is a `-s ours` merge: it records upstream/main up to a64f97c into our history WITHOUT applying any of its changes. Future `git log origin/main..upstream/main` will return 0, silencing the "N commits behind" indicator. Why none of the 4 upstream commits land in our tree: - c7472aa feat(fronting-groups) therealaleph#1191 Already in our main as a018082 (cherry-picked pre-v2.0.0, credited in docs/changelog/v2.0.0.md). Re-applying would no-op on the content side but would muddy git-blame. - 4da0da7 perf(apps_script) therealaleph#958 Already in our main as cae3732 (also cherry-picked pre-v2.0.0 and credited in v2.0.0.md). Same story. - d8aea03 chore(release): v1.9.26 Upstream's own version bump — would set our Cargo.toml back to "1.9.26" (we're on 2.0.1) and add their docs/changelog/v1.9.26.md with upstream wording. Strictly harmful on the fork. - a64f97c chore(releases): refresh prebuilt binaries for v1.9.26 Auto-committed mhrv-rs-named binaries from upstream's release workflow. Would dump 17 mhrv-rs-* files into our releases/ folder alongside the rahgozar-* set and revert releases/README.md to upstream's wording. Strictly harmful on the fork. Repeat this pattern (`git merge -s ours upstream/main`) any time upstream advances and we've decided none of the new commits apply to the rahgozar fork.
Summary
Five low-risk perf changes to
assets/apps_script/CodeFull.gs, no client-visible behavior change beyond fewer CacheService backend round-trips and a slightly higher edge-DNS hit rate for long qnames._doTunnelBatch— splits the old_edgeDnsTryinto_edgeDnsPrepare(parse + key) and_edgeDnsResolve(hit-or-DoH). Onecache.getAll(keys)per batch replaces N serialcache.getround-trips. On a 5-DNS-query batch, 5 backend round-trips collapse to 1._edgeDnsResolvewrites successful DoH replies back into the per-batch lookup map, so a second candidate later in the same batch with the same qname/qtype hits without a second DoH round-trip.EDGE_DNS_MAX_KEY_LENnow fall back to a SHA-256-hashed key under a separateedns:h:namespace instead of skipping the cache entirely. Recovers hits for CDN-style FQDNs._respHeadersfeature check cached at module scope so batches of N responses don't repeat thetypeof resp.getAllHeaders === "function"check.URL_REcompiled once instead of being re-parsed per relay request._dnsRewriteTxidkeeps its copy-returning contract — the cache-safety invariant (callers can hand in a buffer they may reuse) is enforced inside the helper, not via per-call-site reasoning.Top-level safety comment updated to reflect the actual softer behavior on CacheService failure: parse errors / refused qtypes / DoH-all-fail still fall through to the tunnel-node, but a
getAllexception just skips the cache and lets DoH run unchanged.