Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add physicalWrittenBytes to PlanNodeStats #8213

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions velox/exec/PlanNodeStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void PlanNodeStats::addTotals(const OperatorStats& stats) {
peakMemoryBytes += stats.memoryStats.peakTotalMemoryReservation;
numMemoryAllocations += stats.memoryStats.numMemoryAllocations;

physicalWrittenBytes += stats.physicalWrittenBytes;

for (const auto& [name, runtimeStats] : stats.runtimeStats) {
if (UNLIKELY(customStats.count(name) == 0)) {
customStats.insert(std::make_pair(name, runtimeStats));
Expand Down Expand Up @@ -154,6 +156,7 @@ folly::dynamic toPlanStatsJson(const facebook::velox::exec::TaskStats& stats) {
stat["blockedWallNanos"] = operatorStat.second->blockedWallNanos;
stat["peakMemoryBytes"] = operatorStat.second->peakMemoryBytes;
stat["numMemoryAllocations"] = operatorStat.second->numMemoryAllocations;
stat["physicalWrittenBytes"] = operatorStat.second->physicalWrittenBytes;
stat["numDrivers"] = operatorStat.second->numDrivers;
stat["numSplits"] = operatorStat.second->numSplits;
stat["spilledInputBytes"] = operatorStat.second->spilledInputBytes;
Expand Down
2 changes: 2 additions & 0 deletions velox/exec/PlanNodeStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ struct PlanNodeStats {

uint64_t numMemoryAllocations{0};

uint64_t physicalWrittenBytes{0};

/// Operator-specific counters.
std::unordered_map<std::string, RuntimeMetric> customStats;

Expand Down
23 changes: 12 additions & 11 deletions velox/exec/tests/TableWriteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2950,17 +2950,18 @@ TEST_P(AllTableWriterTest, tableWriterStats) {
const int32_t ORC_HEADER_LEN{3};
const auto fixedWrittenBytes =
numWrittenFiles * (fileFormat_ == FileFormat::DWRF ? ORC_HEADER_LEN : 0);
for (int i = 0; i < task->taskStats().pipelineStats.size(); ++i) {
auto operatorStats = task->taskStats().pipelineStats.at(i).operatorStats;
for (int j = 0; j < operatorStats.size(); ++j) {
if (operatorStats.at(j).operatorType == "TableWrite") {
ASSERT_GT(operatorStats.at(j).physicalWrittenBytes, fixedWrittenBytes);
ASSERT_EQ(
operatorStats.at(j).runtimeStats.at("numWrittenFiles").sum,
numWrittenFiles);
}
}
}

auto planStats = exec::toPlanStats(task->taskStats());
auto& stats = planStats.at(tableWriteNodeId_);
ASSERT_GT(stats.physicalWrittenBytes, fixedWrittenBytes);
ASSERT_GT(
stats.operatorStats.at("TableWrite")->physicalWrittenBytes,
fixedWrittenBytes);
ASSERT_EQ(
stats.operatorStats.at("TableWrite")
->customStats.at("numWrittenFiles")
.sum,
numWrittenFiles);
}

DEBUG_ONLY_TEST_P(
Expand Down