Skip to content

SPMI: per-context tpdiff examples#129948

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:andyayersms/tpdiff-context-examples
Open

SPMI: per-context tpdiff examples#129948
AndyAyersMS wants to merge 1 commit 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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@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 on lines +2009 to +2013
# Per-context throughput diffs (rows where PIN measured base != diff
# instruction count). Used by tpdiff to surface specific method examples.
tp_diffs_fields = ["Context", "Method full name", "MinOpts", "Base instructions", "Diff instructions"]
tp_diffs = []

Comment on lines +3406 to +3414
# Release JITs don't report MethodFullName; fall back to context number.
method = r["Method full name"] or "<no name reported by JIT>"
write_fh.write("|{}|{}|{}|{:,d}|{:,d}|{}|\n".format(
r["Collection"],
r["Context"],
method,
r["Base instructions"],
r["Diff instructions"],
compute_and_format_pct(r["Base instructions"], r["Diff instructions"])))
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

2 participants