Skip to content

Conversation

@sanketkedia
Copy link
Contributor

@sanketkedia sanketkedia commented Jun 26, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • We persist the max_block_size_bytes in the arrow metadata now and also add a new blockfile version for handling backward compatibility with old data
    • This is need so that spann posting list can have a block size different from other blockfiles
    • This PR also sets the spann PL block size to 5MiB
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

None

Copy link
Contributor Author

sanketkedia commented Jun 26, 2025

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@sanketkedia sanketkedia requested a review from codetheweb June 26, 2025 01:49
@sanketkedia sanketkedia marked this pull request as ready for review June 26, 2025 01:49
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Jun 26, 2025

Enable Per-Blockfile Custom Block Sizes and Metadata Migration

This PR introduces support for specifying different max block sizes for individual blockfiles. The blockfile versioning and Arrow metadata schema are updated to persist block size information per file, with corresponding migration logic to maintain backward compatibility. The primary motivator is to allow the Spann posting list blockfiles to use a distinct block size (defaulted to 5MiB) while leaving the default 8MiB setting for other blockfile types. Extensive tests and migration scenarios are included to ensure correctness and compatibility across prior versions.

Key Changes:
• Blockfile writer and APIs updated to allow specifying max_block_size_bytes per blockfile via options object
• Arrow blockfile root metadata now persists max_block_size_bytes in each file, with new version V1_2 introduced
• BlockManager now exposes default_max_block_size_bytes, passed down to blockfile readers/writers as fallback
• Arrow (ordered/unordered) blockfile writers/readers and provider now use per-file block size instead of global default
• Spann Posting List creation now specifies a custom 5MiB block size (overridable via config)
• Blockfile migration system enhanced to handle transitions between blockfile versions, including V1_1→V1_2 upgrade and correct block size hydration
• Extensive migration and backward compatibility tests ensuring various edge cases are handled (legacy, partially upgraded, fully upgraded files)
• Tilt and config files updated to allow configurable pl_block_size for Spann in deployment
• API and config plumbing for passing custom block size through segment/provider layers

Affected Areas:
• rust/blockstore/src/arrow/blockfile.rs
• rust/blockstore/src/arrow/ordered_blockfile_writer.rs
• rust/blockstore/src/arrow/provider.rs
• rust/blockstore/src/arrow/root.rs
• rust/blockstore/src/arrow/migrations.rs
• rust/blockstore/src/types/writer_options.rs
• rust/index/src/config.rs
• rust/index/src/spann/types.rs
• rust/segment/src/spann_provider.rs
• rust/segment/src/distributed_spann.rs
• rust/segment/src/test.rs
• rust/worker/tilt_config.yaml

This summary was automatically generated by @propel-code-bot


use super::utils::{rng_query, KMeansAlgorithmInput, KMeansError, RngQueryError};

const PL_BLOCK_SIZE: usize = 5 * 1024 * 1024; // 5 MiB
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should add a justification for why this

@sanketkedia sanketkedia force-pushed the 06-19-_enh_granular_lock_in_spann_index branch from f99a00a to ab8839e Compare June 26, 2025 07:36
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from 56c1e29 to 3c09498 Compare June 26, 2025 07:36
Ok(())
}

async fn migrate_v1_to_v1_1(
Copy link
Contributor

Choose a reason for hiding this comment

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

should update this method name

@sanketkedia sanketkedia force-pushed the 06-19-_enh_granular_lock_in_spann_index branch 2 times, most recently from c13149b to 561c851 Compare June 26, 2025 17:04
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from 3c09498 to adfa3f8 Compare June 26, 2025 17:04
@sanketkedia sanketkedia force-pushed the 06-19-_enh_granular_lock_in_spann_index branch from 561c851 to 9f05434 Compare June 26, 2025 18:01
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from adfa3f8 to 27cdd92 Compare June 26, 2025 18:01
@sanketkedia sanketkedia force-pushed the 06-19-_enh_granular_lock_in_spann_index branch from 9f05434 to 28e3c9e Compare June 26, 2025 18:24
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from 27cdd92 to 1b00d59 Compare June 26, 2025 18:24
@sanketkedia sanketkedia changed the base branch from 06-19-_enh_granular_lock_in_spann_index to graphite-base/4948 June 26, 2025 19:22
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from 1b00d59 to 0b3c66e Compare June 26, 2025 19:23
@graphite-app graphite-app bot changed the base branch from graphite-base/4948 to main June 26, 2025 19:23
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch 3 times, most recently from f9ead28 to 2293092 Compare June 27, 2025 00:35
@sanketkedia sanketkedia force-pushed the 06-25-_enh_add_ability_to_set_different_block_sizes_for_different_blockfiles branch from e7c50b5 to 4aeb57d Compare June 29, 2025 00:12
@sanketkedia sanketkedia enabled auto-merge (squash) June 29, 2025 01:52
@sanketkedia sanketkedia disabled auto-merge June 29, 2025 03:19
@sanketkedia sanketkedia merged commit b276b79 into main Jun 29, 2025
56 of 57 checks passed
Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
…les (chroma-core#4948)

## Description of changes

_Summarize the changes made by this PR._

- Improvements & Bug fixes
- We persist the max_block_size_bytes in the arrow metadata now and also
add a new blockfile version for handling backward compatibility with old
data
- This is need so that spann posting list can have a block size
different from other blockfiles
  - This PR also sets the spann PL block size to 5MiB
- New functionality
  - ...

## Test plan

_How are these changes tested?_
- [x] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
None
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.

4 participants