On Thu, Aug 9, 2012 at 4:16 PM, hagenp <
hagen....@gmail.com> wrote:
> Warning: Long reply ahead.
>
>
> On Monday, August 6, 2012 5:50:21 PM UTC+2, Jack Harvard wrote:
>>
>> A benchmark (AndEBench from Google Play) showed that native vs Java
>> version of the same application varies in performance by 20+ times on
>> Android, this shows that there's a large performance gap to improve on
>> for Dalvik.
>
> So... the statement is valid... for this one implementation. Of this one
> application.
>
> Did you read this?:
>
http://developer.android.com/guide/practices/performance.html
>
> A co-worker baffled me with a remark that a JIT can even outrank an
> optimized native implementation.
That wouldn't surprise me at all, in fact this is frequently cited as
why you should use JIT, because at runtime you can have extra
information, be that in the form of more accurate branch prediction,
better information about the underlying hardware, etc...
(I believe HTC has a binary rewriter that optimizes native arm5 code
to better performing arm9, for example, depending on your device..?
Not exactly JIT, but an example from the previous)
> My first reaction was: WHAT? How?
> Easy: if a piece of code contains lots of conditional statements, but these
> are fixed over a long period of time once processing began (like in a
> long-running loop), the JIT compiler can optimize the conditions away and
> save time. Any static optimization can just not do this.
>
That's not *precisely* true, good static analysis techniques can do a
lot, but yes, in general a dynamic approach will be a lot more precise
for individual runs.
> The drawback with JIT compilers is of course that they also need processing
> cycles. And memory. That's why you want a fast JIT compiler that has a small
> memory footprint. You need to find a good balance between a JIT compilation
> to kick in early enough so to speed up your routines as much as possible,
> but late enough to prevent wasting time by compiling one-shot statements.
>
That's right, and remember that Android has a trace based JIT..
You're correct that it's hard to compare against other VMs, however
*mobile* vms might be the right place. It also depends, however, on
the system architecture underlying the platform. The Android platform
and Dalvik were designed for each other, (and, initially without JIT!
Simply assembly optimized interpretation with a high perf and very
cute / small architecture..). If you throw another mobile vm / system
on Android it probably won't perform well, a similar argument can be
made the other way...
kris