[Truffle] Loop count propagation

Stefan Marr java at stefan-marr.de
Wed May 28 13:58:13 UTC 2014


Hi Chris:

On 28 May 2014, at 15:41, Chris Seaton <chris.seaton at oracle.com> wrote:

>> What’s the idea behind that change? I don’t know enough about the corresponding compiler heuristics, so, it is not directly obvious to me why you propagate the loop count up to the enclosing methods.
> 
> This change greatly improved warmup time and generated fewer compiled methods.

[...]

> To achieve that I pass the loop count to the first root node that isn’t a block (an anonymous function, in JS terms). I also pass it to all blocks in between, in case they can be compiled but the outer function can’t.

[...]

> The idea is to move the starting point, as you say. There’s no tiered compilation in Graal (I believe) so it’s not about getting more attention, it’s just about what gets compiled.
> 
> I don’t know how well this will apply to you, as you convert a call to while into a special while node, don’t you? So that means the loop count would already count for foo in your case I think? I don’t do that, so my call to loop and my call to the anonymous function are just normal calls for me and I need this special mechanism to pass the loop count up.

Thanks. And yes, I think it still applies. 
One reason is that I do not copy loop bodies into the while nodes. They are still DirectCallNodes. Which is the same for all the control structures. I rely there entirely on the DirectCallNodes doing the right thing. So, propagating up the loop count seems to be a good idea to get warmup down.


>> Also, you added branch probability to your while nodes and if nodes, what kind of impact do you see for that?
>> (one of the relevant commits was: Using CompilerDirectives.injectBranchProbability in the DoWhile nodes
>> https://github.com/jruby/jruby/commit/3845bbb106313bf7c4b0624a7fe8ac71940708b4)

[...]

> A more important use is in core library methods. Here in the Array#[]= method (assigning to an index in an array) I have branch profiles for the cases where the index is at the end, or beyond the end. This is almost always not needed, so we can usually remove it via a BranchProfile.

Ok, well, those things are entirely in SOM. Only few operations are currently optimized/reimplemented.
Not sure whether it is worthwhile to go further there, will see when I got the latest comparison numbers.

Thanks for the explanation
Stefan


-- 
Stefan Marr
INRIA Lille - Nord Europe
http://stefan-marr.de/research/





More information about the graal-dev mailing list