Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: consider priority driven importation #12041

Closed
AndyAyersMS opened this issue Feb 14, 2019 · 3 comments
Closed

JIT: consider priority driven importation #12041

AndyAyersMS opened this issue Feb 14, 2019 · 3 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@AndyAyersMS
Copy link
Member

The order of importation of blocks can impact the allocation of fast dictionary slots (see notes in #11971).

The jit currently imports IL code via an implicit depth first search:

  • impImportBlock pends successors in GetSucc order
  • For BBJ_COND, GetSucc returns fall through blocks before jumped-to blocks
  • impImportBlockPending prepends to the pending block list

As a result dictionary slot assignments might be favorably influenced by trying to import the most performance-sensitive blocks first.

Note this may also be mitigated or fixed in the runtime if we can determine the number of needed slots.

Some ideas:

Short term

impImportBlock can try and prioritize among its successors via some heuristic. For instance a branch guarding a return might be considered a fast path.

Long term

Because of evaluation stack modelling the jit can't simply start importation at any point -- blocks that are not stack empty on entry must wait until at least one predecessor has been imported (in fact this is how we discover if a block is stack empty, so in the current importer the only block that we can safely start with is the entry block). But we could do a better job of stack modelling during the IL opcode prescan (where we build the flow graph) and determine the set of stack empty blocks up front.

And, if in conjunction, we ran profile synthesis, or imported IBC profile data, or had a lower tier jit producing profile data that we could access, we'd have a priority ordering for blocks.

category:cq
theme:inlining
skill-level:expert
cost:large

@jkotas
Copy link
Member

jkotas commented Feb 14, 2019

Note that there is a similar problem at larger scope: The order in which generic methods get compiled can affect whether they get the fast slots or not. People did notice this number of times - there are bugs on this in the internal bug database.

I think we should rather fix this in the runtime by making the number of the fast generic slots dynamically adjustable.

@AndyAyersMS
Copy link
Member Author

I agree, but was not sure if/when/how comprehensively you can fix this in the runtime.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@AndyAyersMS
Copy link
Member Author

Now that we've got dynamically adjustable dictionary slots (#32270 and follow-on PRs), this is probably not worth pursuing.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 14, 2020
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

No branches or pull requests

3 participants