Skip to content

perf: reuse loaded utf8 pages for byte-sized batches - #11746

Merged
Xuanwo merged 1 commit into
mainfrom
yang/t215-first-string-decode-batch
Dec 2, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
yang/t215-first-string-decode-batch

Conversation

@BubbleCal

Copy link
Copy Markdown
Contributor

Why

With an explicit byte target, a structural reader limits variable-width batches to 128 rows until it gets decode feedback. A small fragment can already have its full UTF-8 page loaded at that point, so equality scans over many small fragments pay for several decode tasks per fragment.

What changed

For a single Utf8 column, use the existing decoded-byte planner to size a larger batch from already-loaded rows. Keep the row and offset limits and use the regular drain path. Account for the MiniBlock builder's reservation of whole chunks. Fall back to the existing batch size when sparse ranges re-use a chunk, dictionary expansion or all-null pages prevent a usable estimate, or the layout cannot be sized.

Validation

  • The focused 397-row regression fails with four decode tasks on the baseline and passes with one on this change. A second test queues all tasks before feedback and checks byte capacity, order and EOF for repeated strings and all-null arrays.
  • A v2.2 file-reader test selects 4,096 alternating rows through ReadBatchParams::Ranges. It verifies a 128-row first batch within a 16 MiB target and checks the complete result in input order.
  • The pinned CI-profile lance-encoding and lance-file unit binaries passed 3,419 tests with 3 ignored.
  • cargo fmt --all --check and cargo clippy --locked --all --tests --benches -- -D warnings passed.

Paired AB/BA on one x86-64 Linux VM with gp3 and cgroup v2. Baseline is 38040f844. Both binaries use the same release profile and frozen 258,844-row datasets. Each arm has 40 warm repetitions. The query uses a string equality predicate and limit 1. The filter reader materializes one UTF-8 column before fetching the remaining columns.

Scenario / metric Baseline This PR Benefit
652 fragments, 40 columns, miss, 16 MiB target, EOF median (lower) 352.03 ms 119.42 ms 2.95x
652 fragments, 40 columns, late hit, 16 MiB target, EOF median (lower) 344.18 ms 128.55 ms 2.68x
652 fragments, 2 columns, miss, 16 MiB target, EOF median (lower) 343.52 ms 133.42 ms 2.57x
652 fragments, 2 columns, late hit, 16 MiB target, EOF median (lower) 341.92 ms 147.44 ms 2.32x

With the target enabled, peak scanner RSS for the 40-column 652-fragment miss was 61.2 MiB → 62.1 MiB (+1.5%). A direct file-reader check using release-with-debug reduced 1,956 batches to 652 across the v2.2 fixture and measured a maximum Arrow buffer capacity of 39,584 bytes in the candidate. The v2.1 fixture's 42 dictionary pages retained the small batches.

With the target disabled, the 40-column 652-fragment miss measured 125.87 ms → 118.45 ms in an additional interleaved run. The 2-column late hit measured 115.50 ms → 120.51 ms, with overlapping per-block medians. All timings cover the Lance scanner on the local filesystem.

The byte target remains approximate. For an 8,192-row batch, the offset vector can grow by up to about 24 KiB beyond the offset and validity allowance used in the estimate.

@github-actions github-actions Bot added A-encoding Encoding, IO, file reader/writer performance labels Dec 2, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review December 2, 2026 12:14

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Gate recommendation: approve.

The loaded-page estimate is a reasonable exception to the speculative-read guard from #10295. It removes the small-fragment decode-task overhead while retaining conservative startup batches for dictionary expansion and sparse chunk reuse.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@Xuanwo
Xuanwo merged commit f91a1f6 into main Dec 2, 2026
43 checks passed
@Xuanwo
Xuanwo deleted the yang/t215-first-string-decode-batch branch December 2, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-encoding Encoding, IO, file reader/writer K-approved Latest Gatekeeper recommendation permits acceptance. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants