Skip to content

Commit

Permalink
Register Overlay size dynamic counters
Browse files Browse the repository at this point in the history
Summary:
## Context:
Previously, we added counters for all the operations in Overlay. However, we don't have any counter to show the size of the files and trees in Overlay. Like what we have for `inode`, we can add new dynamic counters are report size of Overlay per mounted repo.

## This diff:
This diff register the dynamic call backs. However we also need to add ` OVERLAY_DIR_COUNT` and `OVERLAY_FILE_COUNT` then `EdenMount::getCounterName` can return correct name for these counters.

Reviewed By: jdelliot

Differential Revision: D62987495

fbshipit-source-id: 98ef5b050ce03826c54d63b4556c279946dd6eaa
  • Loading branch information
kavehahmadi60 authored and facebook-github-bot committed Sep 20, 2024
1 parent e454bc9 commit fc83d07
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions eden/fs/inodes/EdenMount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,10 @@ std::string EdenMount::getCounterName(CounterName name) {
case CounterName::PERIODIC_UNLINKED_INODE_UNLOAD:
return folly::to<std::string>(
"inodemap.", base, ".unloaded_unlinked_inodes");
case CounterName::OVERLAY_DIR_COUNT:
return folly::to<std::string>("overlay.", base, ".dir_count");
case CounterName::OVERLAY_FILE_COUNT:
return folly::to<std::string>("overlay.", base, ".file_count");
}
EDEN_BUG() << "unknown counter name "
<< static_cast<std::underlying_type_t<CounterName>>(name);
Expand Down
12 changes: 11 additions & 1 deletion eden/fs/inodes/EdenMount.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,17 @@ enum class CounterName {
* unlinked inode unloading. This is used on NFS mounts to clean up old
* inodes.
*/
PERIODIC_UNLINKED_INODE_UNLOAD
PERIODIC_UNLINKED_INODE_UNLOAD,

/**
* Represents the number of directories that were materialized in the overlay.
*/
OVERLAY_DIR_COUNT,

/**
* Represents the number of files that were materialized in the overlay.
*/
OVERLAY_FILE_COUNT

};

Expand Down
4 changes: 4 additions & 0 deletions eden/fs/inodes/Overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@ OverlayFile Overlay::createOverlayFile(

#endif // !_WIN32

Overlay::InternalOverlayStats Overlay::getOverlayStats() const {
return *overlayStats_.rlock();
}

InodeNumber Overlay::getMaxInodeNumber() {
auto ino = nextInodeNumber_.load(std::memory_order_relaxed);
XCHECK_GT(ino, 1u);
Expand Down
5 changes: 5 additions & 0 deletions eden/fs/inodes/Overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ class Overlay : public std::enable_shared_from_this<Overlay> {
size_t fileCount{0};
};

/**
* Get stats about how many objects are materialized in Overlay.
*/
InternalOverlayStats getOverlayStats() const;

void addChild(
InodeNumber parent,
const std::pair<PathComponent, DirEntry>& childEntry,
Expand Down
14 changes: 14 additions & 0 deletions eden/fs/service/EdenServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,16 @@ void EdenServer::registerStats(std::shared_ptr<EdenMount> edenMount) {
auto stats = edenMount->getJournal().getStats();
return stats ? stats->maxFilesAccumulated : 0;
});
counters->registerCallback(
edenMount->getCounterName(CounterName::OVERLAY_DIR_COUNT), [edenMount] {
auto stats = edenMount->getOverlay()->getOverlayStats();
return stats.dirCount;
});
counters->registerCallback(
edenMount->getCounterName(CounterName::OVERLAY_FILE_COUNT), [edenMount] {
auto stats = edenMount->getOverlay()->getOverlayStats();
return stats.fileCount;
});
#ifndef _WIN32
if (auto* channel = edenMount->getFuseChannel()) {
for (auto metric : RequestMetricsScope::requestMetrics) {
Expand Down Expand Up @@ -1533,6 +1543,10 @@ void EdenServer::unregisterStats(EdenMount* edenMount) {
edenMount->getCounterName(CounterName::JOURNAL_DURATION));
counters->unregisterCallback(
edenMount->getCounterName(CounterName::JOURNAL_MAX_FILES_ACCUMULATED));
counters->unregisterCallback(
edenMount->getCounterName(CounterName::OVERLAY_DIR_COUNT));
counters->unregisterCallback(
edenMount->getCounterName(CounterName::OVERLAY_FILE_COUNT));
#ifndef _WIN32
if (edenMount->getFuseChannel()) {
for (auto metric : RequestMetricsScope::requestMetrics) {
Expand Down

0 comments on commit fc83d07

Please sign in to comment.