Skip to content

fix(merge_insert): plan small streaming sources with exact statistics - #11733

Merged
BubbleCal merged 3 commits into
lance-format:mainfrom
BubbleCal:t3/merge-insert-build-amplification
Dec 2, 2026
Merged

BubbleCal merged 3 commits into
lance-format:mainfrom
BubbleCal:t3/merge-insert-build-amplification

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses #9505. A non-indexed merge with a small streaming source and no statistics can build the hash table from the entire target. When an eligible Lance-owned stream reaches EOF within a bounded probe, pass exact source statistics to DataFusion through a MemTable. When the probe stops early, deliver its buffered batches and the rest of the stream in order.

Keep the existing join actions and retry policy. An authorized retry can reuse the prepared source and plan again against the refreshed target.

Performance

The V1 run compared 00122ee030f1e385c8848adc1f7924f7dfd3baa9 with 3d3f5bfa6217487a49b308cbb322d7f48d94f379. The 10M-row, 44-column fixture includes a deletion vector and an uncovered tail. Each run applies 100 one-shot updates with RewriteRows. Runs used a GCP n2-highmem-16 VM, attached 350 GB GCP pd-ssd, 8 CPUs and an 88 GiB cgroup limit. Medians use two AB/BA repetitions per arm and cache condition. The hot condition pre-reads the snapshot into the OS page cache. V1 latency is measured from arrival to commit acknowledgement.

Scenario / metric Baseline This PR Benefit
Cold operation latency ↓ 32.70 s 30.86 s 1.06x speedup
Cold peak RSS ↓ 26.70 GiB 1.08 GiB 24.68x lower
Cold peak cgroup charge ↓ 39.13 GiB 13.27 GiB 2.95x lower
Hot operation latency ↓ 14.37 s 3.53 s 4.07x speedup
Hot peak RSS ↓ 27.91 GiB 3.52 GiB 7.92x lower
Hot peak cgroup charge ↓ 27.93 GiB 3.40 GiB 8.21x lower

All eight V1 cells matched the independently regenerated plan, passed the full-table oracle and recorded zero OOM kills. Peak cgroup charge includes charged file cache.

The cold fallback controls use the same frozen snapshot and settings, with two AB/BA repetitions per arm. The delayed reader waits 150 ms before batch two. The over-limit reader delivers 50 batches of two rows. These latencies measure public execution through commit return. All eight operations passed the full-table oracle.

Fallback scenario / metric Baseline This PR Difference
Delayed reader latency ↓ 34.487 s 34.528 s +0.12%
Delayed reader peak RSS ↓ 26.842 GiB 26.827 GiB −0.06%
Over-limit reader latency ↓ 34.264 s 34.488 s +0.65%
Over-limit reader peak RSS ↓ 26.834 GiB 26.711 GiB −0.46%

Validation

  • The baseline reproduced the target-side hash build at 10M and 30M rows. The stats-aware control built the source. The baseline and initial candidate covered default replay, a narrow target and indexed routing.
  • Workspace fmt and Clippy passed on the managed VM. GitHub CI passed on 00122ee03. The managed VM also passed all 11 source-statistics tests and the build-side plan test, including the zero-poll invalid UpdateIf and successful retry after a 34-batch fallback.

@github-actions github-actions Bot added the bug Something isn't working label Dec 2, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review December 2, 2026 10:08

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@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 bounded statistics approach addresses #9505 for small sources that finish within the probe limits. Local probe, join-selection, retry, and multi-fragment partial-update checks passed.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@BubbleCal
BubbleCal merged commit 2356bea into lance-format:main Dec 2, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants