Skip to content

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jul 8, 2025

Static cctors tend to be huge and single-edge (e.g. some List or Dictionary static field initialized with a lot of items inline) - if they're compiled with JIT optimizations (TC=0 or dynamic context) - they should not receive an extra inlining boost from #116054. Same for just large single-edge methods.

@Copilot Copilot AI review requested due to automatic review settings July 8, 2025 15:20
@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 Jul 8, 2025
Copy link
Contributor

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

Copy link
Contributor

@Copilot 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 refines the JIT’s optimization mask and enhances profile synthesis to avoid giving inlining boosts to static constructors or large single-edge methods.

  • Reduced the set of flags in CLFLG_MAXOPT to a smaller subset.
  • In ProfileSynthesis::Run, skip fgPgoSingleEdge for static constructors, size-optimized methods, or methods with many calls.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/jit.h Updated CLFLG_MAXOPT to only include a few core optimizations
src/coreclr/jit/fgprofilesynthesis.cpp Added checks to disable single-edge PGO for cctors, size-opt, and call-heavy methods
Comments suppressed due to low confidence (2)

src/coreclr/jit/jit.h:757

  • Add or update a comment above this macro explaining why certain flags were removed and what the new target optimization level represents.
#define CLFLG_MAXOPT (CLFLG_REGVAR | CLFLG_TREETRANS | CLFLG_INLINING | CLFLG_STRUCTPROMOTE)

src/coreclr/jit/fgprofilesynthesis.cpp:256

  • Consider adding tests or a profiling scenario to verify that static constructors and methods exceeding the call threshold are not granted fgPgoSingleEdge.
    m_comp->fgPgoSingleEdge = !isCctor && !preferSize;

@EgorBo
Copy link
Member Author

EgorBo commented Jul 8, 2025

@AndyAyersMS anything else? cc @dotnet/jit-contrib

@EgorBo EgorBo requested a review from AndyAyersMS July 8, 2025 18:38
Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Did you try it out on methods like the .cctor that we looked at the other day?

From the diffs at least it looks like it is doing what we expect.

@EgorBo
Copy link
Member Author

EgorBo commented Jul 8, 2025

Did you try it out on methods like the .cctor that we looked at the other day?

From the diffs at least it looks like it is doing what we expect.

Yep, checked locally.

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

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.

2 participants