Skip to content

SPMI: Fixes to record-and-replay workflows#125981

Merged
jakobbotsch merged 5 commits intodotnet:mainfrom
jakobbotsch:skip-compileresults-superpmi
Mar 30, 2026
Merged

SPMI: Fixes to record-and-replay workflows#125981
jakobbotsch merged 5 commits intodotnet:mainfrom
jakobbotsch:skip-compileresults-superpmi

Conversation

@jakobbotsch
Copy link
Copy Markdown
Member

Three fixes:

  • Skip reading compile results for superpmi replay. If the collection has compile results we never want to reuse them for superpmi replay. Various recording functions do not work properly when there already are existing compile results -- e.g. recAllocMem will keep the old instruction buffer instead of the new one from the replay.

  • Support passing a directory to -mch_files, and allow .mc files passed to -mch_files

  • Fix diffs report generation when a collection has zero succeeding contexts. Previously we would hit a division-by-zero error.

Three fixes:

- Skip reading compile results for superpmi replay. If the collection
  has compile results we never want to reuse them for superpmi replay.
  Various recording functions do not work properly when there already
  are existing compile results -- e.g. `recAllocMem` will keep the old
  instruction buffer instead of the new one from the replay.

- Support passing a directory to -mch_files, and allow .mc files passed
  to -mch_files

- Fix diffs report generation when a collection has zero succeeding
  contexts. Previously we would hit a division-by-zero error.
Copilot AI review requested due to automatic review settings March 23, 2026 17:30
@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 Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves SuperPMI record/replay robustness by preventing reuse of stored compile results during replay, expanding -mch_files input support (directories and .mc files), and hardening summary generation when collections contain no successful contexts.

Changes:

  • Add a readCompileResults switch to MethodContext::Initialize and disable compile-result loading for replay paths.
  • Extend superpmi.py to accept directories for -mch_files and include .mc alongside .mch in discovery.
  • Avoid division-by-zero in diffs summary generation when total contexts is zero.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/coreclr/tools/superpmi/superpmi/superpmi.cpp Disable reading compile results during replay and reset compile-result state.
src/coreclr/tools/superpmi/superpmi/streamingsuperpmi.cpp Disable reading compile results when loading contexts for streaming replay.
src/coreclr/tools/superpmi/superpmi-shared/methodcontextreader.cpp Explicitly request compile-result loading where needed (hash workflow).
src/coreclr/tools/superpmi/superpmi-shared/methodcontextiterator.cpp Explicitly request compile-result loading for iterator-based reads.
src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h Add readCompileResults parameter to initialization helpers/overloads.
src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp Gate compile-result map deserialization on readCompileResults.
src/coreclr/tools/superpmi/mcs/verbstrip.cpp Use the new readCompileResults flag to implement CR stripping.
src/coreclr/scripts/superpmi.py Accept directories for -mch_files, include .mc, and guard percentage computations.
Comments suppressed due to low confidence (1)

src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp:188

  • The updated static Initialize(unsigned char* ...) overload takes readCompileResults, but the implementation still calls the instance Initialize(mcIndex, buff, size) without passing it. This won’t compile and also ignores the caller’s intent. Pass readCompileResults through to the instance Initialize call.
{
    MethodContext* mc = new MethodContext();
    mc->index         = mcIndex;
    *ppmc             = mc;
    return mc->Initialize(mcIndex, buff, size);

Copilot AI review requested due to automatic review settings March 23, 2026 17:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated no new comments.

@jakobbotsch
Copy link
Copy Markdown
Member Author

PTAL @dotnet/jit-contrib

@jakobbotsch jakobbotsch requested a review from a team March 24, 2026 08:45
@jakobbotsch
Copy link
Copy Markdown
Member Author

@EgorBo Can you take a look?

@jakobbotsch jakobbotsch requested a review from EgorBo March 30, 2026 09:56
@jakobbotsch jakobbotsch merged commit 7c91160 into dotnet:main Mar 30, 2026
99 of 101 checks passed
@jakobbotsch jakobbotsch deleted the skip-compileresults-superpmi branch March 30, 2026 10:35
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.

3 participants