Skip to content

Commit 952aede

Browse files
authored
[fix](be) Rename CPU time profile counter (apache#64238)
Problem Summary: Runtime profiles had a CPU-time counter named MaxFindRecvrTime(NS), while the naming convention for CPU-time counters is to include CpuTime directly in the counter name. This makes it hard to distinguish CPU-time counters from wall-time counters by name. Rename the exchange receiver counter to MaxFindRecvrCpuTime(NS), keep existing TaskCpuTime and ScannerCpuTime names without an extra suffix, and cover the expected profile names in BE unit tests and the existing scanner profile regression test.
1 parent 3ece7b5 commit 952aede

4 files changed

Lines changed: 46 additions & 3 deletions

File tree

‎be/src/exec/exchange/vdata_stream_recvr.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ VDataStreamRecvr::VDataStreamRecvr(VDataStreamMgr* stream_mgr,
417417
_blocks_produced_counter = ADD_COUNTER(_profile, "BlocksProduced", TUnit::UNIT);
418418
_max_wait_worker_time = ADD_COUNTER(_profile, "MaxWaitForWorkerTime", TUnit::UNIT);
419419
_max_wait_to_process_time = ADD_COUNTER(_profile, "MaxWaitToProcessTime", TUnit::UNIT);
420-
_max_find_recvr_time = ADD_COUNTER(_profile, "MaxFindRecvrTime(NS)", TUnit::UNIT);
420+
_max_find_recvr_time = ADD_COUNTER(_profile, "MaxFindRecvrCpuTime(NS)", TUnit::UNIT);
421421
}
422422

423423
VDataStreamRecvr::~VDataStreamRecvr() {

‎be/test/exec/pipeline/vdata_stream_recvr_test.cpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <functional>
2424
#include <memory>
2525
#include <mutex>
26+
#include <sstream>
2627
#include <thread>
2728
#include <vector>
2829

@@ -91,6 +92,23 @@ TEST_F(DataStreamRecvrTest, TestCreateSenderQueue) {
9192
}
9293
}
9394

95+
TEST_F(DataStreamRecvrTest, CpuTimeCounterNamesAreMarked) {
96+
create_recvr(1, false);
97+
98+
EXPECT_NE(_mock_profile->get_counter("MaxFindRecvrCpuTime(NS)"), nullptr);
99+
EXPECT_EQ(_mock_profile->get_counter("MaxFindRecvrTime(NS)"), nullptr);
100+
EXPECT_EQ(_mock_profile->get_counter("MaxFindRecvrTime(NS) (Cpu Time)"), nullptr);
101+
102+
std::stringstream ss;
103+
_mock_profile->pretty_print(&ss);
104+
const auto profile_text = ss.str();
105+
EXPECT_NE(profile_text.find("- MaxFindRecvrCpuTime(NS):"), std::string::npos);
106+
EXPECT_EQ(profile_text.find("- MaxFindRecvrTime(NS):"), std::string::npos);
107+
EXPECT_EQ(profile_text.find("- MaxFindRecvrTime(NS) (Cpu Time):"), std::string::npos);
108+
109+
recvr->close();
110+
}
111+
94112
TEST_F(DataStreamRecvrTest, TestSender) {
95113
create_recvr(3, false);
96114
EXPECT_EQ(recvr->sender_queues().size(), 1);

‎be/test/runtime/runtime_profile_test.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,33 @@
2424

2525
#include "common/exception.h"
2626
#include "common/object_pool.h"
27+
#include "runtime/runtime_profile_counter_names.h"
2728

2829
using namespace std;
2930

3031
namespace doris {
3132

3233
class RuntimeProfileTest : public testing::Test {};
3334

35+
TEST(RuntimeProfileTest, CpuTimeCounterNamesAreMarked) {
36+
RuntimeProfile profile("ProfileWithCpuTime");
37+
ADD_TIMER(&profile, profile::TASK_CPU_TIME)->set(int64_t {1000});
38+
ADD_TIMER(&profile, profile::SCANNER_CPU_TIME)->set(int64_t {2000});
39+
40+
EXPECT_NE(profile.get_counter("TaskCpuTime"), nullptr);
41+
EXPECT_NE(profile.get_counter("ScannerCpuTime"), nullptr);
42+
EXPECT_EQ(profile.get_counter("TaskCpuTime (Cpu Time)"), nullptr);
43+
EXPECT_EQ(profile.get_counter("ScannerCpuTime (Cpu Time)"), nullptr);
44+
45+
std::stringstream ss;
46+
profile.pretty_print(&ss);
47+
const auto profile_text = ss.str();
48+
EXPECT_NE(profile_text.find("- TaskCpuTime:"), std::string::npos);
49+
EXPECT_NE(profile_text.find("- ScannerCpuTime:"), std::string::npos);
50+
EXPECT_EQ(profile_text.find("- TaskCpuTime (Cpu Time):"), std::string::npos);
51+
EXPECT_EQ(profile_text.find("- ScannerCpuTime (Cpu Time):"), std::string::npos);
52+
}
53+
3454
TEST(RuntimeProfileTest, Basic) {
3555
RuntimeProfile profile_a("ProfileA");
3656
RuntimeProfile profile_a1("ProfileA1");

‎regression-test/suites/query_profile/scanner_profile.groovy‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ suite('scanner_profile') {
7777
List profileData = profileAction.getProfileList()
7878
def profileWithLimit1 = getProfileByToken(token)
7979
logger.info("${token} Profile Data: ${profileWithLimit1}")
80+
assertTrue(profileWithLimit1.toString().contains("- TaskCpuTime:"))
8081
assertTrue(profileWithLimit1.toString().contains("- MaxScanConcurrency: 1"))
8182

8283
token = UUID.randomUUID().toString()
@@ -86,12 +87,16 @@ suite('scanner_profile') {
8687

8788
String profileWithFilter = getProfileByToken(token)
8889
logger.info("${token} Profile Data: ${profileWithFilter}")
90+
assertTrue(profileWithFilter.toString().contains("- TaskCpuTime:"))
91+
assertTrue(profileWithFilter.toString().contains("- ScannerCpuTime:"))
92+
assertFalse(profileWithFilter.toString().contains("- TaskCpuTime (Cpu Time):"))
93+
assertFalse(profileWithFilter.toString().contains("- ScannerCpuTime (Cpu Time):"))
8994
// Verify actualRows is backfilled onto the scan node. The exact value is
9095
// unstable because 9 INT keys hash-distribute into 10 buckets and a few
9196
// tablets may be pruned at runtime, so only assert it is in [1, 9].
92-
def matcher = (profileWithFilter.toString() =~ /PhysicalOlapScan\[scanner_profile\][^\n]*actualRows=(\d+)/)
97+
def matcher = (profileWithFilter.toString() =~ /PhysicalOlapScan[^\n]*scanner_profile[^\n]*actualRows=(\d+)/)
9398
assertTrue(matcher.find(), "actualRows not found on PhysicalOlapScan[scanner_profile] in profile")
9499
int actualRows = matcher.group(1) as int
95100
assertTrue(actualRows >= 1 && actualRows <= 9,
96101
"expect actualRows in [1, 9], got ${actualRows}")
97-
}
102+
}

0 commit comments

Comments
 (0)