Skip to content

SPMI: per-context tpdiff examples#129948

Merged
AndyAyersMS merged 4 commits into
dotnet:mainfrom
AndyAyersMS:andyayersms/tpdiff-context-examples
Jun 30, 2026
Merged

SPMI: per-context tpdiff examples#129948
AndyAyersMS merged 4 commits into
dotnet:mainfrom
AndyAyersMS:andyayersms/tpdiff-context-examples

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Add a "top method regressions / improvements" section to the tpdiff markdown summary, mirroring how asmdiffs surfaces specific contexts. The per-context data already lives in the details CSV; aggregate it once and emit FullOpts/MinOpts top-N tables by PDIFF %.

Release JITs don't currently report MethodFullName, so the table also shows the SPMI context number for fallback lookup via mcs -dumpMap or superpmi -c N.

Fixes #85755.

Add a "top method regressions / improvements" section to the tpdiff
markdown summary, mirroring how asmdiffs surfaces specific contexts.
The per-context data already lives in the details CSV; aggregate it
once and emit FullOpts/MinOpts top-N tables by PDIFF %.

Release JITs don't currently report `MethodFullName`, so the table also
shows the SPMI context number for fallback lookup via `mcs -dumpMap` or
`superpmi -c N`.

Fixes dotnet#85755.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 28, 2026 16:42
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 28, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@jakobbotsch PTAL
fyi @dotnet/jit-contrib


Sample output

Existing pivot section (unchanged):

Overall (-4.84%)
Collection PDIFF
benchmarks.run.windows.x64.checked.mch -4.84%
FullOpts (-4.82%)
Collection PDIFF
benchmarks.run.windows.x64.checked.mch -4.82%

New per-context section (trimmed here to top 5 of each; the actual report shows top 20):

Top method regressions (FullOpts, by PDIFF %)
Collection Context Method Base Diff PDIFF
benchmarks.run.windows.x64.checked.mch 224 <no name reported by JIT> 77,320 122,551 +58.50%
benchmarks.run.windows.x64.checked.mch 32723 <no name reported by JIT> 78,626 123,097 +56.56%
benchmarks.run.windows.x64.checked.mch 42681 <no name reported by JIT> 91,558 143,311 +56.52%
benchmarks.run.windows.x64.checked.mch 8751 <no name reported by JIT> 57,133 87,846 +53.76%
benchmarks.run.windows.x64.checked.mch 1631 <no name reported by JIT> 57,165 87,876 +53.72%
Top method improvements (FullOpts, by PDIFF %)
Collection Context Method Base Diff PDIFF
benchmarks.run.windows.x64.checked.mch 12166 <no name reported by JIT> 1,392,193 1,170,242 -15.94%
benchmarks.run.windows.x64.checked.mch 52652 <no name reported by JIT> 165,001 138,917 -15.81%
benchmarks.run.windows.x64.checked.mch 18230 <no name reported by JIT> 156,170 132,310 -15.28%
benchmarks.run.windows.x64.checked.mch 33041 <no name reported by JIT> 1,351,314 1,146,456 -15.16%
benchmarks.run.windows.x64.checked.mch 9415 <no name reported by JIT> 219,937 187,271 -14.85%

The Method column is empty here because Release JITs (what tpdiff uses) don't currently
emit MethodFullName via reportMetadata — see compiler.cpp:311-322, which gates the
report on DEBUG || LATE_DISASM || DUMP_FLOWGRAPHS. The Context number is included so
the method can still be resolved via e.g. DOTNET_JitDisasm=* superpmi -c <N> <jit> <mch>
(verified: context 224 above is System.Net.SocketAddress:.cctor()). A small follow-up
to emit MethodFullName unconditionally would let this column populate directly.

@AndyAyersMS AndyAyersMS requested a review from jakobbotsch June 28, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds per-context throughput “examples” to SuperPMI tpdiff markdown summaries by extracting per-context instruction deltas from the existing details CSV and emitting top-N regression/improvement tables (split by FullOpts/MinOpts). Also updates the tuple shape flowing through aggregate_diff_metrics/tpdiff reporting and makes the markdown writer tolerant of older 3-tuple JSON summaries.

Changes:

  • Extend aggregate_diff_metrics() to collect per-context throughput diffs (base vs diff instruction counts) and return them to callers.
  • Plumb per-context throughput data through replay_with_throughput_diff() and into markdown summary generation.
  • Add a new markdown section that lists top per-context regressions/improvements (FullOpts and MinOpts) by PDIFF%.

Comment thread src/coreclr/scripts/superpmi.py
Comment thread src/coreclr/scripts/superpmi.py Outdated
Comment thread src/coreclr/scripts/superpmi.py Outdated
Comment thread src/coreclr/scripts/superpmi.py Outdated
Comment thread src/coreclr/scripts/superpmi.py Outdated
- Drop legacy 3-tuple tolerance and the try/except / .get defensive paths;
  callers always produce the current shape.
- Bound per-context tp_diff retention via four top-K heaps (200 each) so very
  large MCH files can't blow up memory.
- Escape '|' / HTML / newlines in markdown cells; drop the HTML-looking
  "<no name reported by JIT>" placeholder (use an empty cell instead).
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@tannergooding @jakobbotsch can you re-review?

@tannergooding tannergooding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes still LGTM, functionally speaking. Jakob is much more familiar with the long term implementation and goals of the script

Comment thread src/coreclr/scripts/superpmi.py Outdated
Copilot AI review requested due to automatic review settings June 29, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread src/coreclr/scripts/superpmi.py
Comment thread src/coreclr/scripts/superpmi.py
Comment thread src/coreclr/scripts/superpmi.py
Comment thread src/coreclr/scripts/superpmi.py
Comment thread src/coreclr/scripts/superpmi.py

@jakobbotsch jakobbotsch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@AndyAyersMS AndyAyersMS merged commit a20d778 into dotnet:main Jun 30, 2026
111 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPMI: Give specific context examples for tpdiff

4 participants