Skip to content

Commit

Permalink
Add maxSingleIoWaitNanos metric (facebookincubator#8060)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebookincubator#8060

Reviewed By: oerling

Differential Revision: D52178568

fbshipit-source-id: 037f275d9cf83428e996542fcfeaa78dd7857997
  • Loading branch information
Yuhta authored and facebook-github-bot committed Dec 18, 2023
1 parent 5afcf99 commit 97c273b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions velox/common/io/IoStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,42 @@ class IoCounter {
return sum_;
}

uint64_t min() const {
return min_;
}

uint64_t max() const {
return max_;
}

void increment(uint64_t amount) {
++count_;
sum_ += amount;
casLoop(min_, amount, std::greater());
casLoop(max_, amount, std::less());
}

void merge(const IoCounter& other) {
sum_ += other.sum_;
count_ += other.count_;
casLoop(min_, other.min_, std::greater());
casLoop(max_, other.max_, std::less());
}

private:
template <typename Compare>
static void
casLoop(std::atomic<uint64_t>& value, uint64_t newValue, Compare compare) {
uint64_t old = value;
while (compare(old, newValue) &&
!value.compare_exchange_weak(old, newValue)) {
}
}

std::atomic<uint64_t> count_{0};
std::atomic<uint64_t> sum_{0};
std::atomic<uint64_t> min_{std::numeric_limits<uint64_t>::max()};
std::atomic<uint64_t> max_{0};
};

class IoStatistics {
Expand Down
4 changes: 4 additions & 0 deletions velox/connectors/hive/HiveDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ std::unordered_map<std::string, RuntimeCounter> HiveDataSource::runtimeStats() {
RuntimeCounter(
ioStats_->queryThreadIoLatency().sum() * 1000,
RuntimeCounter::Unit::kNanos)},
{"maxSingleIoWaitNanos",
RuntimeCounter(
ioStats_->queryThreadIoLatency().max() * 1000,
RuntimeCounter::Unit::kNanos)},
{"overreadBytes",
RuntimeCounter(
ioStats_->rawOverreadBytes(), RuntimeCounter::Unit::kBytes)},
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/tests/PrintPlanWithStatsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ TEST_F(PrintPlanWithStatsTest, innerJoinWithTableScan) {
{" flattenStringDictionaryValues [ ]* sum: 0, count: 1, min: 0, max: 0"},
{" ioWaitNanos [ ]* sum: .+, count: .+ min: .+, max: .+"},
{" localReadBytes [ ]* sum: 0B, count: 1, min: 0B, max: 0B"},
{" maxSingleIoWaitNanos[ ]*sum: .+, count: 1, min: .+, max: .+"},
{" numLocalRead [ ]* sum: 0, count: 1, min: 0, max: 0"},
{" numPrefetch [ ]* sum: .+, count: 1, min: .+, max: .+"},
{" numRamRead [ ]* sum: 40, count: 1, min: 40, max: 40"},
Expand Down Expand Up @@ -283,6 +284,7 @@ TEST_F(PrintPlanWithStatsTest, partialAggregateWithTableScan) {
{" flattenStringDictionaryValues [ ]* sum: 0, count: 1, min: 0, max: 0"},
{" ioWaitNanos [ ]* sum: .+, count: .+ min: .+, max: .+"},
{" localReadBytes [ ]* sum: 0B, count: 1, min: 0B, max: 0B"},
{" maxSingleIoWaitNanos[ ]*sum: .+, count: 1, min: .+, max: .+"},
{" numLocalRead [ ]* sum: 0, count: 1, min: 0, max: 0"},
{" numPrefetch [ ]* sum: .+, count: .+, min: .+, max: .+"},
{" numRamRead [ ]* sum: 6, count: 1, min: 6, max: 6"},
Expand Down

0 comments on commit 97c273b

Please sign in to comment.