Skip to content

Commit 184dbbe

Browse files
muirdmfacebook-github-bot
authored andcommitted
scmstore: fix propagation of CAS aux data to EdenFS
Summary: Fix DynTree trait impl to support propagating AUX data received from CAS tree entries. Make use of LazyTree::children_aux_data, which already abstracts across the different sources of tree data. When EdenFS fetches trees via Sapling, it will also make use of aux data for the tree entries when available. genevievehelsel discovered the aux data was not making it when Sapling was configured to fetch data from the CAS backend. This hurts performance because eden's caches are not warmed with aux data. The CAS trees _should_ be warm in the local cache, so fetching aux data subsequently should not trigger a remote fetch. Reviewed By: liubov-dmitrieva Differential Revision: D71522121 fbshipit-source-id: b58bb7920941f95f359f75dd2976b185aac40133
1 parent 940574c commit 184dbbe

2 files changed

Lines changed: 26 additions & 49 deletions

File tree

eden/scm/lib/revisionstore/src/scmstore/tree.rs

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use clientinfo::get_client_request_info_thread_local;
3030
use clientinfo::set_client_request_info_thread_local;
3131
use edenapi_types::FileAuxData;
3232
use edenapi_types::TreeAuxData;
33-
use edenapi_types::TreeChildEntry;
3433
use fetch::FetchState;
3534
use flume::bounded;
3635
use flume::unbounded;
@@ -44,6 +43,7 @@ use storemodel::InsertOpts;
4443
use storemodel::KeyStore;
4544
use storemodel::SerializationFormat;
4645
use storemodel::TreeEntry;
46+
use types::AuxData;
4747

4848
use crate::datastore::HgIdDataStore;
4949
use crate::historystore::HistoryStore;
@@ -833,58 +833,29 @@ impl TreeEntry for ScmStoreTreeEntry {
833833
}
834834

835835
fn file_aux_iter(&self) -> anyhow::Result<BoxIterator<anyhow::Result<(HgId, FileAuxData)>>> {
836-
let maybe_iter = (move || -> Option<BoxIterator<anyhow::Result<(HgId, FileAuxData)>>> {
837-
let entry = match &self.tree {
838-
LazyTree::SaplingRemoteApi(entry) => entry.clone(),
839-
_ => return None,
840-
};
841-
let children = entry.children?;
842-
let iter = children.into_iter().filter_map(move |child| {
843-
let child = child.as_ref().ok()?;
844-
let file_entry = match child {
845-
TreeChildEntry::File(v) => v,
846-
_ => return None,
847-
};
848-
Some(Ok((
849-
file_entry.key.hgid,
850-
file_entry.file_metadata.clone()?.into(),
851-
)))
852-
});
853-
Some(Box::new(iter))
854-
})();
855-
Ok(maybe_iter.unwrap_or_else(|| Box::new(std::iter::empty())))
836+
Ok(Box::new(
837+
self.tree
838+
.children_aux_data()
839+
.into_iter()
840+
.filter_map(|(hgid, aux)| match aux {
841+
AuxData::File(file_aux_data) => Some(Ok((hgid, file_aux_data))),
842+
AuxData::Tree(_) => None,
843+
}),
844+
))
856845
}
857846

858847
fn tree_aux_data_iter(
859848
&self,
860849
) -> anyhow::Result<BoxIterator<anyhow::Result<(HgId, TreeAuxData)>>> {
861-
let maybe_iter = (|| -> Option<BoxIterator<anyhow::Result<(HgId, TreeAuxData)>>> {
862-
let entry = match &self.tree {
863-
LazyTree::SaplingRemoteApi(entry) => entry.clone(),
864-
// TODO: We should also support fetching tree metadata from local cache
865-
_ => return None,
866-
};
867-
let children = entry.children?;
868-
let iter = children.into_iter().filter_map(|child| {
869-
let child = child.as_ref().ok()?;
870-
let directory_entry = match child {
871-
TreeChildEntry::Directory(v) => v,
872-
_ => return None,
873-
};
874-
let tree_aux_data = directory_entry
875-
.tree_aux_data
876-
.ok_or_else(|| {
877-
anyhow::anyhow!(format!(
878-
"tree aux data is missing for key: {}",
879-
directory_entry.key
880-
))
881-
})
882-
.ok()?;
883-
Some(Ok((directory_entry.key.hgid, tree_aux_data)))
884-
});
885-
Some(Box::new(iter))
886-
})();
887-
Ok(maybe_iter.unwrap_or_else(|| Box::new(std::iter::empty())))
850+
Ok(Box::new(
851+
self.tree
852+
.children_aux_data()
853+
.into_iter()
854+
.filter_map(|(hgid, aux)| match aux {
855+
AuxData::File(_) => None,
856+
AuxData::Tree(tree_aux_data) => Some(Ok((hgid, tree_aux_data))),
857+
}),
858+
))
888859
}
889860

890861
/// Get the directory aux data of the tree.

eden/scm/tests/test-scmstore-storemodel-aux-data.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
#testcases cas no-cas
12

3+
#if cas
24
$ setconfig scmstore.cas-mode=on
5+
#else
6+
$ setconfig scmstore.cas-mode=off
7+
#endif
38

49
$ setconfig push.edenapi=true
510
$ setconfig scmstore.tree-metadata-mode=always
@@ -21,9 +26,10 @@ First fetch aux data for root dir (needed to for subsequent fetch).
2126
$ hg debugscmstore --mode tree -r $A "" >/dev/null
2227

2328
--store-model uses the storemodel trait (which is what EdenFS uses)
24-
FIXME: missing aux data
2529
$ hg debugscmstore --mode tree -r $A "dir" --store-model
2630
Tree 'dir' entries
2731
(PathComponentBuf("bar"), HgId("a324b8bf63f7d56de9d36f8747e3b68a72a4d968"), File(Regular))
2832
(PathComponentBuf("foo"), HgId("49d8cbb15ce257920447006b46978b7af980a979"), File(Regular))
2933
Tree 'dir' file aux
34+
(HgId("a324b8bf63f7d56de9d36f8747e3b68a72a4d968"), FileAuxData { total_size: 3, sha1: Sha1("62cdb7020ff920e5aa642c3d4066950dd1f01f4d"), blake3: Blake3("0f6cb4c2a4c391b24fdbb4023e5d8c9ad7fbadaecfdc69cc801cf9d08dffd32a"), file_header_metadata: Some(b"") })
35+
(HgId("49d8cbb15ce257920447006b46978b7af980a979"), FileAuxData { total_size: 3, sha1: Sha1("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"), blake3: Blake3("29b9cb87c1ac3fd85f385e97eed4ba6b0bc64435cc1985815d2bef6cde472233"), file_header_metadata: Some(b"") })

0 commit comments

Comments
 (0)