Skip to content

Commit 32c40b0

Browse files
kavehahmadi60facebook-github-bot
authored andcommitted
Add a config threshold for running periodic NFS GC
Summary: We want to add a threshold config to the number of inodes on NFS, and the periodic NFS GC only runs if the number of inodes is higher than this number for a mount. This diff makes periodic NFS GC less aggressive. Reviewed By: genevievehelsel Differential Revision: D75610448 fbshipit-source-id: baf526d90c0b6fe34825ef5369899949ca578552
1 parent 077b559 commit 32c40b0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

eden/fs/config/EdenConfig.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,17 @@ class EdenConfig : private ConfigSettingManager {
442442
std::chrono::hours(1),
443443
this};
444444

445+
/**
446+
* Mininum number of inodes that need to be loaded before triggering the
447+
* periodic NFS Garbage Collector (GC). If the loaded inode count is below
448+
* this number, a GC will be skipped. A value of 0 will effectively skip this
449+
* check.
450+
*/
451+
ConfigSetting<uint64_t> nfsPeriodicGcLoadedInodesThreshold{
452+
"mount:nfs-periodic-gc-loaded-inodes-threshold",
453+
1000000,
454+
this};
455+
445456
/**
446457
* Files with an atime older than this will be invalidated during GC.
447458
*

eden/fs/service/EdenServer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,19 @@ void EdenServer::garbageCollectAllMounts() {
27942794

27952795
auto mountPoints = getMountPoints();
27962796
for (auto& mountHandle : mountPoints) {
2797+
#ifdef __APPLE__
2798+
// On macOS, we don't want to run periodic GC if the number of inodes for
2799+
// the mount is below the threshold.
2800+
auto inodeCountsBeforeGC =
2801+
mountHandle.getEdenMount().getInodeMap()->getInodeCounts();
2802+
auto totalNumberOfInodesBeforeGC = inodeCountsBeforeGC.fileCount +
2803+
inodeCountsBeforeGC.treeCount + inodeCountsBeforeGC.unloadedInodeCount;
2804+
auto nfsPeriodicGcLoadedInodesThreshold =
2805+
config->nfsPeriodicGcLoadedInodesThreshold.getValue();
2806+
if (totalNumberOfInodesBeforeGC < nfsPeriodicGcLoadedInodesThreshold) {
2807+
continue;
2808+
}
2809+
#endif
27972810
folly::via(
27982811
getServerState()->getThreadPool().get(),
27992812
[this, mountHandle, cutoff]() mutable {

0 commit comments

Comments
 (0)