mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
eden: add experimental:enable-blob-caching
Summary: Adding an experimental option to EdenFS so we can disable blob caching if we need. Reviewed By: chadaustin Differential Revision: D18441665 fbshipit-source-id: 56751c0199d6658bfbf7ec3865f746a7279324ab
This commit is contained in:
parent
46b25acec8
commit
dee0478903
@ -300,6 +300,13 @@ class EdenConfig : private ConfigSettingManager {
|
||||
ConfigSetting<std::string> scribeCategory{"telemetry:scribe-category",
|
||||
"",
|
||||
this};
|
||||
|
||||
/**
|
||||
* Controls whether if EdenFS caches blobs in local store.
|
||||
*/
|
||||
ConfigSetting<bool> enableBlobCaching{"experimental:enable-blob-caching",
|
||||
true,
|
||||
this};
|
||||
};
|
||||
} // namespace eden
|
||||
} // namespace facebook
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "eden/fs/service/EdenServer.h"
|
||||
|
||||
#include <cpptoml.h> // @manual=fbsource//third-party/cpptoml:cpptoml
|
||||
#include <atomic>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@ -623,6 +624,9 @@ void EdenServer::openStorageEngine(
|
||||
ensureDirectoryExists(rocksPath);
|
||||
localStore_ = make_shared<RocksDbLocalStore>(
|
||||
rocksPath, &serverState_->getFaultInjector());
|
||||
localStore_->enableBlobCaching.store(
|
||||
serverState_->getEdenConfig()->enableBlobCaching.getValue(),
|
||||
std::memory_order_relaxed);
|
||||
logger->log(
|
||||
"Opened RocksDB store in ",
|
||||
watch.elapsed().count() / 1000.0,
|
||||
|
@ -190,6 +190,11 @@ BlobMetadata LocalStore::getMetadataFromBlob(const Blob* blob) {
|
||||
}
|
||||
|
||||
void LocalStore::putBlobWithoutMetadata(const Hash& id, const Blob* blob) {
|
||||
if (!enableBlobCaching) {
|
||||
XLOG(DBG4) << "Skipping caching " << id
|
||||
<< " because blob cache is diabled via config";
|
||||
return;
|
||||
}
|
||||
// Since blob serialization is moderately complex, just delegate
|
||||
// the immediate putBlob to the method on the WriteBatch.
|
||||
// Pre-allocate a buffer of approximately the right size; it
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <folly/Range.h>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include "eden/fs/store/BlobMetadata.h"
|
||||
@ -275,6 +276,15 @@ class LocalStore : public std::enable_shared_from_this<LocalStore> {
|
||||
virtual std::unique_ptr<WriteBatch> beginWrite(size_t bufSize = 0) = 0;
|
||||
|
||||
virtual void periodicManagementTask(const EdenConfig& config);
|
||||
|
||||
/*
|
||||
* We keep this field to avoid making `LocalStore` holding a reference to
|
||||
* `EdenConfig`, which will require us to change all the subclasses. We update
|
||||
* this flag through `periodicManagementTask` function. The implication is
|
||||
* that the configuration may need up to 1 minute to propagate (or whatever
|
||||
* the configured local store management interval is).
|
||||
*/
|
||||
std::atomic<bool> enableBlobCaching = true;
|
||||
};
|
||||
} // namespace eden
|
||||
} // namespace facebook
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "eden/fs/store/RocksDbLocalStore.h"
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
|
||||
#include <fb303/ServiceData.h>
|
||||
#include <folly/Format.h>
|
||||
@ -557,6 +558,9 @@ uint64_t RocksDbLocalStore::getApproximateSize(
|
||||
}
|
||||
|
||||
void RocksDbLocalStore::periodicManagementTask(const EdenConfig& config) {
|
||||
enableBlobCaching.store(
|
||||
config.enableBlobCaching.getValue(), std::memory_order_relaxed);
|
||||
|
||||
// Compute and publish the stats
|
||||
auto ephemeralSize = publishStats();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user