Skip to content

Commit d9114d3

Browse files
committed
[native] Migrate away stats reporting for allocator and cache
1 parent 9c82b1e commit d9114d3

File tree

3 files changed

+3
-231
lines changed

3 files changed

+3
-231
lines changed

presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp

Lines changed: 2 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
#include <folly/stop_watch.h>
1818
#include "presto_cpp/main/PrestoExchangeSource.h"
1919
#include "presto_cpp/main/PrestoServer.h"
20-
#include "presto_cpp/main/TaskManager.h"
2120
#include "presto_cpp/main/common/Counters.h"
2221
#include "presto_cpp/main/http/filters/HttpEndpointLatencyFilter.h"
2322
#include "velox/common/base/PeriodicStatsReporter.h"
2423
#include "velox/common/base/StatsReporter.h"
2524
#include "velox/common/base/SuccinctPrinter.h"
2625
#include "velox/common/caching/AsyncDataCache.h"
2726
#include "velox/common/caching/CacheTTLController.h"
28-
#include "velox/common/caching/SsdFile.h"
2927
#include "velox/common/memory/MemoryAllocator.h"
3028
#include "velox/common/memory/MmapAllocator.h"
3129
#include "velox/connectors/hive/HiveConnector.h"
@@ -75,15 +73,11 @@ folly::StringPiece getCounterForBlockingReason(
7573

7674
// Every two seconds we export server counters.
7775
static constexpr size_t kTaskPeriodGlobalCounters{2'000'000}; // 2 seconds.
78-
// Every two seconds we export memory counters.
79-
static constexpr size_t kMemoryPeriodGlobalCounters{2'000'000}; // 2 seconds.
8076
// Every two seconds we export exchange source counters.
8177
static constexpr size_t kExchangeSourcePeriodGlobalCounters{
8278
2'000'000}; // 2 seconds.
8379
// Every 1 minute we clean old tasks.
8480
static constexpr size_t kTaskPeriodCleanOldTasks{60'000'000}; // 60 seconds.
85-
// Every 1 minute we export cache counters.
86-
static constexpr size_t kCachePeriodGlobalCounters{60'000'000}; // 60 seconds.
8781
// Every 1 minute we export connector counters.
8882
static constexpr size_t kConnectorPeriodGlobalCounters{
8983
60'000'000}; // 60 seconds.
@@ -116,6 +110,8 @@ void PeriodicTaskManager::start() {
116110
VELOX_CHECK_NOT_NULL(arbitrator_);
117111
velox::PeriodicStatsReporter::Options opts;
118112
opts.arbitrator = arbitrator_->kind() == "NOOP" ? nullptr : arbitrator_;
113+
opts.allocator = memoryAllocator_;
114+
opts.cache = asyncDataCache_;
119115
velox::startPeriodicStatsReporter(opts);
120116

121117
// If executors are null, don't bother starting this task.
@@ -130,16 +126,8 @@ void PeriodicTaskManager::start() {
130126
addOldTaskCleanupTask();
131127
}
132128

133-
if (memoryAllocator_ != nullptr) {
134-
addMemoryAllocatorStatsTask();
135-
}
136-
137129
addPrestoExchangeSourceMemoryStatsTask();
138130

139-
if (asyncDataCache_ != nullptr) {
140-
addCacheStatsUpdateTask();
141-
}
142-
143131
addConnectorStatsTask();
144132

145133
addOperatingSystemStatsUpdateTask();
@@ -252,35 +240,6 @@ void PeriodicTaskManager::addOldTaskCleanupTask() {
252240
"clean_old_tasks");
253241
}
254242

255-
void PeriodicTaskManager::updateMemoryAllocatorStats() {
256-
RECORD_METRIC_VALUE(
257-
kCounterMappedMemoryBytes,
258-
(velox::memory::AllocationTraits::pageBytes(
259-
memoryAllocator_->numMapped())));
260-
RECORD_METRIC_VALUE(
261-
kCounterAllocatedMemoryBytes,
262-
(velox::memory::AllocationTraits::pageBytes(
263-
memoryAllocator_->numAllocated())));
264-
// TODO(jtan6): Remove condition after T150019700 is done
265-
if (auto* mmapAllocator =
266-
dynamic_cast<const velox::memory::MmapAllocator*>(memoryAllocator_)) {
267-
RECORD_METRIC_VALUE(
268-
kCounterMmapRawAllocBytesSmall, (mmapAllocator->numMallocBytes()));
269-
RECORD_METRIC_VALUE(
270-
kCounterMmapExternalMappedBytes,
271-
velox::memory::AllocationTraits::pageBytes(
272-
(mmapAllocator->numExternalMapped())));
273-
}
274-
// TODO(xiaoxmeng): add memory allocation size stats.
275-
}
276-
277-
void PeriodicTaskManager::addMemoryAllocatorStatsTask() {
278-
addTask(
279-
[this]() { updateMemoryAllocatorStats(); },
280-
kMemoryPeriodGlobalCounters,
281-
"mmap_memory_counters");
282-
}
283-
284243
void PeriodicTaskManager::updatePrestoExchangeSourceMemoryStats() {
285244
int64_t currQueuedMemoryBytes{0};
286245
int64_t peakQueuedMemoryBytes{0};
@@ -298,184 +257,6 @@ void PeriodicTaskManager::addPrestoExchangeSourceMemoryStatsTask() {
298257
"exchange_source_counters");
299258
}
300259

301-
void PeriodicTaskManager::updateCacheStats() {
302-
const auto memoryCacheStats = asyncDataCache_->refreshStats();
303-
304-
// Snapshots.
305-
RECORD_METRIC_VALUE(
306-
kCounterMemoryCacheNumEntries, memoryCacheStats.numEntries);
307-
RECORD_METRIC_VALUE(
308-
kCounterMemoryCacheNumEmptyEntries, memoryCacheStats.numEmptyEntries);
309-
RECORD_METRIC_VALUE(
310-
kCounterMemoryCacheNumSharedEntries, memoryCacheStats.numShared);
311-
RECORD_METRIC_VALUE(
312-
kCounterMemoryCacheNumExclusiveEntries, memoryCacheStats.numExclusive);
313-
RECORD_METRIC_VALUE(
314-
kCounterMemoryCacheNumPrefetchedEntries, memoryCacheStats.numPrefetch);
315-
RECORD_METRIC_VALUE(
316-
kCounterMemoryCacheTotalTinyBytes, memoryCacheStats.tinySize);
317-
RECORD_METRIC_VALUE(
318-
kCounterMemoryCacheTotalLargeBytes, memoryCacheStats.largeSize);
319-
RECORD_METRIC_VALUE(
320-
kCounterMemoryCacheTotalTinyPaddingBytes, memoryCacheStats.tinyPadding);
321-
RECORD_METRIC_VALUE(
322-
kCounterMemoryCacheTotalLargePaddingBytes, memoryCacheStats.largePadding);
323-
RECORD_METRIC_VALUE(
324-
kCounterMemoryCacheTotalPrefetchBytes, memoryCacheStats.prefetchBytes);
325-
RECORD_METRIC_VALUE(
326-
kCounterMemoryCacheSumEvictScore, memoryCacheStats.sumEvictScore);
327-
328-
// Interval cumulatives.
329-
RECORD_METRIC_VALUE(
330-
kCounterMemoryCacheNumHit,
331-
memoryCacheStats.numHit - lastMemoryCacheHits_);
332-
RECORD_METRIC_VALUE(
333-
kCounterMemoryCacheHitBytes,
334-
memoryCacheStats.hitBytes - lastMemoryCacheHitsBytes_);
335-
RECORD_METRIC_VALUE(
336-
kCounterMemoryCacheNumNew,
337-
memoryCacheStats.numNew - lastMemoryCacheInserts_);
338-
RECORD_METRIC_VALUE(
339-
kCounterMemoryCacheNumEvict,
340-
memoryCacheStats.numEvict - lastMemoryCacheEvictions_);
341-
RECORD_METRIC_VALUE(
342-
kCounterMemoryCacheNumEvictChecks,
343-
memoryCacheStats.numEvictChecks - lastMemoryCacheEvictionChecks_);
344-
RECORD_METRIC_VALUE(
345-
kCounterMemoryCacheNumWaitExclusive,
346-
memoryCacheStats.numWaitExclusive - lastMemoryCacheStalls_);
347-
RECORD_METRIC_VALUE(
348-
kCounterMemoryCacheNumAllocClocks,
349-
memoryCacheStats.allocClocks - lastMemoryCacheAllocClocks_);
350-
351-
lastMemoryCacheHits_ = memoryCacheStats.numHit;
352-
lastMemoryCacheHitsBytes_ = memoryCacheStats.hitBytes;
353-
lastMemoryCacheInserts_ = memoryCacheStats.numNew;
354-
lastMemoryCacheEvictions_ = memoryCacheStats.numEvict;
355-
lastMemoryCacheEvictionChecks_ = memoryCacheStats.numEvictChecks;
356-
lastMemoryCacheStalls_ = memoryCacheStats.numWaitExclusive;
357-
358-
// All time cumulatives.
359-
RECORD_METRIC_VALUE(
360-
kCounterMemoryCacheNumCumulativeHit, memoryCacheStats.numHit);
361-
RECORD_METRIC_VALUE(
362-
kCounterMemoryCacheCumulativeHitBytes, memoryCacheStats.hitBytes);
363-
RECORD_METRIC_VALUE(
364-
kCounterMemoryCacheNumCumulativeNew, memoryCacheStats.numNew);
365-
RECORD_METRIC_VALUE(
366-
kCounterMemoryCacheNumCumulativeEvict, memoryCacheStats.numEvict);
367-
RECORD_METRIC_VALUE(
368-
kCounterMemoryCacheNumCumulativeEvictChecks,
369-
memoryCacheStats.numEvictChecks);
370-
RECORD_METRIC_VALUE(
371-
kCounterMemoryCacheNumCumulativeWaitExclusive,
372-
memoryCacheStats.numWaitExclusive);
373-
RECORD_METRIC_VALUE(
374-
kCounterMemoryCacheNumCumulativeAllocClocks,
375-
memoryCacheStats.allocClocks);
376-
377-
if (memoryCacheStats.ssdStats != nullptr) {
378-
RECORD_METRIC_VALUE(
379-
kCounterSsdCacheCumulativeReadEntries,
380-
memoryCacheStats.ssdStats->entriesRead)
381-
RECORD_METRIC_VALUE(
382-
kCounterSsdCacheCumulativeReadBytes,
383-
memoryCacheStats.ssdStats->bytesRead);
384-
RECORD_METRIC_VALUE(
385-
kCounterSsdCacheCumulativeWrittenEntries,
386-
memoryCacheStats.ssdStats->entriesWritten);
387-
RECORD_METRIC_VALUE(
388-
kCounterSsdCacheCumulativeWrittenBytes,
389-
memoryCacheStats.ssdStats->bytesWritten);
390-
RECORD_METRIC_VALUE(
391-
kCounterSsdCacheCumulativeOpenSsdErrors,
392-
memoryCacheStats.ssdStats->openFileErrors);
393-
RECORD_METRIC_VALUE(
394-
kCounterSsdCacheCumulativeOpenCheckpointErrors,
395-
memoryCacheStats.ssdStats->openCheckpointErrors);
396-
RECORD_METRIC_VALUE(
397-
kCounterSsdCacheCumulativeOpenLogErrors,
398-
memoryCacheStats.ssdStats->openLogErrors);
399-
RECORD_METRIC_VALUE(
400-
kCounterSsdCacheCumulativeDeleteCheckpointErrors,
401-
memoryCacheStats.ssdStats->deleteCheckpointErrors);
402-
RECORD_METRIC_VALUE(
403-
kCounterSsdCacheCumulativeGrowFileErrors,
404-
memoryCacheStats.ssdStats->growFileErrors);
405-
RECORD_METRIC_VALUE(
406-
kCounterSsdCacheCumulativeWriteSsdErrors,
407-
memoryCacheStats.ssdStats->writeSsdErrors);
408-
RECORD_METRIC_VALUE(
409-
kCounterSsdCacheCumulativeWriteCheckpointErrors,
410-
memoryCacheStats.ssdStats->writeCheckpointErrors);
411-
RECORD_METRIC_VALUE(
412-
kCounterSsdCacheCumulativeReadSsdErrors,
413-
memoryCacheStats.ssdStats->readSsdErrors);
414-
RECORD_METRIC_VALUE(
415-
kCounterSsdCacheCumulativeReadCheckpointErrors,
416-
memoryCacheStats.ssdStats->readCheckpointErrors);
417-
RECORD_METRIC_VALUE(
418-
kCounterSsdCacheCachedEntries,
419-
memoryCacheStats.ssdStats->entriesCached);
420-
RECORD_METRIC_VALUE(
421-
kCounterSsdCacheCachedRegions,
422-
memoryCacheStats.ssdStats->regionsCached);
423-
RECORD_METRIC_VALUE(
424-
kCounterSsdCacheCachedBytes, memoryCacheStats.ssdStats->bytesCached);
425-
REPORT_IF_NOT_ZERO(
426-
kCounterSsdCacheCheckpointsRead,
427-
memoryCacheStats.ssdStats->checkpointsRead -
428-
lastSsdCacheCheckpointsRead_);
429-
REPORT_IF_NOT_ZERO(
430-
kCounterSsdCacheCheckpointsWritten,
431-
memoryCacheStats.ssdStats->checkpointsWritten -
432-
lastSsdCacheCheckpointsWritten_);
433-
REPORT_IF_NOT_ZERO(
434-
kCounterSsdCacheRegionsEvicted,
435-
memoryCacheStats.ssdStats->regionsEvicted -
436-
lastSsdCacheRegionsEvicted_);
437-
438-
lastSsdCacheCheckpointsWritten_ =
439-
memoryCacheStats.ssdStats->checkpointsWritten;
440-
lastSsdCacheCheckpointsRead_ = memoryCacheStats.ssdStats->checkpointsRead;
441-
lastSsdCacheRegionsEvicted_ =
442-
memoryCacheStats.ssdStats->regionsEvicted - lastSsdCacheRegionsEvicted_;
443-
}
444-
445-
if (auto* cacheTTLController =
446-
velox::cache::CacheTTLController::getInstance()) {
447-
RECORD_METRIC_VALUE(
448-
kCounterCacheMaxAgeSecs,
449-
cacheTTLController->getCacheAgeStats().maxAgeSecs);
450-
451-
RECORD_METRIC_VALUE(
452-
kCounterMemoryCacheNumAgedOutEntries,
453-
memoryCacheStats.numAgedOut - lastMemoryCacheAgedOuts_);
454-
lastMemoryCacheAgedOuts_ = memoryCacheStats.numAgedOut;
455-
RECORD_METRIC_VALUE(
456-
kCounterMemoryCacheNumCumulativeAgedOutEntries,
457-
memoryCacheStats.numAgedOut);
458-
459-
if (memoryCacheStats.ssdStats != nullptr) {
460-
RECORD_METRIC_VALUE(
461-
kCounterSsdCacheCumulativeAgedOutEntries,
462-
memoryCacheStats.ssdStats->entriesAgedOut)
463-
RECORD_METRIC_VALUE(
464-
kCounterSsdCacheCumulativeAgedOutRegions,
465-
memoryCacheStats.ssdStats->regionsAgedOut);
466-
}
467-
}
468-
469-
LOG(INFO) << "Cache stats:\n" << memoryCacheStats.toString();
470-
}
471-
472-
void PeriodicTaskManager::addCacheStatsUpdateTask() {
473-
addTask(
474-
[this]() { updateCacheStats(); },
475-
kCachePeriodGlobalCounters,
476-
"cache_counters");
477-
}
478-
479260
namespace {
480261

481262
class HiveConnectorStatsReporter {

presto-native-execution/presto_cpp/main/PeriodicTaskManager.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,9 @@ class PeriodicTaskManager {
104104
void addOldTaskCleanupTask();
105105
void cleanupOldTask();
106106

107-
void addMemoryAllocatorStatsTask();
108-
void updateMemoryAllocatorStats();
109-
110107
void addPrestoExchangeSourceMemoryStatsTask();
111108
void updatePrestoExchangeSourceMemoryStats();
112109

113-
void addCacheStatsUpdateTask();
114-
void updateCacheStats();
115-
116110
void addConnectorStatsTask();
117111

118112
void addOperatingSystemStatsUpdateTask();
@@ -125,9 +119,6 @@ class PeriodicTaskManager {
125119
void addHttpEndpointLatencyStatsTask();
126120
void printHttpEndpointLatencyStats();
127121

128-
void addArbitratorStatsTask();
129-
void updateArbitratorStatsTask();
130-
131122
void addWatchdogTask();
132123

133124
void detachWorker(const char* reason);

presto-native-execution/velox

Submodule velox updated 135 files

0 commit comments

Comments
 (0)