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 💪
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.