Skip to content

fix(compaction): default index_remap_mode from LANCE_FRAG_REUSE_REMAP_MODE - #48

Closed
amunra wants to merge 1 commit into
release-8.0.0from
adam/compaction_default_remap_mode
Closed

amunra wants to merge 1 commit into
release-8.0.0from
adam/compaction_default_remap_mode

Conversation

@amunra

@amunra amunra commented Aug 24, 2026 •

Copy link
Copy Markdown

Bug identified by #47, which is now merged; this PR targets release-8.0.0 directly and is a single commit on top of it.

The bug

CompactionOptions::index_remap_mode hardcoded Direct and was wired to nothing:

defer_index_remap: false,
index_remap_mode: IndexRemapMode::Direct,

So a deployment that moved its readers onto the compact reuse-remap form to bound memory still had every compact_files call that did not explicitly name a form build the per-row HashMap<u64, Option<u64>> remap — the writer-side instance of exactly the growth the compact form exists to avoid. Nobody chose it; the default was simply never revisited when the compact form landed.

This is what LANCE_FRAG_REUSE_REMAP_MODE=assert(compact) from #47 was built to surface, and it is the first thing it found.

The fix

Both sides expand the same reuse payload, so they take the same setting:

  • CompactionOptions::default().index_remap_mode now comes from default_frag_reuse_remap_mode().
  • The field's serde(default) points at the same function, so a serialized options struct that omits the field agrees with a freshly defaulted one instead of silently reverting to Direct.
  • test_from_dataset_config_empty pinned the default to Direct literally; it now pins it to the env-derived default, which is what the field actually promises.
  • Doc updates on both sides so the env var reads as one setting moving reader and writer together.

With LANCE_FRAG_REUSE_REMAP_MODE unset the default is still Direct, so this is not a behaviour change on its own — it only gives the existing env var reach over the writer.

Open question for review

This gives a variable documented so far as reader-side (ReadParams::frag_reuse_remap_mode) reach over compaction. The alternative is a separate LANCE_COMPACTION_REMAP_MODE. One variable was chosen because both sides expand the same payload and splitting them lets the pair drift back apart — but it is worth an explicit ack.

Results

Run Before this PR After
optimize::tests, env unset 103 pass 103 pass
optimize::tests, assert(compact) 64 pass / 39 fail 95 pass / 8 fail
full lance lib, env unset 2064 pass 2064 pass
full lance lib, assert(compact) — 2052 pass / 12 fail
integration targets, assert(compact) — 4 pass / 0 fail

All 12 remaining failures name the direct form on purpose, so nothing forgotten is left in the crate:

  • the 7 deliberate-direct cases (test_catch_up_...::case_1_direct, test_frag_reuse_remap_mode_end_to_end::case_1_direct, the case_2 arms of the btree/ivf_pq/inverted remap families, both arms of test_shared_session_serves_both_forms);
  • test_compact_form_costs_the_cache_far_less, which loops over both forms to compare cache growth;
  • 4 in index::frag_reuse::tests, including test_default_mode_is_direct — that one asserts the unset-env contract, so it is supposed to fail when the env var is set.

cargo fmt --all and cargo clippy -p lance --tests -- -D warnings are clean.

🤖 Generated with Claude Code

…_MODE

`CompactionOptions::index_remap_mode` hardcoded `Direct` and was wired to
nothing, so a deployment that moved its readers onto the compact reuse-remap
form to bound memory still had every `compact_files` call that did not name a
form build the per-row `HashMap<u64, Option<u64>>` -- the writer-side instance
of exactly the growth the compact form exists to avoid. Nobody chose it; the
default was simply never revisited when the compact form landed.

Both sides expand the same reuse payload, so they take the same setting: the
field now defaults to `default_frag_reuse_remap_mode()`, and its `serde(default)`
does too, so a serialized options struct that omits the field agrees with a
freshly defaulted one. With `LANCE_FRAG_REUSE_REMAP_MODE` unset the default is
still `Direct`, so this is not a behaviour change on its own.

`test_from_dataset_config_empty` pinned the default to `Direct` literally; it now
pins it to the env-derived default, which is what the field actually promises.

Found by `LANCE_FRAG_REUSE_REMAP_MODE=assert(compact)`, which took the `lance`
lib suite from 39 failures to 8 in `optimize::tests` alone.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@amunra
amunra force-pushed the adam/compaction_default_remap_mode branch from 6d8a1ad to a17ee65 Compare August 24, 2026 11:08
@amunra
amunra changed the base branch from adam/assert_compact_fri to release-8.0.0 August 24, 2026 11:08
@ilya-zlobintsev

Copy link
Copy Markdown
Member

I strongly prefer human-written PR descriptions, this description is way too long a 1.5 line change

@amunra

amunra commented Sep 14, 2026

Copy link
Copy Markdown
Author

We should have merged it and didn't.

It's been ported (and merged) into release-10.0.0 instead.

Customers off release-8.0.0 might need this, but it hasn't surfaced in prod yet, so we're probably fine and release-8.0.0 is soon to be decommissioned.

While technically a bug (an ommission), I'm closing it as the omission would manifest (if it ever does) as a perf issue, not a correctness issue.

@amunra amunra closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants