Dear ART Team,
While working on Migeran (
http://www.migeran.com) a new Java on iOS solution which is based on the Android runtime, we ran into a few bottlenecks in the ART JDWP implementation.
A single step over a specific method call took more than 36 (!) minutes (!!) on ARM (iPad Mini) hardware. Granted, that our test case is a corner case, and that this particular method call is doing heavy annotation metadata manipulation and numerous JNI calls, but we did not had the same issue with Dalvik running on the same hardware.
We profiled the issue, and identified the performance bottlenecks. We developed 3 patches. With these patches we were able to get the time for our 36 minute step over operation down to 2 seconds.
Short description of the patches:
1. Eliminate stack walks from the JDWP frame id computation
2. Do not copy the instrumentation event listener list when delivering instrumentation events
3. Implement on-demand deoptimization during single stepping.
This last patch probably requires a bit more description:
In the original implementation, when a single step control gets activated, every method gets deoptimized, and all code during the step operation is running in interpreted mode. This results in a huge performance penalty, especially if the method that is being executed calls reflection methods related to annotation processing, which are also implemented in Java.
In our implementation, only those frames are deoptimized, which need it (e.g. stepped into, or where a breakpoint was placed). Also, frames are automatically undeoptimized, when deoptimization is no longer required.
We have not yet tested our patches on "real" Android platforms, only on iOS (both x86 simulator and ARM hardware), but the patches are architecture independent, and we would be happy to test and submit them to AOSP if the ART team would be interested in reviewing them.
Best Regards,
Gergely