mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
fdbf7eadfb
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
42 lines
1.2 KiB
C++
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
|