JIT optimization

59 views
Skip to first unread message

Patrick

unread,
Oct 5, 2016, 2:00:28 PM10/5/16
to Avian
Hi Joel & Joshua,

I am working on an emulator using the avian vm. Are there any tips you can give for maximizing the performance of the JIT?
It is pretty resource intensive, would inlining the functions that are called within the main loops be beneficial? How about loop unrolling, and other tricks to improve speed? Also, I use the long primitive alot due to the fact there really arent any unsigned types.

Also for the Android version would compiling to ARM64 give better performance than ARM on compatible devices?

Thanks,

Patrick

Joel Dice .

unread,
Oct 7, 2016, 3:33:11 PM10/7/16
to Avian
Hi Patrick,

Sorry for the late response. Can you clarify what you're looking to
optimize? Do you want tips on how to generate Java source or bytecode
that will run more efficiently on Avian, or how to improve the JIT
compiler in Avian so it generates better machine code from the
bytecode it is given? Or are you looking to make the JIT generate
machine code more quickly?

If it's the former and you're just looking to generate faster
bytecode, yes, inlining functions and unrolling loops might help (and
ProGuard might be able to do such things at the bytecode level). In
many cases, though, the bottleneck may be that the register allocator
in Avian's JIT is pretty dumb, so loop unrolling could actually slow
things down in some cases. If you're doing a lot of long arithmetic,
switching to ARM64 would probably be a win.

More generically, the key to successful optimization is to let a
profiler tell you where the bottlenecks are. You can write a simple
sample-based profiler in Java that spawns a separate thread which
samples the thread of interest e.g. 10-100 times per second by calling
Thread.getStackTrace() on it and adding the trace to a HashMap. Then
you can generate statistics from that HashMap, ranking traces by the
percentages of samples they appear in. That will tell you where your
program spends most of its time and thus what parts need optimization
the most. There are more sophisticated profilers available, of
course, but not all of them will run on Avian.
> --
> You received this message because you are subscribed to the Google Groups
> "Avian" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to avian+un...@googlegroups.com.
> To post to this group, send email to av...@googlegroups.com.
> Visit this group at https://groups.google.com/group/avian.
> For more options, visit https://groups.google.com/d/optout.

Patrick

unread,
Oct 7, 2016, 5:08:30 PM10/7/16
to Avian
Hi Joel,

Yes, my question was aimed at what optimizations the JIT compiler makes and tips on generating bytecode that is efficient with Avian's compiler.

I will give ProGuard a try and benchmark the results.
Reply all
Reply to author
Forward
0 new messages