-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from fjall-rs/2.5.0
2.5.0
- Loading branch information
Showing
66 changed files
with
1,771 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use lsm_tree::merge::{BoxedIterator, Merger}; | ||
use lsm_tree::{mvcc_stream::MvccStream, InternalValue, Memtable}; | ||
use nanoid::nanoid; | ||
|
||
fn merger(c: &mut Criterion) { | ||
for num in [2, 4, 8, 16, 30] { | ||
c.bench_function(&format!("Merge {num}"), |b| { | ||
let memtables = (0..num) | ||
.map(|_| { | ||
let table = Memtable::default(); | ||
|
||
for _ in 0..100 { | ||
table.insert(InternalValue::from_components( | ||
nanoid!(), | ||
vec![], | ||
0, | ||
lsm_tree::ValueType::Value, | ||
)); | ||
} | ||
|
||
table | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
b.iter_with_large_drop(|| { | ||
let iters = memtables | ||
.iter() | ||
.map(|x| x.iter().map(Ok)) | ||
.map(|x| Box::new(x) as BoxedIterator<'_>) | ||
.collect(); | ||
|
||
let merger = Merger::new(iters); | ||
|
||
assert_eq!(num * 100, merger.count()); | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
fn mvcc_stream(c: &mut Criterion) { | ||
for num in [2, 4, 8, 16, 30] { | ||
c.bench_function(&format!("MVCC stream {num} versions"), |b| { | ||
let memtables = (0..num) | ||
.map(|_| { | ||
let table = Memtable::default(); | ||
|
||
for key in 'a'..='z' { | ||
table.insert(InternalValue::from_components( | ||
key.to_string(), | ||
vec![], | ||
num, | ||
lsm_tree::ValueType::Value, | ||
)); | ||
} | ||
|
||
table | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
b.iter_with_large_drop(|| { | ||
let iters = memtables | ||
.iter() | ||
.map(|x| x.iter().map(Ok)) | ||
.map(|x| Box::new(x) as BoxedIterator<'_>) | ||
.collect(); | ||
|
||
let merger = MvccStream::new(Merger::new(iters)); | ||
|
||
assert_eq!(26, merger.count()); | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
criterion_group!(benches, merger, mvcc_stream); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.