mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
4e1f60fc24
Summary: In addition to duration and success, log object fetch counts and checkout type to Scuba. Reviewed By: fanzeyi Differential Revision: D19334276 fbshipit-source-id: dabf52427f2ebda2b58df93194df39d52f4fcb4f
64 lines
1.4 KiB
C++
64 lines
1.4 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 <atomic>
|
|
#include "eden/fs/store/IObjectStore.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
struct FetchStatistics {
|
|
struct Access {
|
|
/**
|
|
* Total number of object accesses, including cache hits.
|
|
*/
|
|
uint64_t accessCount = 0;
|
|
|
|
/**
|
|
* Number of object fetches from the backing store.
|
|
*/
|
|
uint64_t fetchCount = 0;
|
|
|
|
/**
|
|
* In range [0, 100]. unsigned char is big enough, but prints as a
|
|
* character.
|
|
*/
|
|
unsigned short cacheHitRate = 0;
|
|
};
|
|
|
|
Access tree;
|
|
Access blob;
|
|
Access metadata;
|
|
};
|
|
|
|
class StatsFetchContext : public ObjectFetchContext {
|
|
public:
|
|
StatsFetchContext() = default;
|
|
StatsFetchContext(const StatsFetchContext& other);
|
|
|
|
void didFetch(ObjectType type, const Hash& id, Origin origin) override;
|
|
|
|
uint64_t countFetchesOfType(ObjectType type) const;
|
|
uint64_t countFetchesOfTypeAndOrigin(ObjectType type, Origin origin) const;
|
|
|
|
FetchStatistics computeStatistics() const;
|
|
|
|
/**
|
|
* Sums the counts from another fetch context into this one.
|
|
*/
|
|
void merge(const StatsFetchContext& other);
|
|
|
|
private:
|
|
std::atomic<uint64_t> counts_[ObjectFetchContext::kObjectTypeEnumMax]
|
|
[ObjectFetchContext::kOriginEnumMax] = {};
|
|
};
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|