Skip to content

[ENH] Prefetch block by prefixes #4623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025

Conversation

Sicheng-Pan
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan commented May 23, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • N/A
  • New functionality
    • Implements blockfile prefetch by prefix

Test plan

How are these changes tested?

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

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

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)

Copy link
Contributor Author

Sicheng-Pan commented May 23, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Sicheng-Pan Sicheng-Pan mentioned this pull request May 23, 2025
1 task
Copy link

Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review May 23, 2025 19:04
Copy link
Contributor

propel-code-bot bot commented May 23, 2025

Implement Blockfile Prefetch by Prefix

This PR introduces the ability to prefetch blockfile data based on a list of prefixes, expanding efficient bulk loading strategies for the blockstore. The core addition is a new method on the sparse index (get_block_ids_for_prefixes) that retrieves all relevant block IDs for given prefixes, and this is now threaded through the Arrow blockfile implementation and exposed via the blockfile reader API.

Key Changes:
• Added get_block_ids_for_prefixes method to SparseIndexReader and SparseIndexWriter to enable efficient lookup of block IDs covering multiple prefixes.
• Introduced load_blocks_for_prefixes async method in both ArrowBlockfileReader and the generic BlockfileReader interface, which prefetches all blocks covering the given prefixes.
• Hooked up these methods in the blockfile reader trait hierarchy to allow client code to trigger block prefetch using a list of prefixes.
• Small refactor to get_block_ids_range signature to remove an unused lifetime.
• Maintained unimplemented!() for the memory-backed reader variant with a placeholder for future support.

Affected Areas:
• arrow/sparse_index.rs (SparseIndex lookup logic)
• arrow/blockfile.rs (prefetch logic)
• types/reader.rs (API exposure and trait implementations)

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

@Sicheng-Pan Sicheng-Pan changed the title Prefetch block by prefixes [ENH] Prefetch block by prefixes May 23, 2025
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from f3cedac to 78dbbb3 Compare May 23, 2025 19:51
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-19-_tst_add_unit_test_for_literal_expr branch from dedfbd1 to 3feb7e0 Compare May 23, 2025 19:51
@@ -362,7 +362,47 @@ impl SparseIndexReader {
result_uuids
}

pub(super) fn get_block_ids_range<'prefix, 'referred_data, PrefixRange>(
pub(super) fn get_block_ids_for_prefixes(&self, mut prefixes: Vec<&str>) -> Vec<Uuid> {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Documentation]

The new get_block_ids_for_prefixes function could benefit from some documentation comments explaining its purpose, behavior, and usage - especially since it's a key component of the newly added functionality.

@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-19-_tst_add_unit_test_for_literal_expr branch from 3feb7e0 to 534bff0 Compare May 27, 2025 18:37
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from 78dbbb3 to d4d29e1 Compare May 27, 2025 18:37
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from d4d29e1 to a924a12 Compare May 27, 2025 21:55
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-19-_tst_add_unit_test_for_literal_expr branch 2 times, most recently from 982a8a5 to 88133e0 Compare May 28, 2025 21:59
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from a924a12 to 2f5ee22 Compare May 28, 2025 21:59
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-19-_tst_add_unit_test_for_literal_expr branch from 88133e0 to 8ce40bd Compare May 29, 2025 17:11
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from 2f5ee22 to 66fba61 Compare May 29, 2025 17:11
Copy link
Contributor Author

Sicheng-Pan commented May 29, 2025

Merge activity

  • May 29, 11:02 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 29, 11:04 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 29, 11:37 PM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'all-required-pr-checks-passed', 'Python tests / test-cluster-rust-frontend (3.9, blacksmith-16vcpu-ubuntu-2204, chromadb/test/api)', 'Python tests / test-cluster-rust-frontend (3.9, blacksmith-16vcpu-ubuntu-2204, chromadb/test/property/test_colle...', 'Rust tests / test-integration (blacksmith-16vcpu-ubuntu-2204)').
  • May 30, 6:07 PM UTC: @Sicheng-Pan merged this pull request with Graphite.

@Sicheng-Pan Sicheng-Pan changed the base branch from sicheng/05-19-_tst_add_unit_test_for_literal_expr to graphite-base/4623 May 29, 2025 23:02
@Sicheng-Pan Sicheng-Pan changed the base branch from graphite-base/4623 to main May 29, 2025 23:03
@Sicheng-Pan Sicheng-Pan force-pushed the sicheng/05-21-_enh_prefetch_block_by_prefixes branch from 66fba61 to 9c46a5b Compare May 29, 2025 23:03
@Sicheng-Pan Sicheng-Pan merged commit b2c40df into main May 30, 2025
72 checks passed
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.

2 participants