Repository navigation
perf: stable row id prefilter - #2706
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2706 +/- ##
==========================================
+ Coverage 79.21% 79.25% +0.04%
==========================================
Files 227 227
Lines 67733 67947 +214
Branches 67733 67947 +214
==========================================
+ Hits 53652 53851 +199
- Misses 10968 10978 +10
- Partials 3113 3118 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
be8be9b to
e8ea004
Compare
westonpace
left a comment
There was a problem hiding this comment.
Looks good, nice work on the mask function.
| #[test] | ||
| fn test_row_id_mask() { | ||
| // 0, 1, 2, 3, 4 | ||
| // 50, 51, 52, 55, 56, 57, 58, 59 | ||
| // 7, 9 | ||
| // 10, 12, 14 | ||
| // 35, 39 | ||
| let sequence = RowIdSequence(vec![ | ||
| U64Segment::Range(0..5), | ||
| U64Segment::RangeWithHoles { | ||
| range: 50..60, | ||
| holes: vec![53, 54].into(), | ||
| }, | ||
| U64Segment::SortedArray(vec![7, 9].into()), | ||
| U64Segment::RangeWithBitmap { | ||
| range: 10..15, | ||
| bitmap: [true, false, true, false, true].as_slice().into(), | ||
| }, | ||
| U64Segment::Array(vec![35, 39].into()), | ||
| ]); | ||
|
|
||
| // Masking one in each segment | ||
| let values_to_remove = [4, 55, 7, 12, 39]; | ||
| let positions_to_remove = sequence | ||
| .iter() | ||
| .enumerate() | ||
| .filter_map(|(i, val)| { | ||
| if values_to_remove.contains(&val) { | ||
| Some(i as u32) | ||
| } else { | ||
| None | ||
| } | ||
| }) | ||
| .collect::<Vec<_>>(); | ||
| let mut sequence = sequence; | ||
| sequence.mask(positions_to_remove).unwrap(); | ||
| let expected = RowIdSequence(vec![ | ||
| U64Segment::Range(0..4), | ||
| U64Segment::RangeWithBitmap { | ||
| range: 50..60, | ||
| bitmap: [ | ||
| true, true, true, false, false, false, true, true, true, true, | ||
| ] | ||
| .as_slice() | ||
| .into(), | ||
| }, | ||
| U64Segment::Range(9..10), | ||
| U64Segment::RangeWithBitmap { | ||
| range: 10..15, | ||
| bitmap: [true, false, false, false, true].as_slice().into(), | ||
| }, | ||
| U64Segment::Array(vec![35].into()), | ||
| ]); | ||
| assert_eq!(sequence, expected); | ||
| } |
There was a problem hiding this comment.
What happens if you mask out every row id in a segment?
| .filter(|(sequential_i, i)| **i != *sequential_i as u32) | ||
| .map(|(sequential_i, _)| sequential_i) | ||
| .next() |
| sorted, | ||
| }; | ||
|
|
||
| let make_new_iter = || { |
There was a problem hiding this comment.
Why is a named closure needed here? Can't you just execute it?
There was a problem hiding this comment.
I could, but that just wouldn't be convoluted enough. 😄
I'll simplify this.
| let (row_ids, deletion_vector) = join!(row_ids, deletion_vector); | ||
| Ok::<_, crate::Error>((row_ids?, deletion_vector?)) | ||
| }) | ||
| .buffer_unordered(10) |
There was a problem hiding this comment.
I see you just moved this function but maybe let's get rid of the random 10?
There was a problem hiding this comment.
What is our best practice right now. I don't love this, but I just don't know what our current preferred pattern is right now.
There was a problem hiding this comment.
Since it's mostly I/O driven I'd recommend dataset.object_store().io_parallelism()?
|
|
||
| // The process of computing the final mask is CPU-bound, so we spawn it | ||
| // on a blocking thread. | ||
| let allow_list = tokio::task::spawn_blocking(move || { |
There was a problem hiding this comment.
Perhaps we should use spawn_cpu here?
c0d6323 to
1b3403a
Compare
Cache the row id mask prefilter and make it faster to construct.