Repository navigation
perf(client): skip reqwest's per-request retry copy; reuse the Authorization value - #470
Open
vuanhphung wants to merge 3 commits into
Open
vuanhphung wants to merge 3 commits into
vuanhphung wants to merge 3 commits into
Conversation
…ke; reuse the Authorization value reqwest's default retry layer clones each request (headers, URI, extensions, body) so it can replay HTTP/2 and HTTP/3 refusals. This client speaks HTTP/1.1 only and execute_impl does the kernel's retries, so the layer is turned off. The validated Authorization header value is reused while the provider returns the same string, and FederationProvider decides whether a token's issuer is foreign once per distinct token instead of decoding the JWT and parsing its issuer URL on every request. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 00:55 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Verdict: 1 Low · 1 Nit
Looks good: two low-severity notes. The reqwest retry-disable and the per-header caches are correct, keep re-checking the issuer when the token rotates, and keep the credential out of Debug.
Other findings
- ⚪ Nit —
get_or_buildtakes an exclusivestd::sync::Mutexon every authenticated request, including when the cache is hit, and holds it while comparing the full token string. The PR is aimed at 800-thread loads, so all of those requests now pass through one lock. The critical section is small, but anRwLockread lock for the hit path (the same patternFederationProvider::token_is_foreignuses), taking the write lock only on a miss, would remove the serialization the cache adds. Worth checking against the profile.
…:retry Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Inactive
vuanhphung
had a problem deploying
to
azure-prod
November 15, 2026 01:10 — with
GitHub Actions
Error
There was a problem hiding this comment.
Verdict: 1 Low
Looks good, with one low-severity contention concern. Disabling reqwest's built-in retry fits with the kernel doing its own retries in execute_impl, and caching the Authorization value and federation issuer decision by the exact header string correctly re-checks any new token. Both caches are redacted in Debug.
Requests that share a token now only take the read side, so concurrent requests don't serialize on the cache; the write lock is taken only when the provider returns a new header. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Inactive
vuanhphung
had a problem deploying
to
azure-prod
November 15, 2026 01:23 — with
GitHub Actions
Error
This was referenced Nov 18, 2026
This branch was previously deployed
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.
Problem
On a Real-Time warehouse each query is two HTTP requests (ExecuteStatement, then CloseStatement), so per-request client CPU counts twice. A profile of one Python process running
SELECT 1on 800 threads shows two avoidable costs on every request:execute_impl, so the copy is never used.Authorizationvalue is rebuilt per request: the provider's string is validated into a newHeaderValue, and with token federation (the wrapper around a PAT) the JWT is base64- and JSON-decoded and its issuer URL parsed to decide whether it needs exchange.Fix
The client sets
retry(never().max_retries_per_request(0)). The validatedAuthorizationvalue and the federation issuer decision are remembered for the exact header string, so an unchanged token reuses them and any new token is checked again. The cached value is marked sensitive andDebugnever prints it.Verification
cargo fmt,cargo clippy --all-targets -D warningsandcargo testpass; new testsauth_value_cache_reuses_the_value_until_the_header_changesandissuer_decision_follows_the_current_token.Python driver end to end,
SELECT 1back to back in one process, on the full factory stack (#453 #455 #456 #457 #458 #459 #461 #467 #468 #469) with and without this change. Mock: a TLS server replaying the live Real-Time response bytes and headers (execute 80 ms, close 60 ms), a JWT-shaped token, client on 6 cores, 3 interleaved runs, medians:Live, staging X-Large Real-Time warehouse, 8 client cores, one run each: an env-gated prototype of this change together with the close-path change in #472 (same code paths) cut client CPU per query at 1 process × 800 threads from 0.433 to 0.405 ms (-6.5%); steady QPS 7,651 → 7,961 and query p99 249 → 220 ms (that load is round-trip bound). Live, Medium Real-Time warehouse (server-bound at about 860 QPS), 1 × 200 threads, 60 s, 2 interleaved rounds, the exact commits of this PR, #472 and #471 together: 0.398 → 0.386 ms CPU per query, same QPS, same server-side error counts.
This pull request and its description were written by Isaac.