Skip to content

Commit 3c7a7bc

Browse files
[yugabyte#28803] docdb: Canonicalize thread names for perf endpoint
Summary: The beta `/perf` endpoint generates flamegraphs. The default stack-collapse.pl script combines threads by name, but some of our threads have index numbers. This diff canonicalizes the thread names by truncating at the first numerical character and replacing all numbers with 0, so `prepare_347_wor` becomes `prepare_0`. (The code in this diff was created by @kfranz, I am just putting up the diff.) Jira: DB-18514 Test Plan: Checked perf endpoint and the stacks are correctly aggregated across workers now: {F404101} The stacks used to look like this, since each worker thread was a separate tower: {F404103} Reviewers: hsunder, kfranz Reviewed By: kfranz Subscribers: kfranz, ybase Differential Revision: https://phorge.dev.yugabyte.com/D47496
1 parent 56d7846 commit 3c7a7bc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/yb/tools/stackcollapse-perf.pl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ sub inline {
284284
}
285285
($m_pid, $m_tid, $m_period) = ($pid, $tid, $period);
286286

287+
# Normalize digits in the thread name (comm) to a single 0 and then
288+
# truncate at the first digit encountered so names like
289+
# "prepare_1_worker" and "prepare_347_wor" both become "prepare_0".
290+
if ($comm =~ /^(.*?)(\d)/) {
291+
$comm = $1 . "0";
292+
}
293+
287294
if ($include_tid) {
288295
$pname = "$comm-$m_pid/$m_tid";
289296
} elsif ($include_pid) {

0 commit comments

Comments
 (0)