Skip to content

Differential Flame Graph enhancements: total-diff calculation and additional rendering customisation#329

Open
gielzak wants to merge 7 commits into
brendangregg:masterfrom
gielzak:master
Open

Differential Flame Graph enhancements: total-diff calculation and additional rendering customisation#329
gielzak wants to merge 7 commits into
brendangregg:masterfrom
gielzak:master

Conversation

@gielzak
Copy link
Copy Markdown

@gielzak gielzak commented Feb 12, 2024

Overview:

This pull request introduces an opt-in total-diff calculation method for Differential Flame Graphs, complementing the existing self-diff approach. Additionally, it adds two new flags for diff rendering customisation.

TL;DR: see Demos section below

Proposed changes:

New flags:

  • --totaldiff: aggregates diff values (i.e. uses total-diff not self-diff) when calculating differential hues
  • --mindeltapc NUM: min delta (as % of function duration) to use diff hues (allows to reduce noise from insignificant changes)
  • --fillopacity NUM: fill-opacity for drawn rectangles (SVG attribute; helps with method name readability)

Self-diff vs Total-diff:

Self-diff vs total-diff are based on self-time vs total-time. Basic example below:

  • Base Trace (f1: 25%; f2: 25%; f3: 25%; f4: 25%):
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f1 20
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f1;getTime 5
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f2 25
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f3 25
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f4 25
  • Current Trace (f1: 20%; f2: 30%; f3: 10%; f4: 40%):
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f1 20
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f2 30
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f3 10
  Benchmark.measure;PerfettoSdkBenchmark.basic;f0;f4 40

Self-diff doesn't highlight the performance gain in f1 (25% -> 20%), while total-diff captures this. See Demos section below for illustration.

Demos:

All hosted as interactive demos on https://gielzak.github.io/flamegraph-demos-totaldiff

@gielzak
Copy link
Copy Markdown
Author

gielzak commented Feb 13, 2024

I cleaned-up the pull-request message a bit. It'd be great if you could review this and let me know what you think. I'd be happy to add tests (it didn't seem straightforward to extend existing ones) and/or adjust the changes to suit your coding conventions / vision for the tool.

The "total-diff" approach is more in line with what https://github.com/google/pprof would produce as diffs.

Note that in the demos (linked in the pull-request message) you can switch between graphs using the buttons at the top:

  • base (flamegraph for the "diff base" trace)
  • base-vs-current (differential flame graph with stacks from "base" trace and hues calculated based on the "current" trace)
  • current (flamegraph for the "current" trace)
  • current-vs-base (differential flame graph with stacks from "current" trace and hues calculated based on the "base" trace)

Also, note that the pull-request is split into small commits (hopefully easier to review).

Let me know what you think, and thank you for creating this awesome tool / approach to perf visualisation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant