Skip to content

perf(httpfs): pool HTTP connections and cache remote file sizes - #62

Merged
adsharma merged 1 commit into
mainfrom
perf/xet-http-connection-pool
Aug 20, 2026
Merged

perf(httpfs): pool HTTP connections and cache remote file sizes#62
adsharma merged 1 commit into
mainfrom
perf/xet-http-connection-pool

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

What

Fixes the pathological network churn in the xet:// remote read path that made queries like:

profile match (a)-[b]->(c) return a.id, c.id limit 10;

very slow over HTTP (originally >400 tcp_sendmsg and ~155s+ to complete).

Root cause

  • A fresh httplib::Client was created per request/retry, so every range GET and HEAD tore down and re-established TLS — ~240 connects, ~5 per socket.
  • Each openFile() → initMetadata() issued a HEAD — ~899 HEAD round-trips — because the ice-disk CSR scan re-opens the same parquet files per morsel.

Changes

  1. Process-wide per-host connection poolgetSharedNoRedirectClient / evictAndGetSharedNoRedirectClient hold one keep-alive TLS socket per host reused across all requests; retries evict a stale pool entry instead of reusing a broken socket.
  2. Deadlock-safe locking — the shared-connection lock is scoped to a single host request and released before following a redirect (avoiding self-deadlock on recursion).
  3. Remote file-size cache keyed by URL so repeat openFile() skips the HEAD.

Result (profile query)

metric before after
connects ~240 2
HEAD round-trips 899 5
wall time ~155s ~31s

No functional change; queries still return correct results.

The xet:// remote path was paying enormous per-request churn:

- A fresh httplib::Client was created per request/retry, so every range GET
  tore down and re-established TLS (~240 connects, ~5 per socket).
- Each openFile() -> initMetadata() issued a HEAD (899 HEAD round-trips)
  because the ice-disk CSR scan re-opens the same parquet files per morsel.

Fixes:
- Process-wide per-host pool of no-follow httplib clients
  (getSharedNoRedirectClient/evictAndGetSharedNoRedirectClient). All requests
  to a host share one keep-alive TLS socket; retries evict a stale pool entry
  instead of reusing a dead socket.
- Scope the shared-connection lock to a single host request and release it
  before following a redirect (avoids self-deadlock on recursion).
- Process-wide cache of remote file sizes keyed by URL so openFile() skips the
  HEAD on repeat opens.

Result on the profile query: connects 240 -> 2, HEAD round-trips 899 -> 5,
end-to-end wall time ~155s -> ~31s.
@adsharma
adsharma merged commit 05c63dd into main Aug 20, 2026
2 checks passed
@adsharma
adsharma deleted the perf/xet-http-connection-pool branch August 20, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant