Skip to content

Commit c07cdb5

Browse files
authored
refactor(native): Change to new background cpu time var location (#26673)
Summary: shown in title Differential Revision: D87611460
1 parent 6240b16 commit c07cdb5

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
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: 7 additions & 7 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:
@@ -1033,7 +1033,7 @@ TEST_F(ShuffleTest, endToEnd) {
10331033
numPartitions,
10341034
numMapDrivers,
10351035
{data},
1036-
kFakeBackgroundCpuTimeMs * Timestamp::kNanosecondsInMillisecond);
1036+
kFakeBackgroundCpuTimeNanos);
10371037
}
10381038

10391039
TEST_F(ShuffleTest, endToEndWithSortedShuffle) {
@@ -1074,7 +1074,7 @@ TEST_F(ShuffleTest, endToEndWithSortedShuffle) {
10741074
numPartitions,
10751075
numMapDrivers,
10761076
{batch1, batch2},
1077-
kFakeBackgroundCpuTimeMs * Timestamp::kNanosecondsInMillisecond,
1077+
kFakeBackgroundCpuTimeNanos,
10781078
ordering,
10791079
fields,
10801080
expectedSortingOrder);
@@ -1131,7 +1131,7 @@ TEST_F(ShuffleTest, endToEndWithSortedShuffleRowLimit) {
11311131
numPartitions,
11321132
numMapDrivers,
11331133
{data},
1134-
kFakeBackgroundCpuTimeMs * Timestamp::kNanosecondsInMillisecond,
1134+
kFakeBackgroundCpuTimeNanos,
11351135
ordering,
11361136
fields,
11371137
expectedSortingOrder,
@@ -1160,7 +1160,7 @@ TEST_F(ShuffleTest, endToEndWithReplicateNullAndAny) {
11601160
numPartitions,
11611161
numMapDrivers,
11621162
{data},
1163-
kFakeBackgroundCpuTimeMs * Timestamp::kNanosecondsInMillisecond);
1163+
kFakeBackgroundCpuTimeNanos);
11641164
}
11651165

11661166
TEST_F(ShuffleTest, replicateNullsAndAny) {

presto-native-execution/velox

Submodule velox updated 49 files

0 commit comments

Comments
 (0)