Skip to content

Avoid copying Thrift CloudFetch response buffers - #627

Merged
vuanhphung merged 3 commits into
mainfrom
perf/thrift-cloudfetch
Nov 20, 2026
Merged

vuanhphung merged 3 commits into
mainfrom
perf/thrift-cloudfetch

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Thrift CloudFetch's arrayBuffer() copies node-fetch's already-consumed Buffer. A live 2.109 GB catalog-sales profile attributes 725 ms of self time to that copy; the candidate profile has zero samples there.

Carry response.buffer() directly through the Arrow handoff, removing one full-body allocation. Scheduling, concurrency 10, CloudFetch LZ4-off, retries, logging and telemetry stay unchanged. This is Thrift-only because kernel HTTP/body handling is native. There is a mechanical textual conflict with #610: whichever lands second must use const bodyRead = response.buffer(); inside its idle-timer wrapper. #623's row-limit path is untouched.

Verification: 1806 unit tests (including 28 CloudFetch) and lint/format/types/build pass. A real-HTTP pooled-Arrow test catches the production-read copy mutant. Live Thrift 4/4, kernel 7/7 and full-value/null/limit parity passed on identical runtime code.

Independent adversarial measurements find 10–14% lower CPU and 7–15% lower median peak RSS on live catalog drains. Node 24.22.1; rotated fresh-process A/B, warm-ups discarded, shared live warehouse; medians:

Scenario Pairs Elapsed main → branch
Mock: 64 real Arrow files, 30 ms RTT, drain 7 1.440 → 1.104 s (-23.3%)
Live catalog, actual 2.109 GB, drain 7 10.883 → 9.716 s (-10.7%)
Same, pinned to 4 logical CPUs 5 11.559 → 9.920 s (-14.2%)

Elapsed gains are not repeatable at 216 MB or on materialized/storage-bound results; no universal/tail speedup is claimed. Largest materializations hit the 115 s cap on both revisions. Accepted baseline: mid-download close/cancel emits one error-telemetry event on both main and branch, pre-existing on main and unchanged by this PR; neither produces ERROR logs or unhandled rejections.

Adversarial review: round 1 converged with no high findings; evidence wording corrected, production-path coverage added, and unchanged lifecycle telemetry accepted separately.

This pull request and its description were written by Isaac.

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>
@vuanhphung
vuanhphung marked this pull request as ready for review November 19, 2026 15:41

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

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>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 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, no blocking issues. Switching arrayBuffer() to buffer() keeps the retry, LZ4 and telemetry paths the same. Both new tests check the change: one covers the fallback path, and the other runs a real-HTTP pooled Buffer, with a byteOffset view, through the Arrow converter.

Other findings

  • ⚪ Nit — The new CHANGELOG entry has no PR reference, unlike the neighbouring entries such as (#508). Add (#627) to it. (Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept)

@vuanhphung
vuanhphung added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 386d242 Nov 20, 2026
23 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — d75493e7 Deployed Nov 19, 2026 by vuanhphung via e2e-test (22.23.4, 22_23_4) #2164
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.

3 participants