Skip to content

fix(ci): enlarge mem pool only around merge_insert index build - #8191

Merged
Xuanwo merged 2 commits into
mainfrom
xuanwo/fix-sort-spill-reservation-cap
Aug 4, 2026
Merged

fix(ci): enlarge mem pool only around merge_insert index build#8191
Xuanwo merged 2 commits into
mainfrom
xuanwo/fix-sort-spill-reservation-cap

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Why

Run Regression Benchmarks fails during Generate datasets when building BTREE indexes on merge_insert_narrow string keys:

OSError: LanceError(IO): Resources exhausted: Additional allocation failed for ExternalSorterMerge[0] ...
fair(pool_size: 150.0 MB)

Example: https://github.com/lance-format/lance/actions/runs/30819924543/job/91706969640

Approach

Library-wide tuning of sort_spill_reservation_bytes is not a reliable fix for this class of failure (there is no safe general value for that knob). Index build here is one-shot datagen setup, not a measured benchmark path.

Temporarily set LANCE_MEM_POOL_SIZE=1GiB only around the create_scalar_index loop in merge_insert datagen, then restore the previous env so measured paths keep the default pool.

Notes

  • Reverts the earlier default-reservation change from this PR.
  • Scoped to merge_insert datagen only; other datagen paths were not failing on this error.

The sort spill reservation was sized as pool/3 but hard-capped at 40 MiB.
Under the default 150 MiB FairSpillPool that leaves only 40 MiB free for
ExternalSorterMerge, while BTREE training on large string columns (e.g.
10M uuid keys in merge_insert datagen) peaks near 48 MiB and fails with
ResourcesExhausted. Raise the ceiling to 64 MiB so the default pool keeps
its intended pool/3 (= 50 MiB) reservation.
@github-actions github-actions Bot added the bug Something isn't working label Aug 3, 2026

@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 with a non-blocking risk.

The reservation increase matches DataFusion’s merge-memory contract. The remaining risk is that the exact workload threshold and added spill I/O are not behaviorally pinned; an end-to-end regression that fails at 40 MiB and passes at 50 MiB would make this tuning durable.

Comment thread rust/lance-datafusion/src/exec.rs Outdated
}

#[test]
fn test_sort_spill_reservation_bytes() {

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.

This validates the sizing arithmetic, but not the behavioral contract that 40 MiB exhausts the target workload and 50 MiB succeeds. I ran a 10M-row UUID7-shaped, 32-byte-string BTREE build against the base 150 MiB / 40 MiB configuration and it passed, so the failure depends on a batch or storage shape this test does not capture. Please add an end-to-end case matching that shape, or capture the relevant merge-reservation metrics, so the threshold is pinned.

@westonpace westonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not opposed but I'm not sure this will work any better. There is just no safe way to set these variables. It seems pretty much impossible to predict what sort_spill_reservation_bytes should be set to.

@Xuanwo

Xuanwo commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

I'm not opposed but I'm not sure this will work any better. There is just no safe way to set these variables. It seems pretty much impossible to predict what sort_spill_reservation_bytes should be set to.

I'm not really won't to set this. Just wanna to fix the bench regress CI.

I'm open to put a step back for better solutions.

cc @wjones127 to join the discuss.

@wjones127

Copy link
Copy Markdown
Contributor

I'm not opposed but I'm not sure this will work any better. There is just no safe way to set these variables. It seems pretty much impossible to predict what sort_spill_reservation_bytes should be set to.

I'm not really won't to set this. Just wanna to fix the bench regress CI.

I'm open to put a step back for better solutions.

cc @wjones127 to join the discuss.

I'm fine with just fixing this in CI.

I'm sure you and Weston have looked more at this, so it seems like there isn't a great generate solution for sorting wide data with small memory pools. I think in production most folks will just want to increase the memory pool to be a significant fraction of system memory, at least in single-tenant use cases.

BTREE training on merge_insert_narrow's 10M string keys can exhaust the
default 150 MiB FairSpillPool during ExternalSorterMerge and abort
bench_regress datagen. Raising the library-wide sort spill reservation is
not a reliable fix for this class of failure.

Enlarge LANCE_MEM_POOL_SIZE to 1 GiB only for the create_scalar_index loop
in merge_insert datagen, then restore the previous env so measured
benchmark paths keep the default pool.
@Xuanwo Xuanwo changed the title fix: raise sort spill reservation ceiling for default memory pool fix(ci): enlarge mem pool only around merge_insert index build Aug 4, 2026
@github-actions github-actions Bot added the A-python Python bindings label Aug 4, 2026
@Xuanwo
Xuanwo merged commit 3f7adda into main Aug 4, 2026
18 of 21 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/fix-sort-spill-reservation-cap branch August 4, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants