mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
dag: benchmark dag_ops on different IdDagStores
Summary: Change dag_ops benchmarks to use different IdDagStores. An example run shows: benchmarking dag::iddagstore::indexedlog_store::IndexedLogStore building segments (old) 856.803 ms building segments (new) 127.831 ms ancestors 54.288 ms children (spans) 619.966 ms children (1 id) 12.596 ms common_ancestors (spans) 3.050 s descendants (small subset) 35.652 ms gca_one (2 ids) 164.296 ms gca_one (spans) 3.132 s gca_all (2 ids) 270.542 ms gca_all (spans) 2.817 s heads 247.504 ms heads_ancestors 40.106 ms is_ancestor 108.719 ms parents 243.317 ms parent_ids 10.752 ms range (2 ids) 7.370 ms range (spans) 23.933 ms roots 620.150 ms benchmarking dag::iddagstore::in_process_store::InProcessStore building segments (old) 790.429 ms building segments (new) 55.007 ms ancestors 8.618 ms children (spans) 196.562 ms children (1 id) 2.488 ms common_ancestors (spans) 545.344 ms descendants (small subset) 8.093 ms gca_one (2 ids) 24.569 ms gca_one (spans) 529.080 ms gca_all (2 ids) 38.462 ms gca_all (spans) 540.486 ms heads 103.930 ms heads_ancestors 6.763 ms is_ancestor 16.208 ms parents 103.889 ms parent_ids 0.822 ms range (2 ids) 1.748 ms range (spans) 6.157 ms roots 197.924 ms benchmarking dag::iddagstore::bytes_store::BytesStore building segments (old) 724.467 ms building segments (new) 90.207 ms ancestors 23.812 ms children (spans) 348.237 ms children (1 id) 4.609 ms common_ancestors (spans) 1.315 s descendants (small subset) 20.819 ms gca_one (2 ids) 72.423 ms gca_one (spans) 1.346 s gca_all (2 ids) 116.025 ms gca_all (spans) 1.470 s heads 155.667 ms heads_ancestors 19.486 ms is_ancestor 51.529 ms parents 157.285 ms parent_ids 5.427 ms range (2 ids) 4.448 ms range (spans) 13.874 ms roots 365.568 ms Overall, InProcessStore > BytesStore > IndexedLogStore. The InProcessStore uses `Vec<BTreeMap<Id, StoreId>>` for the level-head index, which is more efficient on the "Level" lookup (Vec), and more cache efficient (BTree). BytesStore outperforms IndexedLogStore because it does not need to verify checksum on every read access - the checksum was verified at store creation (IdDag::from_bytes). Note: The `BytesStore` is something optimized for serialization, and hasn't been sent. Reviewed By: sfilipco Differential Revision: D23438174 fbshipit-source-id: 6e5f15188e3b935659ccde25fac573e9b963b78f
This commit is contained in:
parent
84ad7a5351
commit
99511f8743
@ -5,6 +5,8 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use dag::iddagstore::GetLock;
|
||||
use dag::iddagstore::IdDagStore;
|
||||
use dag::idmap::IdMapAssignHead;
|
||||
use dag::idmap::IdMapBuildParents;
|
||||
use dag::namedag::NameDag;
|
||||
@ -16,6 +18,16 @@ use minibench::{bench, elapsed};
|
||||
use tempfile::tempdir;
|
||||
|
||||
fn main() {
|
||||
let dag_dir = tempdir().unwrap();
|
||||
|
||||
bench_with_iddag(|| IdDag::open(&dag_dir.path()).unwrap());
|
||||
bench_with_iddag(|| IdDag::new_in_process());
|
||||
|
||||
bench_many_heads_namedag();
|
||||
}
|
||||
|
||||
fn bench_with_iddag<S: IdDagStore + GetLock>(get_empty_iddag: impl Fn() -> IdDag<S>) {
|
||||
println!("benchmarking {}", std::any::type_name::<S>());
|
||||
let parents = bindag::parse_bindag(bindag::MOZILLA);
|
||||
|
||||
let head_name = VertexName::copy_from(format!("{}", parents.len() - 1).as_bytes());
|
||||
@ -39,10 +51,8 @@ fn main() {
|
||||
let head_id = id_map.find_id_by_name(head_name.as_ref()).unwrap().unwrap();
|
||||
let parents_by_id = id_map.build_get_parents_by_id(&parents_by_name);
|
||||
|
||||
let dag_dir = tempdir().unwrap();
|
||||
|
||||
bench("building segments (old)", || {
|
||||
let mut dag = IdDag::open(&dag_dir.path()).unwrap();
|
||||
let mut dag = get_empty_iddag();
|
||||
elapsed(|| {
|
||||
dag.build_segments_volatile(head_id, &parents_by_id)
|
||||
.unwrap();
|
||||
@ -50,7 +60,7 @@ fn main() {
|
||||
});
|
||||
|
||||
bench("building segments (new)", || {
|
||||
let mut dag = IdDag::open(&dag_dir.path()).unwrap();
|
||||
let mut dag = get_empty_iddag();
|
||||
elapsed(|| {
|
||||
dag.build_segments_volatile_from_assign_head_outcome(&outcome)
|
||||
.unwrap();
|
||||
@ -58,12 +68,12 @@ fn main() {
|
||||
});
|
||||
|
||||
// Write segments to filesystem.
|
||||
let mut dag = IdDag::open(&dag_dir.path()).unwrap();
|
||||
let mut dag = get_empty_iddag();
|
||||
let mut syncable = dag.prepare_filesystem_sync().unwrap();
|
||||
syncable
|
||||
.build_segments_persistent(head_id, &parents_by_id)
|
||||
.unwrap();
|
||||
syncable.sync(std::iter::once(&mut dag)).unwrap();
|
||||
syncable.sync().unwrap();
|
||||
|
||||
let sample_two_ids: Vec<SpanSet> = (0..parents.len() as u64)
|
||||
.step_by(10079)
|
||||
@ -228,7 +238,10 @@ fn main() {
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn bench_many_heads_namedag() {
|
||||
println!("benchmarking NameDag with many heads");
|
||||
// Create a graph with M linear vertexes in the master branch, and M
|
||||
// child for every vertex in the master branch.
|
||||
//
|
||||
|
@ -18,7 +18,7 @@ pub mod errors;
|
||||
mod fmt;
|
||||
pub mod id;
|
||||
mod iddag;
|
||||
mod iddagstore;
|
||||
pub mod iddagstore;
|
||||
pub mod idmap;
|
||||
pub mod namedag;
|
||||
pub mod nameset;
|
||||
|
Loading…
Reference in New Issue
Block a user