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

A better explanation for change in differentials #294

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion flamegraph
Submodule flamegraph updated 34 files
+1 −2 README.md
+15 −74 flamegraph.pl
+3 −9 stackcollapse-bpftrace.pl
+0 −61 stackcollapse-faulthandler.pl
+0 −145 stackcollapse-ibmjava.pl
+7 −15 stackcollapse-instruments.pl
+16 −21 stackcollapse-perf.pl
+1 −1 stackcollapse-pmc.pl
+0 −103 stackcollapse-vtune-mc.pl
+3 −3 stackcollapse-xdebug.php
+10 −10 test/results/perf-dd-stacks-01-collapsed-addrs.txt
+10 −10 test/results/perf-dd-stacks-01-collapsed-all.txt
+10 −10 test/results/perf-dd-stacks-01-collapsed-jit.txt
+10 −10 test/results/perf-dd-stacks-01-collapsed-kernel.txt
+10 −10 test/results/perf-dd-stacks-01-collapsed-pid.txt
+10 −10 test/results/perf-dd-stacks-01-collapsed-tid.txt
+7 −7 test/results/perf-java-faults-01-collapsed-addrs.txt
+7 −7 test/results/perf-java-faults-01-collapsed-all.txt
+7 −7 test/results/perf-java-faults-01-collapsed-jit.txt
+7 −7 test/results/perf-java-faults-01-collapsed-kernel.txt
+9 −9 test/results/perf-java-faults-01-collapsed-pid.txt
+9 −9 test/results/perf-java-faults-01-collapsed-tid.txt
+26 −26 test/results/perf-java-stacks-01-collapsed-pid.txt
+26 −26 test/results/perf-java-stacks-01-collapsed-tid.txt
+1 −1 test/results/perf-java-stacks-02-collapsed-pid.txt
+1 −1 test/results/perf-java-stacks-02-collapsed-tid.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-addrs.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-all.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-jit.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-kernel.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-pid.txt
+45 −45 test/results/perf-rust-Yamakaky-dcpu-collapsed-tid.txt
+191 −191 test/results/perf-vertx-stacks-01-collapsed-pid.txt
+191 −191 test/results/perf-vertx-stacks-01-collapsed-tid.txt
35 changes: 22 additions & 13 deletions src/flamegraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,21 +616,30 @@ where
"{} ({} {}, {:.2}%)",
function, samples_txt, opt.count_name, pct
),
// Special case delta == 0 so we don't format percentage with a + sign.
Some(delta) if delta == 0 => write!(
buffer,
"{} ({} {}, {:.2}%; 0.00%)",
function, samples_txt, opt.count_name, pct,
),
Some(mut delta) => {
if opt.negate_differentials {
delta = -delta;
}
let delta_pct = (100 * delta) as f64 / (timemax as f64 * opt.factor);
Some(delta) => {
let samples = frame.end_time as isize - frame.start_time as isize;
let (old, new) = if opt.negate_differentials {
(samples, samples - delta)
} else {
(samples - delta, samples)
};
let change = match (old, new) {
(0, _) => "all newly added".to_string(),
(_, 0) => "were all removed".to_string(),
Comment on lines +627 to +628
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these labels still make sense if negate_differentials is on.

(x, y) if x == y => "".to_string(),
(old, new) => {
let (ratio, compared_to) = if opt.negate_differentials {
(old as f64 / new as f64, "new")
} else {
(new as f64 / old as f64, "old")
};
format!(" = {ratio:.3} × {compared_to} {}", opt.count_name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow the phrasing here. If, for example, we spend 2x as many samples in some frame, this will look like (I think):

= 2 × old cycles

Which I think is maybe overly concise. It doesn't include the function name (is that printed elsewhere?), and the old or new sample counts. I think we'll want to include at least the function name and one of the two absolute numbers. I'm also not sure if "old" and "new" are understandable labels in this instance (esp. for negate_differentials) — they may even be unnecessary. I think "2×cycles" may actually be sufficient.

}
};
write!(
buffer,
"{} ({} {}, {:.2}%; {:+.2}%)",
function, samples_txt, opt.count_name, pct, delta_pct
"{} ({} {} {}, {:.2}%)",
function, samples_txt, opt.count_name, change, pct
)
}
}
Expand Down
Loading