Skip to content

DNS: ui: Heap Dump Explorer diffing#5826

Open
zezeozue wants to merge 1 commit into
mainfrom
dev/zezeozue/heap_diff
Open

DNS: ui: Heap Dump Explorer diffing#5826
zezeozue wants to merge 1 commit into
mainfrom
dev/zezeozue/heap_diff

Conversation

@zezeozue
Copy link
Copy Markdown
Member

Adds a baseline-vs-current diff mode to the Heap Dump Explorer, introducing per-tab diff views (Overview, Classes, Objects, Dominators, Bitmaps, Strings, Arrays). This supports both same-trace workflows (multiple snapshots in one file) and cross-trace workflows (separate primary and baseline files).

A key feature is the same-trace flamegraph diff, which paints each node by its Δ direction while preserving the standard per-name palette hue. Grown nodes saturate and darken, shrunk nodes lighten and desaturate, unchanged nodes stay neutral, and new nodes receive a saturation boost. This ensures natural pprof-style color continuity between diff and non-diff modes rather than relying on absolute red/blue diff coloring.

@zezeozue zezeozue requested a review from a team as a code owner May 12, 2026 12:56
@zezeozue zezeozue force-pushed the dev/zezeozue/heap_diff branch from 151da1a to 17526b3 Compare May 12, 2026 13:08
@LalitMaganti
Copy link
Copy Markdown
Member

Wow exciting stuff! I'd love to test this but CI build seems to be failing. Will take a look immediately after the bot gives me a build!

…raph

Adds a baseline-vs-current diff mode to the Heap Dump Explorer with
per-tab diff views (Overview, Classes, Objects, Dominators, Bitmaps,
Strings, Arrays) and a same-trace flamegraph diff that paints each
node by Δ direction *while preserving the standard per-name palette
hue* — grew nodes saturate and darken, shrunk nodes lighten and
desaturate towards the background, unchanged nodes stay neutral, and
new nodes pop with a small saturation boost. The natural pprof-style
palette is intact so users see colour continuity between diff and
non-diff modes.
Both same-trace (two heap_graph snapshots in one .pftrace) and
cross-trace (separate primary + baseline .hprof or .pftrace files)
workflows are supported.

Changes vs. the upstream heap_diff branch (zezeozue/heap_diff):

- Fix engine-identity comparison in heap_dump_page.ts and
  baseline/state.ts. Trace.engine returns a fresh per-access proxy via
  createTraceProxy, so `getActiveBaseline()?.trace.engine === engine`
  is always false and the same-trace flamegraph diff path never fired.
  Use the stable `disposable === false` flag instead.
- Update header.ts to the new SegmentedButtons children-based API
  (selectedValue + SegmentedButton vnodes) — the upstream branch was
  written against the old `options:` prop and produced a runtime
  error.
- Replace the absolute hsl(0, ...) / hsl(220, ...) red/blue diff
  colouring with palette-modulated colours so each class keeps its
  natural pprof-style hue and we only modulate saturation/lightness
  to encode direction. Implemented in
  ui/src/widgets/flamegraph.ts (new modulatePaletteScheme helper +
  extended getColorSchemeFromHint signature) with the SQL emitting
  'palette:DIR[:INTENSITY]' hints.
- Add tools/heap_dump_diff_test_app/HeapDumpDiffTest.java: a real
  Java app that builds a deep, branchy Android-app-shaped object
  graph (Application → ActivityManager → Activity → … → byte[]) and
  captures two .hprof snapshots via HotSpotDiagnosticMXBean.dumpHeap
  for the cross-trace diff workflow.
- Add tools/heap_dump_diff_test_app/build_rich_fixture.py: textproto
  generator for the synthetic two-snapshot fixture used by the
  same-trace flamegraph diff test.
- Add docs/heap_diff/{README.md,screenshots/}: end-to-end screenshots
  of every diff tab and the primary-dump popup, captured against the
  rich fixture and against real JVM hprofs (cross-trace screenshots
  under cross_trace/).

Rebased onto current upstream/main so both the new
'Default to Heapdump Explorer' callout and the diff feature work
together.

Change-Id: I61f8e5e7f9988a89a7fd861b2e68ff9922568510
@zezeozue zezeozue force-pushed the dev/zezeozue/heap_diff branch from 17526b3 to 2e0868b Compare May 12, 2026 14:14
@github-actions
Copy link
Copy Markdown

🎨 Perfetto UI Builds

Copy link
Copy Markdown

@matteozanettii matteozanettii left a comment

Choose a reason for hiding this comment

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

Suggestion: the checks may have failed due to the the file's size

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.

3 participants