mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
5da3dec645
Summary: Bring back readdir prefetching, which was disabled as part of the edenapi aux metadata rollout, and tighten up its logic to accelerate specific use cases. To optimize `find .`, prefetch subtrees when a subtree is stat(). To optimize `find . -empty`, prefetch blob metadata when a file is stat(). Add a config knob to opt out of blob prefetching, tree prefetching, or both. Reviewed By: xavierd Differential Revision: D41701675 fbshipit-source-id: 29b9c28f0f09cf686e3f256bd8c993e9b466e012
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include "eden/fs/config/ReaddirPrefetch.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
namespace {
|
|
|
|
constexpr auto readdirPrefetchStr = [] {
|
|
std::array<folly::StringPiece, 4> mapping{};
|
|
mapping[folly::to_underlying(ReaddirPrefetch::None)] = "none";
|
|
mapping[folly::to_underlying(ReaddirPrefetch::Files)] = "files";
|
|
mapping[folly::to_underlying(ReaddirPrefetch::Trees)] = "trees";
|
|
mapping[folly::to_underlying(ReaddirPrefetch::Both)] = "both";
|
|
return mapping;
|
|
}();
|
|
|
|
}
|
|
|
|
folly::Expected<ReaddirPrefetch, std::string>
|
|
FieldConverter<ReaddirPrefetch>::fromString(
|
|
folly::StringPiece value,
|
|
const std::map<std::string, std::string>& /*unused*/) const {
|
|
for (auto i = 0ul; i < readdirPrefetchStr.size(); i++) {
|
|
if (value.equals(readdirPrefetchStr[i], folly::AsciiCaseInsensitive())) {
|
|
return static_cast<ReaddirPrefetch>(i);
|
|
}
|
|
}
|
|
|
|
return folly::makeUnexpected(
|
|
fmt::format("Failed to convert value '{}' to a ReaddirPrefetch.", value));
|
|
}
|
|
|
|
std::string FieldConverter<ReaddirPrefetch>::toDebugString(
|
|
ReaddirPrefetch value) const {
|
|
return readdirPrefetchStr[folly::to_underlying(value)].str();
|
|
}
|
|
|
|
} // namespace facebook::eden
|