Repository navigation
perf(session): reuse idle HTTP connection pools across sessions - #488
vuanhphung wants to merge 10 commits into
Conversation
f043a8e to
d0f5034
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 1 Low
Looks good, with one low-severity changelog duplicate. The pool key covers every client config field (checked by an exhaustive destructure). The reqwest client has no cookies and no default headers, so auth and custom headers stay per-session. Lock ordering and shutdown/close handling look sound.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟡 Medium — The bindings inherit default-on reuse but do not expose its keep-alive-preserving opt-out, so Node/C callers cannot request fresh transport/trust state per session without disabling pooling or altering TLS configuration. Expose the boolean through the binding configuration surfaces and generated declarations, with mapping tests and retention documentation. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
|
On the binding suggestion in the review body: the approved scope explicitly says, “No binding needs to expose it in this PR.” |
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 1 Low
Looks good, with 2 low concerns. The pool key correctly separates transport settings from per-request ones (headers, org_id and auth are all applied per request). Leasing, expiry and shutdown are well covered by tests.
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good, with 1 low concern. The leasing, expiry, registry and shutdown paths look sound. The Weak transport fix in the reader factory and its release test are correct.
Other findings
- ⚪ Nit —
PoolKey::newdoes a blockingstd::fs::readand SHA-256 ofSSL_CERT_FILEon every pooledSession::open, on an async worker thread. The impact is small: it only runs whenSSL_CERT_FILEis set, bundles are usually a few hundred KB, and the client build already does blocking work. If it matters, cache the digest by path, mtime and length, or run it inspawn_blocking. (Found by Claude Opus 5.5 · confirmed by the judge)
|
The fingerprint nit repeats F2, already accepted and resolved at this head: #488 (comment). Content hashing preserves trust-byte identity; path/mtime/length can miss replacements. The existing synchronous TLS-build path remains a separate offload follow-up, with the cold-miss extra read recorded in the evidence. |
Keep authentication, retries and session state independent while sharing reqwest clients for matching host, transport configuration and runtime. Expire idle clients and bound retention across runtimes and configurations. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Preserve per-session idle-socket limits and request locality by returning clients only after their HTTP wrapper is dropped. Bound total client age, retain runtime shutdown safety, and isolate socket/configuration tests from connection-establishment races. Address adversarial review R1-1 through R1-9; declare Tokio 1.49 for runtime IDs and document bounded TLS/proxy retention. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Cover the Session::open wiring with eight sequential opens and request-used socket IDs, tolerating spare connects. Replacing for_session with new fails the test with exit 101. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Destructure HttpClientConfig exhaustively, requiring new settings to be classified before compilation succeeds. Test per-request settings independently; adding a future transport field fails with E0027 in TransportKey::from. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Sweep all expired entries on take and put, including rejected returns, and drop them after unlocking. Test a current-thread runtime that is never polled; removing either sweep fails the test. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Add HttpConfig::reuse_client_across_sessions, defaulting to true. False bypasses only the cross-session cache and preserves within-session keep-alive. Document idle/trust retention and test both behaviors, including two failing mutants. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Keep the original entry from #434 and remove this branch duplicate. Verified that exactly one transport-cycle entry remains and the reuse opt-out documentation is preserved. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Document the Rust-only opt-out and idle/trust retention in Node/Python release notes, the shared C ABI connection reference and ADBC configuration docs. Validate all five documents name the option and bounds; no runtime or binding API change. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Looks good, with 2 low concerns. The transport key covers every builder input, headers and compression stay per-request, and the lease and lock ordering look sound.
| impl PoolKey { | ||
| fn new(host: &str, config: &HttpClientConfig) -> Option<Self> { | ||
| let root_file = match std::env::var_os("SSL_CERT_FILE") { | ||
| Some(path) => { |
There was a problem hiding this comment.
🔵 Low — PoolKey::new runs a blocking std::fs::read plus SHA-256 of the whole SSL_CERT_FILE on every Session::open, from async code, even on a cache hit. Cache the digest by path plus mtime/len, or use spawn_blocking.
🔀 Found by Claude Opus 5.5 · confirmed by the judge
| Self { | ||
| connect_timeout: *connect_timeout, | ||
| read_timeout: *read_timeout, | ||
| max_connections_per_host: *max_connections_per_host, |
There was a problem hiding this comment.
🔵 Low — The pool key clones tls.client_key_pem and proxy.password in plaintext and keeps them in idle cache entries for up to about 105s after the session ends. They are not zeroized, and the cache outlives the session config that held them. Store a hash of the secret fields in the key, or zeroize on eviction.
🔀 Found by Claude Opus 5.5 · confirmed by the judge
Resolve the main changes by merging (no force-push). Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 2 low concerns. The pool key covers every reqwest builder setting, the lock order is consistent, shutdown closes the cache, and tests cover reuse, partitioning, expiry and opt-out.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/client/http.rs:116— DerivingPartialEq, Eqon the publicProxyConfig/TlsConfigcommits the crate to a new public trait surface. These types hold proxy passwords and client pr
Judge's evidence:#[derive(Clone, Default, PartialEq, Eq)] pub struct TlsConfig {
| fn new(host: &str, config: &HttpClientConfig) -> Option<Self> { | ||
| let root_file = match std::env::var_os("SSL_CERT_FILE") { | ||
| Some(path) => { | ||
| let contents = std::fs::read(&path).ok()?; |
There was a problem hiding this comment.
🔵 Low — PoolKey::new does a blocking std::fs::read and SHA-256 of SSL_CERT_FILE on the async worker thread for each pooled session open (only when that variable is set). Cache the digest by path/mtime/len or use spawn_blocking.
🔀 Found by Claude Opus 5.5 · confirmed by the judge
Repeated sessions rebuild reqwest and discard TLS connections. Five rotated fresh-process Node comparisons after the review fixes reduce sequential openSession p50 from 146.63 to 77.02 ms (-47.5%). Earlier driver tracing counted 9→1 TCP connects for nine cycles with auth/session RPC counts unchanged.
Lease cached clients exclusively so active sessions retain independent idle caps and request locality. Authentication, headers, retries and telemetry remain session-local.
HttpConfig::reuse_client_across_sessions = falseopts out while preserving within-session keep-alive. This is a Rust HTTP-config option; exposing it in bindings is a follow-up. Reuse is default-on, bounded to 16 idle clients/runtime, 90s idle plus a 15s cleanup sweep while the runtime is driven (next access/shutdown otherwise), and 300s maximum client age. Cache access sweeps expired entries too; the transport key exhaustively classifies client settings. This composes with #453/#455/#459/#470.Verification: fmt/native/rustls clippy, workspace excluding existing U2M failures, 161 rustls client, 91 napi, 31 PyO3 Rust, 58 live Python, 34 Node e2e, 30 live SEA and 96 pool stress processes pass; 4 Node cases remain pending. Three unfiltered local U2M failures reproduce on the baseline. Session-reuse, expiry and opt-out mutants fail assertions/exit101; adding a client-config field fails compilation with E0027.
The 8×16 mock has zero reconnects in all 15 steady rounds/side and matching value/null checksums. Live auth is CLI OAuth; PAT/M2M coverage is mocked. No statement-throughput gain is claimed. Earlier unfavorable CloudFetch/tail results and Python/idle/M2M evidence remain archived. CI's unchanged chrono advisory failures are documented.
Adversarial review converged in round 2 with no open high; R2-1–R2-4 are fixed in separate signed-off commits with tests and mutant evidence. Rebased onto main after #434 merged; the tree is identical to the bot-approved 57a6bbf.
This pull request and its description were written by Isaac.