7 ms·
A Closer Look at Android RunTime (ART) in Android L
- mwcampbell 12y agoI wonder if it would make sense to rewrite some native components of Android in Java now. Presumably, whole-program optimization means that the ART compiler is more effective if more of the code is in Java (or technically, Dex bytecode) rather than having opaque native parts with JNI overhead.
- DiabloD3 12y agoA lot of Android is written in Java already. What would be interesting, however, is Android transitioning to a message passing micro-kernel (instead of Linux) and writing as much as possible of the rest of the kernel in Java.
- pjmlp 12y agoThat is already the case. When you look at the NDK, you can only have access to game related API (audio, graphics and sensors) almost everything else involves JNI.
- jordanthoms 12y agoActually quite a bit of the view code is native still - start reading the source for View etc and you hit a level where it's mostly calls out to native libraries. e.g https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/GLES20Canvas.java https://github.com/android/platform_frameworks_base/blob/mas...
- pjmlp 12y agoWell, graphics code eventually needs to speak to the graphics card. I imagine outside graphics, audio and hardware integration APIs, there is very little done at C level.
- vii 12y agoThis architecture is insane from an overall system point of view. Why ship DEX proprietary bytecode to be compiled by the same compiler in the same way on hundreds of millions of devices to produce the same output? It would seem far more logical to compile all the versions needed, one for each device architecture, just once. As other aspects of the apk need to be customised for each device class already, there is not really new overhead. Going native is a great idea, doing it this way is plain bonkers.
- learc83 12y agoBackwards compatibility is extremely important--existing APKs will still work with ART. They also avoid separate binaries for each supported architecture, MIPS, x86, and ARM. Plus this system also allows apps to take advantage of updates to the compiler without requiring that developers recompile and resubmit. Imagine in 2 years a new ARM version drastically increases performance by using some clever new instructions. If you have pure native code every developer has to recompile their apps to take advantage of the new architecture--with ART, Google handles the update, and every app on the appstore benefits automatically.
- mwcampbell 12y agoSystem-on-chip vendors could also tune the compiler, just as some do now with the Dalvik VM. For example, this AnandTech article mentions that the Moto X has a Qualcomm-modified version of Dalvik: http://www.anandtech.com/show/7517/google-nexus-5-review/2 http://www.anandtech.com/show/7517/google-nexus-5-review/2
- personZ 12y agoIt's how Java works. It is, indeed, how HTML, CSS, JavaScript, and many, many other technologies work (millions of us are all using the same Chrome browser that's doing exactly the same work to make sense of this markup, build and transform DOM trees, compile and JIT the scripts, etc. Why don't sites just serve up Chrome native code?). It isn't really "insane". There are benefits and detriments. Not least that the same APK can run on many Android versions, across many architectures (x86, AMD64, ARM, ARMv8, MIPS), with many different bits of system hardware. Further the whole "ART goes native" thing is largely wrong -- Dalvik already compiled to native, storing the JITted code for subsequent uses. ART is just a better performing, more considered rewrite.
- rcthompson 12y agoIt's kind of funny to hear AOT compilation being heralded as the next step after JIT that will bring better performance because you only have to compile once, since we spend so much time hearing exactly the opposite, especially in the context of Javascript. (Notwithstanding that, as other comments have pointed out, JIT vs AOT is at best a gross oversimplification of the difference between Dalvik and ART.)
- AshleysBrain 12y agoApps and web pages are different use cases. An app you expect to spend a moment "installing" and are likely to use regularly, so AOT compiling is useful. Web pages on the other hand are often visited briefly and a few seconds delay can make a huge difference difference, and often contain lots of script executed only once or not at all - so AOT compilation would actually hurt performance.
- lenkite 12y agoNot really true with all the HTML5 apps based on Phonegap and WebView.
- pjmlp 12y agoNot really, it is deja vu for anyone that has been around in this industry for long time. The idea of universal VMs go back to UNCOL project (1958). A few mainframes made use of VMs with some kind of AOT compilation at installation time. The most notorious of it OS/400, still being used. The first sucessful JIT compilers were designed as part of Smalltalk systems, namely SELF, which JavaScript is a descent of. So of course you hear a lot about it in the context of JavaScript. Where JIT compilers bring a major win is when compiling dynamic languages. With strong typed languages, the type of optimization algorithms you can make use of usually win over the limited options JIT compilers have available due to responsiveness limitations. In the early 80s there was a fad of VM craziness around P-Code virtual machines, which eventually died out when everyone went back to proper compilers. So this going back to AOT compilation trend, is just the IT circle going around one more time.
- rst 12y ago
- TheLoneWolfling 12y agoThis seems familiar: https://news.ycombinator.com/item?id=7738223 https://news.ycombinator.com/item?id=7738223
- melling 12y ago"This also means that Android is finally able to compete with iOS in terms of application fluidity and performance, a big win for the consumer." Does anyone actually have any real comparisons between Android and iOS? Was there an acknowledged 2x performance benefit for iOS on the same hardware? For games and Ui, for example, wouldn't the GPU be more important?
- hexleo 12y agoART is a good news for Android users, but it's really optimize the performance? I watched someone use Android L to run some popular social app(like WeChat), you can't open it normally. Some big bug sure be fixed.
- on_and_off 12y agoI am testing the L build on a Nexus 5. Our app has a feed full of very rich views. We already implement a lot of optimizations (not all of those that are possible though, namely flat custom views, simply because we don't have the engineering ressources to do it right now) but it scrolling is not perfectly smooth on 4.4. We lose a couple of frames each second when scrolling rapidly (interestingly, in addition to its native code, iOS also limits scrolling speed in order to deliver a smooth experience). This is no longer the case with Android L. Without changing anything in our code, this feed is now smooth as hell. About the app you mentioned, L is right now a preview build, there are indeed a lot of bugs everywhere. It is not really surprising since we are months away from the release. It does not have anything to do with perfs though.
- hexleo 12y agoI think you are right. I'm not a pure Android developer, just do some works with Android. Your test give us a good news, we happy to see Android more smooth.
- Roboprog 12y agoInteresting that the new on-device output is a Linux ELF binary. I suppose this opens the door for a more flexible cross-compiler system that could in the future better support languages that are less Java-like. E.g. - something like Swift that doesn't use a GC at all, for example. Or at least an option to develop in Go? It will be interesting to see what sort of extensions Google adds to the dex format in the next few years. Hopefully, there will be some efficient lower level language bindings for the UI calls, perhaps?