sapling/eden/fs/store/BlobAccess.cpp
Zeyi (Rice) Fan fff1c76996 make open calls from fuse high priority
Summary: This diff bumps the open call from FUSE to High priority (which is higher than any other blob open request atm). This has shown improvement on the user experience of EdenFS when it's importing many other things from other channels (thrift, etc.)

Reviewed By: chadaustin

Differential Revision: D20287389

fbshipit-source-id: 319bc44ef8be5c904d7cf0db7cc2f8be28b4760a
2020-03-17 02:31:25 -07:00

44 lines
1.2 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "eden/fs/store/BlobAccess.h"
#include <folly/MapUtil.h>
#include "eden/fs/model/Blob.h"
#include "eden/fs/store/BlobCache.h"
#include "eden/fs/store/IObjectStore.h"
namespace facebook {
namespace eden {
BlobAccess::BlobAccess(
std::shared_ptr<IObjectStore> objectStore,
std::shared_ptr<BlobCache> blobCache)
: objectStore_{std::move(objectStore)}, blobCache_{std::move(blobCache)} {}
BlobAccess::~BlobAccess() {}
folly::Future<BlobCache::GetResult> BlobAccess::getBlob(
const Hash& hash,
ObjectFetchContext& context,
BlobCache::Interest interest,
ImportPriority priority) {
auto result = blobCache_->get(hash, interest);
if (result.blob) {
return std::move(result);
}
return objectStore_->getBlob(hash, context, priority)
.thenValue([blobCache = blobCache_,
interest](std::shared_ptr<const Blob> blob) {
auto interestHandle = blobCache->insert(blob, interest);
return BlobCache::GetResult{std::move(blob), std::move(interestHandle)};
});
}
} // namespace eden
} // namespace facebook