Repository navigation
perf: avoid flattening and shifting result batches - #577
Open
vuanhphung wants to merge 2 commits into
Open
vuanhphung wants to merge 2 commits into
vuanhphung wants to merge 2 commits into
Conversation
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
This branch was successfully 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.
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
pecotestingon 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.One PR double sample took 17.075 s elapsed / 11.903 s drain and remains included in the median.