Increase JIT compiler throughput
The following is a list of areas being considered for throughput improvements in the near future; if anyone wants to help with these just add a note here, if we have lots of volunteers we can establish a simple tracking system. Note that the stuff gathered in this issue addresses the specific goal of speeding up IL -> machine code conversion in RyuJIT - IOW, things like better heuristics to decide when to use / not use MinOpts, finding more ways to avoid compilation at runtime (via crossgen or whatever) are not covered here.
- Importing IL (typically takes 25% of overall JIT time):
- Cache results of calling through ICorJitInfo, such as IL token resolution:
- Option 1 - do this only for large methods, no caching across compilations.
- Option 2 - cache things "globally", across methods; requires retention policy.
- Cache the internal format of carefully chosen methods that are frequently inlined:
- This only helps "normal opts" unless we extend MinOpts to do "fast" inlining.
- Needs retention policy so memory (and any overhead for serializing the IR) is not wasted.
- Closely tied to the inliner so this should probably be integrated into the inline policy / etc logic.
- Recognize a tiny subset of trivial IL body patterns; for matched methods:
- Spit out "canned" IR to bypass the "full" import logic.
- Mark "trivial" bodies (or parts of bodies?) and add simplified processing downstream for such bodies (e.g. no jumps, no stores to locals, or whatever).
- Find the most frequent paths through the most expensive JIT -> EE calls, and try to speed them up:
- For some calls the JIT may not need all the information the EE is currently returning -> add shortcuts and/or subset versions?
- Batch / overlap / defer EE calls:
- This has ramifications for class loading order / etc, so feasibility is an open question.
- When the importer asks about tokens / methods / fields it doesn't need all the info immediately; split the relevant (expensive) EE calls into two parts, the first - hopefully much faster than the whole - would only return the minimal info the importer must have right away, the rest could come on a separate thread / via an asynch callback or something like that.
- If we do any "quick look at IL" processing (e.g. to do some of the stuff above for "trivial" methods) we could fire off calls to ask about the tokens we encounter.
- Cache results of calling through ICorJitInfo, such as IL token resolution:
- Speed up genGenerateCode, i.e. the far back end (takes about 10-20% of total time):
- Speed up GC info gathering and encoding:
- GC encoder: avoid sorting when possible, speed up bit-twiddling, etc.
- Instruction encoding: try to speed up the most frequent emitXxxxx methods, emitter::emitGCregLiveUpd()
- Speed up GCInfo::gcMakeRegPtrTable() and related logic.
- Other things, such as the scope tracking stuff (CodeGen::siBeginBlock etc).
- Note: probably ignore CodeGen::genCodeForTreeNode() even though it's up to 5% - way too many little pieces.
- Speed up GC info gathering and encoding:
- Speed up LSRA (around 20% of total compile time) and make it consume a lot less memory:
- Punting this entirely to the RA specialists.
- Slim down Lowering::DoPhase (currently up to 10% of JIT time):
- Completely bypass fgInterBlockLocalVarLiveness() - up to 2% of total time.
- Avoid doing lvaSortByRefCount() for very small numbers of variables (0.5% of total time).
- Other things? Returns probably diminish rapidly.
- Speed up Morph (around 8% of total compile time):
- Spend less time spent recursively walking trees for MinOpts.
- Global improvements (few percent):
- Shrink GenTree nodes.
- Speed up tree walks.
- Allocate memory in larger chunks.
- Skip more things for MinOpts (few percent):
- Skip (parts of) liveness analysis (also see above)?
- Bypass some tree optimizations (just do the simplest / easiest thing).
- Skip "ordering" passes (evalOrder/blockOrder) for trivial or reducible CFG's or some such.
- Short-cut things like lvaSortByRefCount() for small numbers of variables, etc.
category:throughput theme:throughput skill-level:expert cost:extra-large
Count me in. I'd like to help on this.
It's worth looking at each item in the list considering there may be possible throughput wins.