mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
dag: reduce remote lookup calculating "definitely missing" vertexes
Summary: Practically only checking the "root" vertexes is also "correct". Let's do that to reduce some remote lookups. Reviewed By: andll Differential Revision: D30004909 fbshipit-source-id: e46e8ee6b072270b860c5275b13f1e2103ef2b6a
This commit is contained in:
parent
625d413add
commit
c016c76db9
@ -902,11 +902,18 @@ async fn calculate_definitely_unassigned_vertexes(
|
||||
}
|
||||
|
||||
// Sample: heads, roots, and the "middle point" from "remaining".
|
||||
let sample = subdag
|
||||
.roots(remaining.clone())
|
||||
.await?
|
||||
.union(&subdag.heads(remaining.clone()).await?)
|
||||
.union(&remaining.skip((remaining_old_len as u64) / 2).take(1));
|
||||
let sample = if i <= 2 {
|
||||
// But for the first few queries, let's just check the roots.
|
||||
// This could reduce remote lookups, when we only need to
|
||||
// query the roots to rule out all `remaining` vertexes.
|
||||
subdag.roots(remaining.clone()).await?
|
||||
} else {
|
||||
subdag
|
||||
.roots(remaining.clone())
|
||||
.await?
|
||||
.union(&subdag.heads(remaining.clone()).await?)
|
||||
.union(&remaining.skip((remaining_old_len as u64) / 2).take(1))
|
||||
};
|
||||
let sample: Vec<VertexName> = sample.iter().await?.try_collect().await?;
|
||||
let assigned_bools: Vec<bool> = {
|
||||
let ids = this.vertex_id_batch(&sample).await?;
|
||||
|
@ -135,13 +135,13 @@ async fn test_add_heads() {
|
||||
assert_eq!(
|
||||
client.output(),
|
||||
[
|
||||
"resolve names: [K, I, G, F, A], heads: [B]",
|
||||
"resolve names: [H, D, C], heads: [B]"
|
||||
"resolve names: [I, A], heads: [B]",
|
||||
"resolve names: [C], heads: [B]"
|
||||
]
|
||||
);
|
||||
|
||||
client.dag.flush(&["G".into()]).await.unwrap();
|
||||
assert_eq!(client.output(), ["resolve names: [K, I, G, C], heads: [B]"]);
|
||||
assert_eq!(client.output(), ["resolve names: [I, C], heads: [B]"]);
|
||||
|
||||
let mut client = server.client_cloned_data().await;
|
||||
client
|
||||
@ -152,8 +152,8 @@ async fn test_add_heads() {
|
||||
assert_eq!(
|
||||
client.output(),
|
||||
[
|
||||
"resolve names: [G, K, I, H, A], heads: [B]",
|
||||
"resolve names: [F, D, C], heads: [B]"
|
||||
"resolve names: [I, A], heads: [B]",
|
||||
"resolve names: [C], heads: [B]"
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -196,7 +196,7 @@ async fn test_pull_remap() {
|
||||
assert_eq!(
|
||||
client.output(),
|
||||
[
|
||||
"resolve names: [E, B, A], heads: []",
|
||||
"resolve names: [A], heads: []",
|
||||
"resolve names: [C, F], heads: [E]"
|
||||
]
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user