sapling/eden/integration/helpers/ZeroBlob.cpp
Chad Austin d0ce25afba log to scuba upon automatic gc
Summary:
A spike in automatic GCs usually implies something has gone wrong. Log
an event for each one, recording the cache size prior to the GC and
the cache size after.

Reviewed By: simpkins

Differential Revision: D18902580

fbshipit-source-id: 158b2635733a415a9fcc7c412b2c0f44ed04aa01
2019-12-10 16:16:35 -08:00

54 lines
1.6 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 <sysexits.h>
#include <folly/init/Init.h>
#include <folly/logging/Init.h>
#include <folly/logging/xlog.h>
#include <gflags/gflags.h>
#include "eden/fs/model/Blob.h"
#include "eden/fs/model/Hash.h"
#include "eden/fs/store/RocksDbLocalStore.h"
#include "eden/fs/telemetry/NullStructuredLogger.h"
#include "eden/fs/utils/FaultInjector.h"
DEFINE_string(edenDir, "", "The path to the .eden directory");
DEFINE_string(blobID, "", "The blob ID");
FOLLY_INIT_LOGGING_CONFIG("eden=DBG2");
constexpr folly::StringPiece kRocksDBPath{"storage/rocks-db"};
using namespace facebook::eden;
using folly::IOBuf;
/*
* This tool rewrites a specific blob in Eden's local store with empty contents.
* This is intended for use in integration tests that exercise the behavior
* with bogus blob contents in the LocalStore.
*/
int main(int argc, char* argv[]) {
folly::init(&argc, &argv);
if (FLAGS_edenDir.empty()) {
fprintf(stderr, "error: the --edenDir argument is required\n");
return EX_USAGE;
}
Hash blobID(FLAGS_blobID);
auto edenDir = facebook::eden::canonicalPath(FLAGS_edenDir);
const auto rocksPath = edenDir + RelativePathPiece{kRocksDBPath};
FaultInjector faultInjector(/*enabled=*/false);
RocksDbLocalStore localStore(
rocksPath, std::make_shared<NullStructuredLogger>(), &faultInjector);
Blob blob(blobID, IOBuf());
localStore.putBlob(blobID, &blob);
return EX_OK;
}