Skip to content

Commit ecc972b

Browse files
xavierdfacebook-github-bot
authored andcommitted
store: add support for aux data in hg import queue
Summary: As a first step towards enabling aux data fetching, we need to allow aux data to be batch fetched. Reviewed By: chadaustin Differential Revision: D44110105 fbshipit-source-id: f9c3f55ffdc5554784b5f38457ef675689664263
1 parent 838419f commit ecc972b

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

eden/fs/config/EdenConfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,15 @@ class EdenConfig : private ConfigSettingManager {
667667
1,
668668
this};
669669

670+
/**
671+
* Controls the max number of blob metadata import requests we batch in
672+
* HgBackingStore
673+
*/
674+
ConfigSetting<uint32_t> importBatchSizeBlobMeta{
675+
"hg:import-batch-size-blobmeta",
676+
1024,
677+
this};
678+
670679
/**
671680
* Whether fetching trees should fall back on an external hg importer process.
672681
*/

eden/fs/store/hg/HgImportRequest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ std::shared_ptr<HgImportRequest> HgImportRequest::makeTreeImportRequest(
5555
return makeRequest<TreeImport>(priority, cause, hash, proxyHash);
5656
}
5757

58+
std::shared_ptr<HgImportRequest> HgImportRequest::makeBlobMetaImportRequest(
59+
const ObjectId& hash,
60+
const HgProxyHash& proxyHash,
61+
ImportPriority priority,
62+
ObjectFetchContext::Cause cause) {
63+
return makeRequest<BlobMetaImport>(priority, cause, hash, proxyHash);
64+
}
65+
5866
} // namespace facebook::eden

eden/fs/store/hg/HgImportRequest.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ class HgImportRequest {
5656
std::vector<folly::Promise<Response>> promises;
5757
};
5858

59+
struct BlobMetaImport {
60+
using Response = std::unique_ptr<BlobMetadata>;
61+
BlobMetaImport(ObjectId hash, HgProxyHash proxyHash)
62+
: hash{std::move(hash)}, proxyHash{std::move(proxyHash)} {}
63+
64+
ObjectId hash;
65+
HgProxyHash proxyHash;
66+
67+
// See the comment above for BlobImport::promises
68+
std::vector<folly::Promise<Response>> promises;
69+
};
70+
5971
/**
6072
* Allocate a blob request.
6173
*/
@@ -74,6 +86,12 @@ class HgImportRequest {
7486
ImportPriority priority,
7587
ObjectFetchContext::Cause cause);
7688

89+
static std::shared_ptr<HgImportRequest> makeBlobMetaImportRequest(
90+
const ObjectId& hash,
91+
const HgProxyHash& proxyHash,
92+
ImportPriority priority,
93+
ObjectFetchContext::Cause cause);
94+
7795
/**
7896
* Implementation detail of the make*Request functions from above. Do not use
7997
* directly.
@@ -147,10 +165,11 @@ class HgImportRequest {
147165
HgImportRequest(const HgImportRequest&) = delete;
148166
HgImportRequest& operator=(const HgImportRequest&) = delete;
149167

150-
using Request = std::variant<BlobImport, TreeImport>;
168+
using Request = std::variant<BlobImport, TreeImport, BlobMetaImport>;
151169
using Response = std::variant<
152170
folly::Promise<std::unique_ptr<Blob>>,
153-
folly::Promise<std::unique_ptr<Tree>>>;
171+
folly::Promise<std::unique_ptr<Tree>>,
172+
folly::Promise<std::unique_ptr<BlobMetadata>>>;
154173

155174
Request request_;
156175
ImportPriority priority_;

eden/fs/store/hg/HgImportRequestQueue.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ folly::Future<std::unique_ptr<Tree>> HgImportRequestQueue::enqueueTree(
3333
std::move(request));
3434
}
3535

36+
folly::Future<std::unique_ptr<BlobMetadata>>
37+
HgImportRequestQueue::enqueueBlobMeta(
38+
std::shared_ptr<HgImportRequest> request) {
39+
return enqueue<
40+
std::unique_ptr<BlobMetadata>,
41+
HgImportRequest::BlobMetaImport>(std::move(request));
42+
}
43+
3644
template <typename Ret, typename ImportType>
3745
folly::Future<Ret> HgImportRequestQueue::enqueue(
3846
std::shared_ptr<HgImportRequest> request) {
@@ -41,6 +49,10 @@ folly::Future<Ret> HgImportRequestQueue::enqueue(
4149
std::vector<std::shared_ptr<HgImportRequest>>* queue;
4250
if constexpr (std::is_same_v<ImportType, HgImportRequest::BlobImport>) {
4351
queue = &state->blobQueue;
52+
} else if constexpr (std::is_same_v<
53+
ImportType,
54+
HgImportRequest::BlobMetaImport>) {
55+
queue = &state->blobMetaQueue;
4456
} else {
4557
static_assert(std::is_same_v<ImportType, HgImportRequest::TreeImport>);
4658
queue = &state->treeQueue;
@@ -97,19 +109,26 @@ HgImportRequestQueue::combineAndClearRequestQueues() {
97109
auto state = state_.lock();
98110
auto treeQSz = state->treeQueue.size();
99111
auto blobQSz = state->blobQueue.size();
112+
auto blobMetaQSz = state->blobMetaQueue.size();
100113
XLOGF(
101114
DBG5,
102-
"combineAndClearRequestQueues: tree queue size = {}, blob queue size = {}",
115+
"combineAndClearRequestQueues: tree queue size = {}, blob queue size = {}, blob metadata queue size = {}",
103116
treeQSz,
104-
blobQSz);
117+
blobQSz,
118+
blobMetaQSz);
105119
auto res = std::move(state->treeQueue);
106120
res.insert(
107121
res.end(),
108122
std::make_move_iterator(state->blobQueue.begin()),
109123
std::make_move_iterator(state->blobQueue.end()));
124+
res.insert(
125+
res.end(),
126+
std::make_move_iterator(state->blobMetaQueue.begin()),
127+
std::make_move_iterator(state->blobMetaQueue.end()));
110128
state->treeQueue.clear();
111129
state->blobQueue.clear();
112-
XCHECK_EQ(res.size(), treeQSz + blobQSz);
130+
state->blobMetaQueue.clear();
131+
XCHECK_EQ(res.size(), treeQSz + blobQSz + blobMetaQSz);
113132
return res;
114133
}
115134

@@ -122,6 +141,7 @@ std::vector<std::shared_ptr<HgImportRequest>> HgImportRequestQueue::dequeue() {
122141
if (!state->running) {
123142
state->treeQueue.clear();
124143
state->blobQueue.clear();
144+
state->blobMetaQueue.clear();
125145
return std::vector<std::shared_ptr<HgImportRequest>>();
126146
}
127147

@@ -137,6 +157,15 @@ std::vector<std::shared_ptr<HgImportRequest>> HgImportRequestQueue::dequeue() {
137157
queue = &state->treeQueue;
138158
}
139159

160+
if (!state->blobMetaQueue.empty()) {
161+
auto priority = state->blobMetaQueue.front()->getPriority();
162+
if (!queue || priority > highestPriority) {
163+
queue = &state->blobMetaQueue;
164+
count = config_->getEdenConfig()->importBatchSizeBlobMeta.getValue();
165+
highestPriority = priority;
166+
}
167+
}
168+
140169
if (!state->blobQueue.empty()) {
141170
auto priority = state->blobQueue.front()->getPriority();
142171
if (!queue || priority > highestPriority) {

eden/fs/store/hg/HgImportRequestQueue.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ class HgImportRequestQueue {
4242
folly::Future<std::unique_ptr<Tree>> enqueueTree(
4343
std::shared_ptr<HgImportRequest> request);
4444

45+
/**
46+
* Enqueue an aux data request to the queue.
47+
*
48+
* Return a future that will complete when the aux data request completes.
49+
*/
50+
folly::Future<std::unique_ptr<BlobMetadata>> enqueueBlobMeta(
51+
std::shared_ptr<HgImportRequest> request);
52+
4553
/**
4654
* Returns a list of requests from the queue. It returns an empty list while
4755
* the queue is being destructed. This function will block when there is no
@@ -87,6 +95,10 @@ class HgImportRequestQueue {
8795
if constexpr (std::is_same_v<T, Tree>) {
8896
auto* treeImport = import->getRequest<HgImportRequest::TreeImport>();
8997
promises = &treeImport->promises;
98+
} else if constexpr (std::is_same_v<T, BlobMetadata>) {
99+
auto* blobMetaImport =
100+
import->getRequest<HgImportRequest::BlobMetaImport>();
101+
promises = &blobMetaImport->promises;
90102
} else {
91103
static_assert(
92104
std::is_same_v<T, Blob>,
@@ -130,6 +142,7 @@ class HgImportRequestQueue {
130142
bool running = true;
131143
std::vector<std::shared_ptr<HgImportRequest>> treeQueue;
132144
std::vector<std::shared_ptr<HgImportRequest>> blobQueue;
145+
std::vector<std::shared_ptr<HgImportRequest>> blobMetaQueue;
133146

134147
/**
135148
* Map of a ObjectId to an element in the queue. Any changes to this type

0 commit comments

Comments
 (0)