Skip to content

perf: avoid flattening and shifting result batches - #577

Open
vuanhphung wants to merge 2 commits into
mainfrom
perf/result-slicer-offsets
Open

vuanhphung wants to merge 2 commits into
mainfrom
perf/result-slicer-offsets

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

ResultSlicer tracks leftovers by offset and shares a copy loop with fetchAll(), preserving chunk sizes, row order, hasMore(), and disableBuffering behavior. Initial allocation is capped at 2 ** 25 to avoid V8 dictionary arrays; sequential writes grow larger results. Negative, NaN, and fractional limits retain their previous behavior.

Validation: 1,544 unit tests pass (CODEX_CI unset), plus lint, Prettier, type checking, and build. Compared 2,000 generated slicing scenarios against main and checked every output row immediately below, at, and above the allocation threshold.

Offline benchmarks on Node v24.14.0, three alternating fresh-process runs per build: the 80,003,072-row Arrow pipeline improved from 28.3 to 12.4 ns/row (100,000-row fetches, materialization disabled, DBSQL_KERNEL_PIPELINE unset). Joining 4,096-row placeholder batches improved versus main's flat(): 40M rows 1.301 → 0.541 s; 80M rows 2.965 → 1.730 s (medians).

Live kernel benchmark using pecotesting on Medium serverless, result caching and row materialization disabled, 100,000-row chunks: medians of five fresh-process samples per build after warmup. All runs returned the expected row counts.

Query Elapsed, main → PR Drain, main → PR
Boolean, 80M rows 3.641 → 2.513 s 2.557 → 1.471 s
Float, 50M rows 4.800 → 4.151 s 1.718 → 1.089 s
Double, 30M rows 4.622 → 4.394 s 1.085 → 0.828 s

One PR double sample took 17.075 s elapsed / 11.903 s drain and remains included in the median.

Signed-off-by: Vu Anh Phung <vu.phung@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.

✅ No issues identified by the review bot.

Signed-off-by: Vu Anh Phung <vu.phung@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.

✅ No issues identified by the review bot.

This branch was successfully deployed

1 active deployment
azure-prod — 0a0b5767 Deployed Nov 11, 2026 by vuanhphung via e2e-test (26.12.1, 26_12_1) #1850
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant