sapling/eden/fs/store/KeySpace.h
Andrey Chursin 008167cb0e deprecate scs proxy hash
Summary:
The tree metadata fetching evolution goes as follow
(1) (commit, path) scs query
(2) tree manifest scs query [we are here]
(3) eden api manifest query [in development]

Option (1) is no longer used and is the only placed that required scs proxy hash.
Removing it will simplify transition from (2) to (3) and also cleans up bunch of unused code.

It also comes with minor performance improvement, saving about 5% on file access time.
To be precise, this is measured by running fsprobe [this is probably too little to measure in high noise benchmark like running arc focus]:
```
fsprobe.sh run cat.targets --parallel 24
```

Results:
```
W/ scshash:
P24: 0.1044 0.1007 0.1005 (hot) 0.1019 avg

W/o scshash:
P24: 0.0954 0.0964 0.1008 (hot) 0.0975 avg
```

This performance improvement comes from the fact, that even though scs hash was never created or used, we still attempted to load it from scs table, and even though this load always failed it contributed to execution time.

Reviewed By: xavierd

Differential Revision: D30942663

fbshipit-source-id: af84f1e5658e7d8d9fb6853cbb88f02b49cd050b
2021-09-14 19:52:15 -07:00

123 lines
3.3 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.
*/
#pragma once
#include <folly/Range.h>
#include <variant>
#include "eden/fs/config/EdenConfig.h"
namespace facebook::eden {
/**
* Indicates the key space is safe to clear at any moment. The key space's disk
* usage should be kept under the size specified by `cacheLimit`.
*/
struct Ephemeral {
ConfigSetting<uint64_t> EdenConfig::*cacheLimit;
};
/**
* Indicates the key space contains persistent data and should never be cleared.
*/
struct Persistent {};
/**
* The key space is no longer used. It should be cleared on startup.
*/
struct Deprecated {};
using Persistence = std::variant<Ephemeral, Persistent, Deprecated>;
/**
* Which key space (and thus column family for the RocksDbLocalStore) should be
* used to store a specific key. The `name` value must be stable across builds
* as it is used to identify the table names in RocksDbLocalStore and
* SqliteLocalStore.
*/
struct KeySpaceRecord {
uint8_t index;
folly::StringPiece name;
Persistence persistence;
constexpr bool isEphemeral() const noexcept {
return std::holds_alternative<Ephemeral>(persistence);
}
constexpr bool isDeprecated() const noexcept {
return std::holds_alternative<Deprecated>(persistence);
}
};
class KeySpace {
public:
/* implicit */ constexpr KeySpace(const KeySpaceRecord& record)
: record_{&record} {}
/* implicit */ KeySpace(const KeySpaceRecord* record) : record_{record} {
XCHECK_NE(record, nullptr);
}
constexpr const KeySpaceRecord* operator->() const {
return record_;
}
static constexpr KeySpaceRecord BlobFamily{
0,
"blob",
Ephemeral{&EdenConfig::localStoreBlobSizeLimit}};
static constexpr KeySpaceRecord BlobMetaDataFamily{
1,
"blobmeta",
Ephemeral{&EdenConfig::localStoreBlobMetaSizeLimit}};
static constexpr KeySpaceRecord TreeFamily{
2,
"tree",
Ephemeral{&EdenConfig::localStoreTreeSizeLimit}};
// Proxy hashes are required to fetch objects from hg from a hash.
// Deleting them breaks re-importing after an inode is unloaded.
static constexpr KeySpaceRecord HgProxyHashFamily{
3,
"hgproxyhash",
Persistent{}};
static constexpr KeySpaceRecord HgCommitToTreeFamily{
4,
"hgcommit2tree",
Ephemeral{&EdenConfig::localStoreHgCommit2TreeSizeLimit}};
static constexpr KeySpaceRecord BlobSizeFamily{5, "blobsize", Deprecated{}};
static constexpr KeySpaceRecord ScsProxyHashFamily{
6,
"scsproxyhash",
Deprecated{}};
static constexpr KeySpaceRecord TreeMetaDataFamily{
7,
"treemeta",
Ephemeral{&EdenConfig::localStoreTreeMetaSizeLimit}};
static constexpr KeySpaceRecord ReCasDigestProxyHashFamily{
8,
"recasdigestproxyhash",
Persistent{}};
static constexpr const KeySpaceRecord* kAll[] = {
&BlobFamily,
&BlobMetaDataFamily,
&TreeFamily,
&HgProxyHashFamily,
&HgCommitToTreeFamily,
&BlobSizeFamily,
&ScsProxyHashFamily,
&TreeMetaDataFamily,
&ReCasDigestProxyHashFamily};
static constexpr size_t kTotalCount = std::size(kAll);
private:
const KeySpaceRecord* record_;
};
} // namespace facebook::eden