Skip to content

Commit

Permalink
add local/ remote counters for SaplingBackingStore stats
Browse files Browse the repository at this point in the history
Summary:
`getTree()`, `getRoorTree()`, `importManifestForRoot()`, `getBlob()`, `getBlobMetdata()` All of these functions get data from local or fom remote backing store. This diff add new counters to count the number of local/remote access which are happening for each of these functions.

## Note
This doc explains all the SaplingBackingStore ODS counters/duration after this stack changes: https://docs.google.com/document/d/1o355e8JGvq3fBYFD738Jkx9tPSWzH4bmxcM8YRKMziU/edit?usp=sharing

Reviewed By: jdelliot

Differential Revision: D56555571

fbshipit-source-id: a330bd3656d6cc7ec28a2b3dbcc835340910d592
  • Loading branch information
kavehahmadi60 authored and facebook-github-bot committed May 14, 2024
1 parent 958c434 commit 8f7b0b4
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 96 deletions.
6 changes: 6 additions & 0 deletions eden/fs/store/BackingStoreLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ void BackingStoreLogger::logImport(
case ObjectFetchContext::ObjectType::Tree:
typeString = "Tree";
break;
case ObjectFetchContext::RootTree:
typeString = "Root Tree";
break;
case ObjectFetchContext::ManifestForRoot:
typeString = "Manifest For Root";
break;
case ObjectFetchContext::ObjectType::kObjectTypeEnumMax:
// invalid string prolly good here
break;
Expand Down
39 changes: 38 additions & 1 deletion eden/fs/store/ObjectFetchContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "eden/common/os/ProcessId.h"
#include "eden/common/utils/RefPtr.h"
#include "eden/fs/store/ImportPriority.h"
#include "eden/fs/telemetry/EdenStats.h"

namespace facebook::eden {

Expand All @@ -38,6 +39,8 @@ class ObjectFetchContext : public RefCounted {
Blob,
BlobMetadata,
Tree,
RootTree,
ManifestForRoot,
kObjectTypeEnumMax,
};

Expand Down Expand Up @@ -109,7 +112,15 @@ class ObjectFetchContext : public RefCounted {
return kDefaultImportPriority;
}

void setFetchedSource(FetchedSource fetchedSource) {
void setFetchedSource(
FetchedSource fetchedSource,
ObjectType type,
EdenStatsPtr stats) {
// There is no stat increment for FetchedSource::Unknown
if (saplingStatsMap_.find({fetchedSource, type}) !=
saplingStatsMap_.end()) {
stats->increment(saplingStatsMap_[{fetchedSource, type}]);
}
fetchedSource_ = fetchedSource;
}

Expand Down Expand Up @@ -161,6 +172,32 @@ class ObjectFetchContext : public RefCounted {
ObjectFetchContext& operator=(const ObjectFetchContext&) = delete;

FetchedSource fetchedSource_{FetchedSource::Unknown};

std::unordered_map<
std::tuple<FetchedSource, ObjectType>,
StatsGroupBase::Counter SaplingBackingStoreStats::*>
saplingStatsMap_ = {
{{FetchedSource::Local, ObjectType::Tree},
&SaplingBackingStoreStats::fetchTreeLocal},
{{FetchedSource::Remote, ObjectType::Tree},
&SaplingBackingStoreStats::fetchTreeRemote},
{{FetchedSource::Local, ObjectType::RootTree},
&SaplingBackingStoreStats::getRootTreeLocal},
{{FetchedSource::Remote, ObjectType::RootTree},
&SaplingBackingStoreStats::getRootTreeRemote},
{{FetchedSource::Local, ObjectType::ManifestForRoot},
&SaplingBackingStoreStats::importManifestForRootLocal},
{{FetchedSource::Remote, ObjectType::ManifestForRoot},
&SaplingBackingStoreStats::importManifestForRootRemote},
{{FetchedSource::Local, ObjectType::Blob},
&SaplingBackingStoreStats::fetchBlobLocal},
{{FetchedSource::Remote, ObjectType::Blob},
&SaplingBackingStoreStats::fetchBlobRemote},
{{FetchedSource::Local, ObjectType::BlobMetadata},
&SaplingBackingStoreStats::fetchBlobMetadataLocal},
{{FetchedSource::Remote, ObjectType::BlobMetadata},
&SaplingBackingStoreStats::fetchBlobMetadataRemote},
};
};

// For fbcode/eden/scm/lib/backingstore/src/ffi.rs
Expand Down
1 change: 1 addition & 0 deletions eden/fs/store/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ cpp_library(
"fbsource//third-party/fmt:fmt",
"//eden/common/os:os",
"//eden/common/utils:ref_ptr",
"//eden/fs/telemetry:stats",
],
)

Expand Down

0 comments on commit 8f7b0b4

Please sign in to comment.