Skip to content
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

feat: allow lazily chunking unsorted iteration #55

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

macklin-10x
Copy link
Contributor

Refactors unsorted shard iteration into a few more granular types.

Adds a skip_lazy method to the top-level type to allow lazily seeking into a collection of shard files. This allows chunking a set of shard files for parallel unordered iteration by multiple readers without having to read anything more than the shard index plus the first partially-read shard.

Copy link
Contributor

@pmarks pmarks left a comment

Choose a reason for hiding this comment

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

lgtm, other than possibly making the skip tests a little broader

src/lib.rs Outdated

// Check that the skip_lazy feature produces the expected results.
let mut unsorted_reader_skip = UnsortedShardReader::<T1>::open(tmp.path());
let to_skip = (disk_chunk_size * 3) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe scramble this value somehow to get different boundaries, or try a few different carefully chosen skip values here? You could skip to a file boundary, a chunk boundary, or the middle of a chunk and ideally the tests would hit all 3 cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ultimately didn't merge the cellranger patch that made use of this feature, so I'm a bit on the fence about merging it at all at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking into this again now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I enhanced the tests by writing two shard files of size n_items, to test the set reading logic. I expanded the skip tests to include these offsets:

            check_unsorted_skip(0)?;
            check_unsorted_skip(1)?;
            check_unsorted_skip(disk_chunk_size)?;
            check_unsorted_skip((disk_chunk_size * 3) + 1)?;
            check_unsorted_skip(n_items)?; // skip entire first file
            check_unsorted_skip(n_items + 1)?; // skip entire first file plus next item
            check_unsorted_skip(n_items * 2)?; // skip everything

@macklin-10x macklin-10x merged commit 54f2453 into master Sep 6, 2024
2 checks passed
@macklin-10x macklin-10x deleted the macklin/unsorted-reader-seek branch September 6, 2024 23:12
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