Skip to content

Commit

Permalink
[native] Remove arbitrator stats reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang authored and xiaoxmeng committed May 6, 2024
1 parent bc29df7 commit 0f21fe5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 105 deletions.
1 change: 1 addition & 0 deletions presto-native-execution/presto_cpp/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ target_link_libraries(
presto_operators
velox_aggregates
velox_caching
velox_common_base
velox_core
velox_dwio_common_exception
velox_encode
Expand Down
58 changes: 7 additions & 51 deletions presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "presto_cpp/main/TaskManager.h"
#include "presto_cpp/main/common/Counters.h"
#include "presto_cpp/main/http/filters/HttpEndpointLatencyFilter.h"
#include "velox/common/base/PeriodicStatsReporter.h"
#include "velox/common/base/StatsReporter.h"
#include "velox/common/base/SuccinctPrinter.h"
#include "velox/common/caching/AsyncDataCache.h"
Expand Down Expand Up @@ -88,8 +89,6 @@ static constexpr size_t kConnectorPeriodGlobalCounters{
60'000'000}; // 60 seconds.
static constexpr size_t kOsPeriodGlobalCounters{2'000'000}; // 2 seconds
static constexpr size_t kSpillStatsUpdateIntervalUs{60'000'000}; // 60 seconds
static constexpr size_t kArbitratorStatsUpdateIntervalUs{
60'000'000}; // 60 seconds
// Every 1 minute we print endpoint latency counters.
static constexpr size_t kHttpEndpointLatencyPeriodGlobalCounters{
60'000'000}; // 60 seconds.
Expand All @@ -114,6 +113,11 @@ PeriodicTaskManager::PeriodicTaskManager(
server_(server) {}

void PeriodicTaskManager::start() {
VELOX_CHECK_NOT_NULL(arbitrator_);
velox::PeriodicStatsReporter::Options opts;
opts.arbitrator = arbitrator_->kind() == "NOOP" ? nullptr : arbitrator_;
velox::startPeriodicStatsReporter(opts);

// If executors are null, don't bother starting this task.
if ((driverCPUExecutor_ != nullptr) || (httpExecutor_ != nullptr)) {
addExecutorStatsTask();
Expand Down Expand Up @@ -146,11 +150,6 @@ void PeriodicTaskManager::start() {
addHttpEndpointLatencyStatsTask();
}

VELOX_CHECK_NOT_NULL(arbitrator_);
if (arbitrator_->kind() != "NOOP") {
addArbitratorStatsTask();
}

if (server_ && server_->hasCoordinatorDiscoverer()) {
numDriverThreads_ = server_->numDriverThreads();
addWatchdogTask();
Expand All @@ -160,6 +159,7 @@ void PeriodicTaskManager::start() {
}

void PeriodicTaskManager::stop() {
velox::stopPeriodicStatsReporter();
oneTimeRunner_.cancelAllFunctionsAndWait();
oneTimeRunner_.shutdown();
repeatedRunner_.stop();
Expand Down Expand Up @@ -610,50 +610,6 @@ void PeriodicTaskManager::addOperatingSystemStatsUpdateTask() {
"os_counters");
}

void PeriodicTaskManager::addArbitratorStatsTask() {
addTask(
[this]() { updateArbitratorStatsTask(); },
kArbitratorStatsUpdateIntervalUs,
"arbitrator_stats");
}

void PeriodicTaskManager::updateArbitratorStatsTask() {
const auto updatedArbitratorStats = arbitrator_->stats();
VELOX_CHECK_GE(updatedArbitratorStats, lastArbitratorStats_);
const auto deltaArbitratorStats =
updatedArbitratorStats - lastArbitratorStats_;
REPORT_IF_NOT_ZERO(
kCounterArbitratorNumRequests, deltaArbitratorStats.numRequests);
REPORT_IF_NOT_ZERO(
kCounterArbitratorNumAborted, deltaArbitratorStats.numAborted);
REPORT_IF_NOT_ZERO(
kCounterArbitratorNumFailures, deltaArbitratorStats.numFailures);
REPORT_IF_NOT_ZERO(
kCounterArbitratorQueueTimeUs, deltaArbitratorStats.queueTimeUs);
REPORT_IF_NOT_ZERO(
kCounterArbitratorArbitrationTimeUs,
deltaArbitratorStats.arbitrationTimeUs);
REPORT_IF_NOT_ZERO(
kCounterArbitratorNumShrunkBytes, deltaArbitratorStats.numShrunkBytes);
REPORT_IF_NOT_ZERO(
kCounterArbitratorNumReclaimedBytes,
deltaArbitratorStats.numReclaimedBytes);
REPORT_IF_NOT_ZERO(
kCounterArbitratorFreeCapacityBytes,
deltaArbitratorStats.freeCapacityBytes);
REPORT_IF_NOT_ZERO(
kCounterArbitratorNonReclaimableAttempts,
deltaArbitratorStats.numNonReclaimableAttempts);

if (!deltaArbitratorStats.empty()) {
LOG(INFO) << "Updated memory arbitrator stats: "
<< updatedArbitratorStats.toString();
LOG(INFO) << "Memory arbitrator stats change: "
<< deltaArbitratorStats.toString();
}
lastArbitratorStats_ = updatedArbitratorStats;
}

void PeriodicTaskManager::addSpillStatsUpdateTask() {
addTask(
[this]() { updateSpillStatsTask(); },
Expand Down
5 changes: 0 additions & 5 deletions presto-native-execution/presto_cpp/main/PeriodicTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ class PeriodicTaskManager {
std::shared_ptr<velox::connector::Connector>>& connectors,
PrestoServer* server);

~PeriodicTaskManager() {
stop();
}

/// Invoked to start all registered, and fundamental periodic tasks running at
/// the background.
///
Expand Down Expand Up @@ -170,7 +166,6 @@ class PeriodicTaskManager {
int64_t lastForcedContextSwitches_{0};
// Renabled this after update velox.
velox::common::SpillStats lastSpillStats_;
velox::memory::MemoryArbitrator::Stats lastArbitratorStats_;

// NOTE: declare last since the threads access other members of `this`.
folly::FunctionScheduler oneTimeRunner_;
Expand Down
17 changes: 0 additions & 17 deletions presto-native-execution/presto_cpp/main/common/Counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,6 @@ void registerPrestoMetrics() {
100);
DEFINE_METRIC(kCounterSpillMaxLevelExceeded, facebook::velox::StatType::SUM);

/// ================== Memory Arbitrator Counters =================

DEFINE_METRIC(kCounterArbitratorNumRequests, facebook::velox::StatType::SUM);
DEFINE_METRIC(kCounterArbitratorNumAborted, facebook::velox::StatType::SUM);
DEFINE_METRIC(kCounterArbitratorNumFailures, facebook::velox::StatType::SUM);
DEFINE_METRIC(kCounterArbitratorQueueTimeUs, facebook::velox::StatType::SUM);
DEFINE_METRIC(
kCounterArbitratorArbitrationTimeUs, facebook::velox::StatType::SUM);
DEFINE_METRIC(
kCounterArbitratorNumShrunkBytes, facebook::velox::StatType::SUM);
DEFINE_METRIC(
kCounterArbitratorNumReclaimedBytes, facebook::velox::StatType::SUM);
DEFINE_METRIC(
kCounterArbitratorFreeCapacityBytes, facebook::velox::StatType::AVG);
DEFINE_METRIC(
kCounterArbitratorNonReclaimableAttempts, facebook::velox::StatType::SUM);

// NOTE: Metrics type exporting for file handle cache counters are in
// PeriodicTaskManager because they have dynamic names. The following counters
// have their type exported there:
Expand Down
31 changes: 0 additions & 31 deletions presto-native-execution/presto_cpp/main/common/Counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,37 +165,6 @@ constexpr folly::StringPiece kCounterMmapRawAllocBytesSmall{
constexpr folly::StringPiece kCounterExchangeSourcePeakQueuedBytes{
"presto_cpp.exchange_source_peak_queued_bytes"};

/// ================== Memory Arbitrator Counters =================

/// The number of arbitration requests.
constexpr folly::StringPiece kCounterArbitratorNumRequests{
"presto_cpp.arbitrator_num_requests"};
/// The number of aborted arbitration requests.
constexpr folly::StringPiece kCounterArbitratorNumAborted{
"presto_cpp.arbitrator_num_aborted"};
/// The number of arbitration request failures.
constexpr folly::StringPiece kCounterArbitratorNumFailures{
"presto_cpp.arbitrator_num_failures"};
/// The sum of all the arbitration request queue times in microseconds.
constexpr folly::StringPiece kCounterArbitratorQueueTimeUs{
"presto_cpp.arbitrator_queue_time_us"};
/// The sum of all the arbitration run times in microseconds.
constexpr folly::StringPiece kCounterArbitratorArbitrationTimeUs{
"presto_cpp.arbitrator_arbitration_time_us"};
/// The amount of memory bytes freed by reducing the memory pool's capacity
/// without actually freeing memory.
constexpr folly::StringPiece kCounterArbitratorNumShrunkBytes{
"presto_cpp.arbitrator_num_shrunk_bytes"};
/// The amount of memory bytes freed by memory reclamation.
constexpr folly::StringPiece kCounterArbitratorNumReclaimedBytes{
"presto_cpp.arbitrator_num_reclaimed_bytes"};
/// The free memory capacity in bytes.
constexpr folly::StringPiece kCounterArbitratorFreeCapacityBytes{
"presto_cpp.arbitrator_free_capacity_bytes"};
/// The number of non-reclaimable operator reclaim attempts.
constexpr folly::StringPiece kCounterArbitratorNonReclaimableAttempts{
"presto_cpp.arbitrator_non_reclaimable_attempts"};

/// ================== Disk Spilling Counters =================

/// The number of times that spilling runs on a velox operator.
Expand Down
2 changes: 1 addition & 1 deletion presto-native-execution/velox
Submodule velox updated 43 files
+0 −6 .gitmodules
+5 −8 README.md
+30 −4 velox/common/base/PeriodicStatsReporter.cpp
+12 −3 velox/common/base/PeriodicStatsReporter.h
+23 −5 velox/common/base/tests/StatsReporterTest.cpp
+1 −1 velox/core/PlanNode.h
+2 −0 velox/docs/develop/testing/fuzzer.rst
+1 −1 velox/docs/develop/testing/join-fuzzer.rst
+55 −0 velox/docs/develop/testing/row-number-fuzzer.rst
+9 −3 velox/docs/functions/spark/datetime.rst
+3 −2 velox/docs/monthly-updates.rst
+68 −0 velox/docs/monthly-updates/february-2024.rst
+9 −6 velox/exec/HashProbe.cpp
+6 −8 velox/exec/HashProbe.h
+1 −36 velox/exec/Task.cpp
+0 −18 velox/exec/Task.h
+6 −0 velox/exec/fuzzer/CMakeLists.txt
+35 −3 velox/exec/fuzzer/DuckQueryRunner.cpp
+3 −0 velox/exec/fuzzer/DuckQueryRunner.h
+39 −3 velox/exec/fuzzer/PrestoQueryRunner.cpp
+3 −0 velox/exec/fuzzer/PrestoQueryRunner.h
+550 −0 velox/exec/fuzzer/RowNumberFuzzer.cpp
+25 −0 velox/exec/fuzzer/RowNumberFuzzer.h
+72 −0 velox/exec/fuzzer/RowNumberFuzzerRunner.h
+6 −0 velox/exec/tests/CMakeLists.txt
+65 −0 velox/exec/tests/HashJoinTest.cpp
+7 −0 velox/exec/tests/PlanBuilderTest.cpp
+96 −0 velox/exec/tests/RowNumberFuzzerTest.cpp
+1 −0 velox/exec/tests/utils/PlanBuilder.cpp
+5 −0 velox/exec/tests/utils/PlanBuilder.h
+38 −0 velox/expression/fuzzer/ArgGenerator.h
+3 −2 velox/expression/fuzzer/CMakeLists.txt
+99 −0 velox/expression/fuzzer/DecimalArgGeneratorBase.cpp
+72 −0 velox/expression/fuzzer/DecimalArgGeneratorBase.h
+1 −1 velox/expression/fuzzer/tests/CMakeLists.txt
+128 −0 velox/expression/fuzzer/tests/DecimalArgGeneratorTest.cpp
+11 −0 velox/functions/sparksql/DateTimeFunctions.h
+3 −0 velox/functions/sparksql/Register.cpp
+12 −0 velox/functions/sparksql/tests/DateTimeFunctionsTest.cpp
+4 −2 velox/vector/BaseVector.h
+5 −1 velox/vector/ConstantVector.h
+4 −1 velox/vector/DictionaryVector.h
+7 −0 velox/vector/tests/VectorTest.cpp

0 comments on commit 0f21fe5

Please sign in to comment.