Hi��Thierry,

On Tue, Sep 16, 2014 at 1:06 AM, Thierry Goubier <thierry.goubier@gmail.com> wrote:


2014-09-16 1:46 GMT+02:00 Eliot Miranda <eliot.miranda@gmail.com>:

Ah! ��But! ��Sista has an advantage that other adaptive optimizers don't. ��Because it optimizes from bytecode to bytecode it can be used during a training phase and then switched off.

Great.

Would it also be possible from the outside to make sista-like optimisations? I'm thinking of a few possibilities such as replacing some dictionary constant building code and a few others (i.e. a kind of [ ] once and the #(( )) of Dolphin) which could be handled at the user level (by tracking if it has to be recompiled if someone, say, changes the implementation of Dictionary).

There is no "outside" in Sista. ��It is an image-level optimizer, so you'll be able to interact with it at the same level one interacts with the Opal compiler. ��Of course doing this kind of strength-reduction is possible.


Real time applications requires an upper bound guarantee in their response time. In some cases, the lack of this guarantee can be just an annoyance, as happens in video games. In some mission critical applications the results can not be good, if this time constraint is not met. An example of a mission critical system could the flight controls of an airplane, or the cooling system of a nuclear reactor.

For these application, it is not possible to rely in an adaptive optimizer that can be triggered sometimes. In these application you have to either:
- Extend the language to hand optimize some performance critical sections of code.
- Use another language to optimize these critical section.
- Use another language for the whole project.

The additional option is to "train" the optimizer by running the application before deploying and capturing the optimised methods. ��Discuss this with Cl��ment and he'll explain how straight-forward it should be. ��This still leaves the latency in the Cogit when it compiles from bytecode to machine code. ��But

a) I've yet to see anybody raise JIT latency as an issue in Cog

How many instructions you spend on average in Cog per generated instruction?

I have no idea. ��All I know is that the code generation side of the Cogit is extremely cheap, dwarfed by the costs of relinking when code is recompiled. ��But the cost is vanishingly small. ��The costs that do show up in the Cogit are the cost of discarding, compacting and relinking code when the working set grows (e.g. Compiler recompileAll), and pause times here are ~ 1ms on my 2.2GHz MBP; thats about twice the cost of a scavenge, at about 1/20th the frequency (these times are for Spur). If you open up the system reporter you'll be able to see for yourself. ��And if you use the VMProfiler you can see exactly here the time goes for your favourite synthetic benchmark. ��See if you can figure out how to create bytecoded methods cheaper than the JIT can compile them and profile it.

If you've got a tool that can count instructions let me know and I may measure. ��I could could bytecodes per instruction generated in the simulator ;-).
��
b) it would be easy to extend the VM to cause the Cogit to precompile specified methods. ��We could easily provide a "lock-down" facility that would prevent Cog from discarding specific machine code methods.

That one is interesting. It sounds like a great benefit would be to have a limited API to the Cog JIT for that sort of requirements.

And of course, you have to perform lot of profiling.

Early and often :-).

Because we can have complete control over the optimizer, and because Sista is byetcode-to-bytecode and can hence store its results in the image in the form of optimized methods, I believe that Sista is well-positioned for real-time since it can be used before deployment. ��In fact we should emphasise this in the papers we write on Sista.

I'm not sure of that "real-time" aspect is a good idea. More real-time than others dynamic optimisers, maybe. Note that Java Real-Time suggest turning off JIT and switch to ITC.

But thats because in Java VMs the adaptive optimizer is in the VM where one has limited control over it. ��Sista is different.
��

The word you're looking for there is AoT Compiler :)

In fact a better term would be an interactive compiler ;-)

Regards,

Thierry

--
best,
Eliot