Skip to content

Commit

Permalink
Another attempt at introducing a columnated merge batcher (#418)
Browse files Browse the repository at this point in the history
* Copy merge_batcher

Signed-off-by: Moritz Hoffmann <[email protected]>

* Merge batcher col updates

* Introduce update type on Vector/TStack layouts

Signed-off-by: Moritz Hoffmann <[email protected]>

* cleanup

Signed-off-by: Moritz Hoffmann <[email protected]>

* Cleanup of merge_batcher_col

Signed-off-by: Moritz Hoffmann <[email protected]>

* ColKeySpine with TimelyStack in the merge batcher

Signed-off-by: Moritz Hoffmann <[email protected]>

* Address comments

Signed-off-by: Moritz Hoffmann <[email protected]>

* Simpler TimelyStackQueue

Signed-off-by: Moritz Hoffmann <[email protected]>

---------

Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru authored Nov 20, 2023
1 parent f4a951e commit 9163a29
Show file tree
Hide file tree
Showing 5 changed files with 456 additions and 83 deletions.
37 changes: 1 addition & 36 deletions src/trace/implementations/merge_batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
}
}

pub struct MergeSorter<D: Ord, T: Ord, R: Semigroup> {
struct MergeSorter<D: Ord, T: Ord, R: Semigroup> {
queue: Vec<Vec<Vec<(D, T, R)>>>, // each power-of-two length list of allocations.
stash: Vec<Vec<(D, T, R)>>,
}
Expand Down Expand Up @@ -283,38 +283,3 @@ impl<D: Ord, T: Ord, R: Semigroup> MergeSorter<D, T, R> {
output
}
}

/// Reports the number of elements satisfing the predicate.
///
/// This methods *relies strongly* on the assumption that the predicate
/// stays false once it becomes false, a joint property of the predicate
/// and the slice. This allows `advance` to use exponential search to
/// count the number of elements in time logarithmic in the result.
#[inline]
pub fn _advance<T, F: Fn(&T)->bool>(slice: &[T], function: F) -> usize {

// start with no advance
let mut index = 0;
if index < slice.len() && function(&slice[index]) {

// advance in exponentially growing steps.
let mut step = 1;
while index + step < slice.len() && function(&slice[index + step]) {
index += step;
step = step << 1;
}

// advance in exponentially shrinking steps.
step = step >> 1;
while step > 0 {
if index + step < slice.len() && function(&slice[index + step]) {
index += step;
}
step = step >> 1;
}

index += 1;
}

index
}
Loading

0 comments on commit 9163a29

Please sign in to comment.