store: remove reading from the non-Rust datapackstore

Summary:
If the data isn't found in the Rust one, it can't be found in the non-Rust one.
Since the non-Rust one will issue a filesystem rescan, this is a fairly
expensive operation which shows up in strobelight when trying to walk the
entire repo with: `rg --files`.

There is one last place that still use the non-Rust stores and that's as a
fallack for when Mercurial doesn't support CMD_CAT_TREE. Since this has been
supported for a bit, I'll make a followup change to completely get rid of the
non-Rust stores.

Reviewed By: fanzeyi

Differential Revision: D24035451

fbshipit-source-id: acd9741a16f3786796d329a4cddfe4ee435bcad9
This commit is contained in:
Xavier Deguillard 2020-10-02 10:43:21 -07:00 committed by Facebook GitHub Bot
parent 83801357d4
commit 908c037e39

View File

@ -145,22 +145,6 @@ ConstantStringRef unionStoreGet(
(const char*)id.getBytes().data(),
id.getBytes().size()));
}
// A helper function to avoid repeating noisy casts/conversions when
// loading data from a UnionDatapackStore instance. This variant will
// ask the store to rescan and look for changed packs if it encounters
// a missing key.
ConstantStringRef unionStoreGetWithRefresh(
UnionDatapackStore& unionStore,
StringPiece name,
const Hash& id) {
try {
return unionStoreGet(unionStore, name, id);
} catch (const MissingKeyError&) {
unionStore.markForRefresh();
return unionStoreGet(unionStore, name, id);
}
}
} // namespace
HgBackingStore::HgBackingStore(
@ -332,18 +316,12 @@ HgBackingStore::fetchTreeFromHgCacheOrImporter(
RelativePath path,
const std::optional<Hash>& commitId) {
auto writeBatch = localStore_->beginWrite();
try {
if (auto tree = datapackStore_.getTree(
path, manifestNode, edenTreeID, writeBatch.get(), commitId)) {
XLOG(DBG4) << "imported tree node=" << manifestNode << " path=" << path
<< " from Rust hgcache";
return folly::makeFuture(std::move(tree));
}
auto content = unionStoreGetWithRefresh(
*unionStore_->wlock(), path.stringPiece(), manifestNode);
return folly::makeFuture(processTree(
content, manifestNode, edenTreeID, path, commitId, writeBatch.get()));
} catch (const MissingKeyError&) {
if (auto tree = datapackStore_.getTree(
path, manifestNode, edenTreeID, writeBatch.get(), commitId)) {
XLOG(DBG4) << "imported tree node=" << manifestNode << " path=" << path
<< " from Rust hgcache";
return folly::makeFuture(std::move(tree));
} else {
// Data for this tree was not present locally.
// Fall through and fetch the data from the server below.
if (!FLAGS_hg_fetch_missing_trees) {