runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Reuse internal format of inlined methods

Open pkukol opened this issue 10 years ago • 3 comments

Converting IL to the tree-based IR is a fairly expensive operation which is often repeated many times for the same inlined methods; see if we can retain this IR for popular inlinee's (e.g. by serializing the trees or a similar contrivance). Of course keeping this IR around across compiles could waste memory so a suitable policy needs to be developed to maximize the benefit.

category:throughput theme:throughput skill-level:expert cost:large

pkukol avatar Oct 03 '16 14:10 pkukol

While this is an interesting idea, it is probably not viable.

When reading the inlinee the jit will directly substitute argument trees from the caller into the callee. So the callee IR is already tailored to a particular call site and can't easily be reused at another call site. And important decisions are made in this context-sensitive callee importation -- for instance the viability of callee call sites for inlining, or the eager pruning of unreachable blocks -- that may also be context dependent.

One could imagine trying to read a callsite neutral format and then later adapt the IR with callsite specific knowledge, but I suspect we'd sacrifice CQ and the TP wins are less clear when we need to do extensive rework of the IR versus just reimportation. And managing the callee cache (or anticipating when caching is worth the trouble is also likely to be tricky.

AndyAyersMS avatar May 04 '18 17:05 AndyAyersMS

IMO it would be much better to simply recognize some trivial and common cases - (e.g. ldarg;ldfld;ret - a typical property getter). That wouldn't need any complex caching, it would be just some sort of inlining fast path.

As is now, inlining such simple methods is very costly - initialize the inlinee compiler, scan IL for basic blocks, import the IL and then finally link the imported nodes into the inliner IR (which doesn't always provide best results).

mikedn avatar May 04 '18 18:05 mikedn

There may be a case for small/trivial methods, but I'm a little skeptical of how much it would actually improve for throughput, especially since we have a tiered JIT. Keeping this as future.

TIHan avatar Nov 01 '23 21:11 TIHan