sapling/eden/fs/store/SqliteLocalStore.h
Xavier Deguillard fdbf7eadfb store: add telemetry for LocalStore operations
Summary:
We've seen a case where a large `hg update` was taking an absurdly long time in
`ObjectStore::getTree` but the telemetry was showing us that most of the time
wasn't spent fetching trees from Mercurial! The suspicion is that most of the
time was spent in the LocalStore but with no evidence to prove it.

Let's thus add some timing telemetry to various LocalStore read requests to
fill this gap.

Reviewed By: mshroyer

Differential Revision: D46154456

fbshipit-source-id: b439ac48889ed3db71db136ff6c1cc91f48c926a
2023-05-25 15:48:11 -07:00

42 lines
1.2 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.
*/
#pragma once
#include <folly/Synchronized.h>
#include "eden/fs/sqlite/SqliteDatabase.h"
#include "eden/fs/store/LocalStore.h"
namespace facebook::eden {
class EdenStats;
using EdenStatsPtr = RefPtr<EdenStats>;
/** An implementation of LocalStore that stores values in Sqlite.
* SqliteLocalStore is thread safe, allowing reads and writes from
* any thread.
* */
class SqliteLocalStore final : public LocalStore {
public:
explicit SqliteLocalStore(AbsolutePathPiece pathToDb, EdenStatsPtr edenStats);
void open() override;
void close() override;
void clearKeySpace(KeySpace keySpace) override;
void compactKeySpace(KeySpace keySpace) override;
StoreResult get(KeySpace keySpace, folly::ByteRange key) const override;
bool hasKey(KeySpace keySpace, folly::ByteRange key) const override;
void put(KeySpace keySpace, folly::ByteRange key, folly::ByteRange value)
override;
std::unique_ptr<LocalStore::WriteBatch> beginWrite(
size_t bufSize = 0) override;
private:
mutable SqliteDatabase db_;
};
} // namespace facebook::eden