Skip to content

Commit 0ab0189

Browse files
pbhandar2meta-codesync[bot]
authored andcommitted
Fix call chaining CacheBase and CacheAllocator to set EventTracker
Summary: #### [Cachelib] Fix call chaining CacheBase and CacheAllocator to set EventTracker **Cache.h Changes:** * The function `setEventTracker` has been made virtual. * The functions `setEventTrackerSamplingRate` and `disableEventTracker` have been removed from the `Cache` class. This will be handled by Luna. **Cache.cpp Changes:** * The implementation of `getEventTracker` remains unchanged. * The implementation of `setEventTrackerSamplingRate` has been removed. This will be handled by Luna. **Impact:** This diff aims to fix the call chaining between `CacheBase` and `CacheAllocator` to set the `EventTracker`. The changes make the `setEventTracker` function virtual, allowing for proper overriding in derived classes. Additionally, `setEventTrackerSamplingRate` and `disableEventTracker` are not needed as changing and disabling EventTracker will be handled by Luna. Reviewed By: rlyerly Differential Revision: D92208056 fbshipit-source-id: 88f0c252345c2e980093e77e67b702299cb29f1f
1 parent 2057e42 commit 0ab0189

3 files changed

Lines changed: 2 additions & 28 deletions

File tree

cachelib/allocator/Cache.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -634,28 +634,4 @@ void CacheBase::setEventTracker(EventTracker::Config&& config) {
634634
std::shared_ptr<EventTracker> CacheBase::getEventTracker() const {
635635
return eventTracker_.load();
636636
}
637-
638-
void CacheBase::setEventTrackerSamplingRate(uint32_t samplingRate) {
639-
if (auto eventTracker = getEventTracker()) {
640-
XLOG(INFO) << "Attempting to set sampling rate to " << samplingRate
641-
<< " for event tracker.";
642-
eventTracker->setSamplingRate(samplingRate);
643-
XLOG(INFO) << "EventTracker sampling rate is "
644-
<< eventTracker->getSamplingRate();
645-
} else {
646-
XLOG(INFO) << "Event tracker is not enabled. "
647-
"Setting EventTracker sampling rate to "
648-
<< samplingRate << " will have no effect.";
649-
}
650-
}
651-
652-
void CacheBase::disableEventTracker() {
653-
if (auto eventTracker = getEventTracker()) {
654-
XLOG(INFO) << "Disabling event tracker. Setting eventTracker_ to nullptr.";
655-
eventTracker_.store(nullptr);
656-
} else {
657-
XLOG(INFO) << "Event tracker is already disabled.";
658-
}
659-
}
660-
661637
} // namespace facebook::cachelib

cachelib/allocator/Cache.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ class CacheBase {
231231
bool aggregatePoolStats_{false};
232232

233233
std::shared_ptr<EventTracker> getEventTracker() const;
234-
void setEventTracker(EventTracker::Config&& config);
235-
void setEventTrackerSamplingRate(uint32_t samplingRate);
236-
void disableEventTracker();
234+
virtual void setEventTracker(EventTracker::Config&& config);
237235

238236
protected:
239237
// move bytes from one pool to another. The source pool should be at least

cachelib/allocator/CacheAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ class CacheAllocator : public CacheBase {
12551255
// Set the event tracker for the cache allocator.
12561256
// This overrides the base class method to also propagate the event tracker
12571257
// to the NVM cache if it is enabled.
1258-
void setEventTracker(EventTracker::Config&& config) {
1258+
void setEventTracker(EventTracker::Config&& config) override {
12591259
// Call the base class method to set the event tracker
12601260
CacheBase::setEventTracker(std::move(config));
12611261

0 commit comments

Comments
 (0)