Skip to content

Commit e7f9168

Browse files
tanjialiangfacebook-github-bot
authored andcommitted
refactor(native): Change to new background cpu time var location
Summary: shown in title Differential Revision: D87611460
1 parent c270c64 commit e7f9168

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

presto-native-execution/presto_cpp/main/operators/ShuffleWrite.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,35 +120,34 @@ class ShuffleWrite : public Operator {
120120

121121
void recordShuffleWriteClientStats() {
122122
auto lockedStats = stats_.wlock();
123-
std::optional<uint64_t> backgroundCpuTimeMsOpt = std::nullopt;
123+
std::optional<uint64_t> backgroundCpuTimeNanosOpt = std::nullopt;
124124
if (shuffle_->supportsMetrics()) {
125125
const auto shuffleMetrics = shuffle_->metrics();
126126
for (const auto& [name, metric] : shuffleMetrics) {
127127
lockedStats->runtimeStats[name] = metric;
128128
}
129129

130-
if (shuffleMetrics.contains(ExchangeClient::kBackgroundCpuTimeMs)) {
131-
backgroundCpuTimeMsOpt =
132-
shuffleMetrics.at(ExchangeClient::kBackgroundCpuTimeMs).sum;
130+
if (shuffleMetrics.contains(Operator::kBackgroundCpuTimeNanos)) {
131+
backgroundCpuTimeNanosOpt =
132+
shuffleMetrics.at(Operator::kBackgroundCpuTimeNanos).sum;
133133
}
134134
} else {
135135
const auto shuffleStats = shuffle_->stats();
136136
for (const auto& [name, value] : shuffleStats) {
137137
lockedStats->runtimeStats[name] = RuntimeMetric(value);
138138
}
139139

140-
if (shuffleStats.contains(ExchangeClient::kBackgroundCpuTimeMs)) {
141-
backgroundCpuTimeMsOpt =
142-
shuffleStats.at(ExchangeClient::kBackgroundCpuTimeMs);
140+
if (shuffleStats.contains(Operator::kBackgroundCpuTimeNanos)) {
141+
backgroundCpuTimeNanosOpt =
142+
shuffleStats.at(Operator::kBackgroundCpuTimeNanos);
143143
}
144144
}
145145

146-
if (backgroundCpuTimeMsOpt.has_value()) {
146+
if (backgroundCpuTimeNanosOpt.has_value()) {
147147
const CpuWallTiming backgroundTiming{
148-
static_cast<uint64_t>(1),
149-
0,
150-
static_cast<uint64_t>(*backgroundCpuTimeMsOpt) *
151-
Timestamp::kNanosecondsInMillisecond};
148+
.count = static_cast<uint64_t>(1),
149+
.wallNanos = 0,
150+
.cpuNanos = static_cast<uint64_t>(*backgroundCpuTimeNanosOpt)};
152151
lockedStats->backgroundTiming.clear();
153152
lockedStats->backgroundTiming.add(backgroundTiming);
154153
}

presto-native-execution/presto_cpp/main/operators/tests/ShuffleTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace facebook::presto::operators::test {
4242

4343
namespace {
4444

45-
static const uint64_t kFakeBackgroundCpuTimeMs = 123;
45+
static const uint64_t kFakeBackgroundCpuTimeNanos = 123000000;
4646

4747
struct TestShuffleInfo {
4848
uint32_t numPartitions;
@@ -153,7 +153,7 @@ class TestShuffleWriter : public ShuffleWriter {
153153
folly::F14FastMap<std::string, int64_t> stats() const override {
154154
return {
155155
{"test-shuffle.write", 1002},
156-
{exec::ExchangeClient::kBackgroundCpuTimeMs, kFakeBackgroundCpuTimeMs}};
156+
{exec::Operator::kBackgroundCpuTimeNanos, kFakeBackgroundCpuTimeNanos}};
157157
}
158158

159159
std::shared_ptr<std::vector<std::vector<std::unique_ptr<ReadBatch>>>>&
@@ -248,7 +248,7 @@ class TestShuffleReader : public ShuffleReader {
248248
folly::F14FastMap<std::string, int64_t> stats() const override {
249249
return {
250250
{"test-shuffle.read", 1032},
251-
{exec::ExchangeClient::kBackgroundCpuTimeMs, kFakeBackgroundCpuTimeMs}};
251+
{exec::Operator::kBackgroundCpuTimeNanos, kFakeBackgroundCpuTimeNanos}};
252252
}
253253

254254
private:

0 commit comments

Comments
 (0)