Skip to content

Commit e6a69ea

Browse files
genevievehelselmeta-codesync[bot]
authored andcommitted
telemetry: Guard OBC counters for OSS builds
Summary: Add an OSS `eden-config.h` variant and make the OBC includes, counters, and update paths conditional on `EDEN_HAVE_OBC`. Internal builds keep defining `EDEN_HAVE_OBC`, while the shipped OSS config can omit the internal OBC dependency. Reviewed By: muirdm Differential Revision: D109885413 fbshipit-source-id: 6512c468f7dbe808f334ab03fade34cd4adf5278
1 parent 9e4bf20 commit e6a69ea

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

eden/fs/service/EdenServer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ Future<TakeoverData> EdenServer::stopMountsForTakeover(
13511351

13521352
void EdenServer::startPeriodicTasks() {
13531353
auto config = serverState_->getReloadableConfig()->getEdenConfig();
1354+
#ifdef EDEN_HAVE_OBC
13541355
if (config->enableOBCOnEden.getValue()) {
13551356
// Get the hostname without the ".facebook.com" suffix
13561357
auto hostname = facebook::network::getLocalHost(/*stripFbDomain=*/true);
@@ -1368,6 +1369,7 @@ void EdenServer::startPeriodicTasks() {
13681369
// Report memory usage stats once every 60 seconds
13691370
memoryStatsTask_.updateInterval(60s);
13701371
}
1372+
#endif
13711373
updatePeriodicTaskIntervals(*config);
13721374

13731375
#ifndef _WIN32
@@ -3202,11 +3204,13 @@ void EdenServer::flushStatsNow() {
32023204
}
32033205

32043206
void EdenServer::reportMemoryStats() {
3207+
#ifdef EDEN_HAVE_OBC
32053208
auto memoryStats = facebook::eden::proc_util::readMemoryStats();
32063209
if (memoryStats) {
32073210
// Bump the OBC counters for the current memory usage
32083211
memory_vm_rss_bytes_ += memoryStats->resident;
32093212
}
3213+
#endif
32103214
}
32113215

32123216
void EdenServer::refreshBackingStore() {

eden/fs/service/EdenServer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
#include "eden/fs/takeover/TakeoverHandler.h"
4747
#include "eden/fs/telemetry/EdenStats.h"
4848
#include "eden/fs/telemetry/IActivityRecorder.h"
49+
#ifdef EDEN_HAVE_OBC
4950
#include "monitoring/obc/OBCAvg.h"
51+
#endif
5052

5153
DECLARE_bool(takeover);
5254

@@ -607,8 +609,10 @@ class EdenServer : private TakeoverHandler {
607609
void startPeriodicTasks();
608610
void updatePeriodicTaskIntervals(const EdenConfig& config);
609611

610-
// calculates eden rss memory usage
612+
#ifdef EDEN_HAVE_OBC
613+
// Calculates EdenFS RSS memory usage.
611614
monitoring::OBCAvg memory_vm_rss_bytes_;
615+
#endif
612616

613617
/**
614618
* Schedule a call to unloadInodes() to happen after timeout

eden/fs/store/sl/SaplingBackingStore.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
#ifdef EDEN_HAVE_SERVER_OBSERVER
5555
#include "common/fb303/cpp/ThreadPoolExecutorCounters.h" // @manual
5656
#endif
57+
#ifdef EDEN_HAVE_OBC
5758
#include "common/network/Hostname.h"
59+
#endif
5860

5961
DEFINE_bool(
6062
hg_fetch_missing_trees,
@@ -176,9 +178,11 @@ SaplingBackingStore::SaplingBackingStore(
176178
folly::to<std::string>("hg-activitybuffer-", getRepoName().value_or("")),
177179
[this](const HgImportTraceEvent& event) { this->processHgEvent(event); });
178180

181+
#ifdef EDEN_HAVE_OBC
179182
if (config_->getEdenConfig()->enableOBCOnEden.getValue()) {
180183
initializeOBCCounters();
181184
}
185+
#endif
182186
}
183187

184188
/**
@@ -251,9 +255,11 @@ SaplingBackingStore::SaplingBackingStore(
251255
folly::to<std::string>("hg-activitybuffer-", getRepoName().value_or("")),
252256
[this](const HgImportTraceEvent& event) { this->processHgEvent(event); });
253257

258+
#ifdef EDEN_HAVE_OBC
254259
if (config_->getEdenConfig()->enableOBCOnEden.getValue()) {
255260
initializeOBCCounters();
256261
}
262+
#endif
257263
}
258264

259265
SaplingBackingStore::~SaplingBackingStore() {
@@ -263,6 +269,7 @@ SaplingBackingStore::~SaplingBackingStore() {
263269
}
264270
}
265271

272+
#ifdef EDEN_HAVE_OBC
266273
void SaplingBackingStore::initializeOBCCounters() {
267274
// Get the hostname without the ".facebook.com" suffix
268275
auto hostname = facebook::network::getLocalHost(/*stripFbDomain=*/true);
@@ -276,6 +283,7 @@ void SaplingBackingStore::initializeOBCCounters() {
276283
{hostname});
277284
isOBCEnabled_ = true;
278285
}
286+
#endif
279287

280288
void SaplingBackingStore::processHgEvent(const HgImportTraceEvent& event) {
281289
switch (event.eventType) {
@@ -331,9 +339,11 @@ void SaplingBackingStore::setFetchBlobCounters(
331339
return;
332340
}
333341

342+
#ifdef EDEN_HAVE_OBC
334343
if (isOBCEnabled_) {
335344
getBlobPerRepoLatencies_ += watch.elapsed().count();
336345
}
346+
#endif
337347
stats_->addDuration(&SaplingBackingStoreStats::fetchBlob, watch.elapsed());
338348

339349
if (fetchResult == ObjectFetchContext::FetchResult::Success) {
@@ -586,9 +596,11 @@ void SaplingBackingStore::getTreeBatch(
586596
}
587597
}
588598

599+
#ifdef EDEN_HAVE_OBC
589600
if (isOBCEnabled_) {
590601
getTreePerRepoLatencies_ += batchWatch.elapsed().count();
591602
}
603+
#endif
592604
stats_->addDuration(
593605
&SaplingBackingStoreStats::fetchTree, batchWatch.elapsed());
594606

eden/fs/store/sl/SaplingBackingStore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "eden/fs/store/sl/SaplingImportRequestQueue.h"
3232
#include "eden/fs/telemetry/ActivityBuffer.h"
3333
#include "eden/scm/lib/backingstore/src/ffi.rs.h"
34+
#ifdef EDEN_HAVE_OBC
3435
#include "monitoring/obc/OBCPxx.h"
36+
#endif
3537

3638
namespace sapling {
3739
using NodeId = facebook::eden::Hash20;
@@ -765,13 +767,15 @@ class SaplingBackingStore final
765767

766768
EdenStatsPtr stats_;
767769

770+
#ifdef EDEN_HAVE_OBC
768771
// This is used to avoid reading config in hot path of get request
769772
bool isOBCEnabled_ = false;
770773
// TODO: this is a prototype to test OBC API on eden
771774
// we should move these to a separate class
772775
monitoring::OBCP99P95P50 getBlobPerRepoLatencies_; // calculates p50, p95, p99
773776
monitoring::OBCP99P95P50 getTreePerRepoLatencies_; // calculates p50, p95, p99
774777
void initializeOBCCounters();
778+
#endif
775779

776780
bool dogfoodingHost();
777781

0 commit comments

Comments
 (0)