A Closer Look at Android RunTime in Android L
anandtech.com
anandtech.com
https://blog.mozilla.org/javascript/2013/08/01/staring-at-th...
So ART and AOT compilation is a step in the right direction, but I'm secretly hoping that Google will enable Portable Native Client 'natively' on Android outside the browser for proper C/C++ development. Distribution format is a frozen LLVM IR subset, final compilation to the CPU architecture happens on the client side, and performance is close enough to pre-compiled that the difference doesn't matter much.
And having a gdb setup that works properly.
Let me explain - One of the big reasons that Google cannot switch over to Golang (or Dart, or any other) is that the core of Android SDK is written in Java and therefore every app needs to work with Java to be able to tap into it.
However, ART can make it possible for SDK components to compiled down to object code, thus making it possible for Golang/Dart/etc. to link against it, while MAINTAINING backward compatibility with old java apps.
Will it allow new apps to be written in pure native code, without relying on the JNI bridge ?
So no, you cannot just link random other languages without going through JNI. That is a common misconception. Also most of Android itself is managed Java code, so making other languages first-party citizens would require pretty much full OS rewrite. I very much doubt rewriting whole Android just to support non-JVM languages is worth it.
Making ART VM fast, efficient and adding Java 8 bytecode compatiblity is I feel a much better use of development time. Wasting precious development time to placate devs that don't want to switch languagaes is - I feel - a hugely wasted effort.
The official line is that moving the core libraries to something else would be an enormous amount of work and at the moment, they don't see the benefits outweighing the cost.
It is possible that Google is secretly working on some other language, it is also possible that they intend to stick with Java and make it better instead (cue Dagger 2, Guava, AutoValue, ...).
Android team stated multiple times that Java is the language of the platform.
The article doesn't mention one seemingly huge benefit of JIT compilation: profile-guided optimization:
http://www.slideshare.net/ZeroTurnaround/vladimir-ivanovjvmj...
Perhaps the baby has been thrown out with the bathwater?
Little is mentioned about how ART compares to the JVM. For example, does ART perform escape analysis? Not all object allocations are equally bad. The Sun JVM can figure out which objects may be allocated on TLABs (Thread Local Allocation Buffers) - an optimization which reduces the burden placed on the garbage collector because TLAB-resident objects may be deallocated as the stack is popped. [Please fact-check me as I'm merely a long-time Java developer vs. an expert on JVM internals]
Dalvik was rather primitive and extremely slow in comparison to whichever JVM you choose on the desktop today.
The SubstrateVM is the AOT compiler for Graal.
And many commercial JVMs do offer AOT compilation.
Also, .NET has had AOT/JIT since the very beginning. And now static compilation is coming as well.
On ARM? Last time I checked, OpenJDK doesn't even have JIT compilation on ARM, it just interprets the bytecode.
Well, at least the closed source JDK has it. As many other commercial JVMs.
As for AOT, it was referenced at Java ONE, Java Language Summit and Øredev 2014.
Any thoughts on why they they are compiling to native on first run, rather than at install-time?
Often a user will want to run immediately after install, but my feeling is that people are less likely to be frustrated by a longer install time than having to wait for an app to start-up.
Edit: Izacus and InclinedPlane say that AOT compilation is at install-time and the article is wrong.
Or why they don't do it on the server so that you get the specialized binary directly from Google Play? Why should my phone be compiling anything?
The device itself is by far most capable of choosing optimal compiler optimizations for it's own SoC.
Time has proven again and again that humans are really bad at memory management and having raw access to memory is something that needs to be justified on a case by case basis.
Well until AI write garbage collectors I'm not sure I see how your comment doesn't also apply to them. And lots of great software manages memory quite fine, like that browser you used to write your comment and the operating system it runs on, so not sure the use of "proven" is appropriate in your comment.
https://developer.mozilla.org/en-US/docs/Mozilla/Performance
And are making Servo in Rust, which uses compiler dataflows form memory management.
Apple has added ARC to Objective-C and Swift.
Microsoft uses GC in .NET, ARC in C++/CX.
Modern C++ favors RC.
They all seem to think manual memory management is to be avoided.
However it does place a bit of cognitive burden, but last version already improved it.
Does it? I was under the impression that the order of preference (from most preferred to least) is something like:
- plain values (i.e. no pointers)
- references
- unique_ptr
- shared_ptr
- raw pointersYes.
> the others are the main/preferred strategy in those languages/libraries.
While true, manual memory management is still possible, but should be left for the 1% cases that really benefit from it.
Most applications are _not_ games or web browsers, but enterprise-y CRUD applications.
I'm fine with having the ability to turn that off for specific things, but it should be made as inconvenient as possible to avoid the "Can't have GC pauses in my todo list" usecase.
Which bit of the browser are you talking about? Garbage collection is used extensively during the execution of JavaScript in a lot of browsers. For example, Chrome [1].
[1] https://developer.chrome.com/devtools/docs/javascript-memory...
I see what you did there. :)
The original posters meaning was that "malloc() has non-trivial execution costs", but the other meaning is, tautologically, malloc is the "complement" of free (think true is not false).
You are forgetting that Dalvik hasn't been touched since Android 2.3.
Of course, not much could be expected from it.
It's a bit like the folks who say that dynamic languages can be just as fast as compiled languages. Perhaps eventually, but in the here and now in the typical case that claim misses the mark by orders of magnitude.
There are plenty of very fast dynamic language runtimes: LuaJIT, PyPy, Spidermonkey, V8, SBCL, etc. They're all competitive with JVMs and some are consistently faster.
Dalvik avoided the state of the art on purpose, for some reason. It didn't even have a JIT by default until Android 2!
There are quite a few decent GCs out there, Dalvik's merely had almost no work put into it.
Sure, there are good GCs out there, but good GCs are harder than many GC proponents make out.
Take the top 100 most heavily used applications or platforms that rely on garbage collection. What fraction of them actually use decent GC implementations?
Also, you seemingly misread my other point about dynamic language runtimes, I wasn't comparing them to JVMs, I was comparing them to compiled code written in lower level systems languages (like C/C++). V8 may be fast, but it's not as fast as compiled code, yet. There's still a huge gap between theory and practice there.
Other than that, lag can come from many things, so if you lag without GC, the only solution is to profile that part of your app.
Now it just needs to provide a similar developer experience to the other mobile platforms for the C and C++ developers.
I agree that they should have made the transition to AOT a long time ago. Their technical excuse is that devices didn't have enough space. That's only because they allowed devices to not have enough space. Even the original iPhone had 4 GB flash minimum.
However, I'm not completely sure whether Google just restricts the addresses length to 32-bit, or they are keeping the apps 32-bit even on the 64-bit architecture. It sounds like the former, but I really hope it's not the latter. So far I've not seen ARMv8 supported in the SDK and Nvidia's 64-bit Denver CPU still comes out as 32-bit in benchmark tests, even on Android Lollipop.
I don't know whether that's related in any way, or it's some other Google screw-up (not being ready on time with Aarach64 support), or it's just the benchmarks who don't support ARMv8 yet.
Oh and I agree with your comment on storage. Google should impose more "reasonable" requirements. In 2010, even high-end HTC flagships came with like less than 200 MB free storage. Absolutely unacceptable, even at the time. I've hated my HTC phone for so long because it, and it kind of made me not want to get HTC ever again now, since the brand is tainted in my mind.
Today, even $50 Android phones shouldn't have less than 4GB internal storage (which is like 1GB free storage), but those over $100-$150 should all have at least 8GB. Most people should get at least 16GB. When I'll buy a flagship phone a year or so from now I intend to get one with 64GB internal and a UHS-I 128GB microSD to shoot 4k video and RAW pictures.
Is this actually going to be the case? 64-bit addresses allow the use of tagged pointers, which I understand ameliorate any additional cost introduced.
EDIT: Also, ART takes a different approach to AOT compilation than either iOS and Windows Phone. iOS apps are shipped as compiled binaries from the start, and apparently Windows Phone apps are compiled in the cloud by MS. ART does the native translation step on the device itself, which has only really recently become feasible with the speed and storage capacity of recent Android devices.
I code mainly in C++ (NDK) and don't have any issues delivering code.
No, they are not the solution: you cannot provide new optimized versions for generations that did not exist yet when you compiled the binary. Also, providing an optimized version for every ARM, x86, etc. generation will make the binaries very fat.
Fat binaries worked for relatively static platforms, such as Macs. For devices which are (still) iterating quickly, it's a suboptimal solution. Sure, it works for delivering code, but it is suboptimal.
(Not that I believe that ART is currently optimal, e.g. it should not be necessary to do the compilation of an app on 1 million devices that are identical.)
And it isn't that hard to have "APP_ABI := all" in Application.mk. The build just takes a little longer on the CI system.
Tracking all those devices and architectures is dumb, when the manufacturer/device can provide proper tuning for the device itself.
That's not a solution, that's band aid. Fat binaries or multiple binaries cannot support future architectures or architectures that the original developer doesn't support. Platform independent bytecode can.
The real life looks a bit different.
An a simple example, I can recompile my application and target any device while using 100% of all CPU features in all Android generations.
Whereas Dalvik and ART are stuck to the versions that were burned into the silicon.
So gcc and clang can easily outperform Dalvik in < 4.4 generations, given that it was hardly changed since 2.3.
For one application. And again, your binaries will be very fat if you want to optimize for every possible CPU generation.
Whereas Dalvik and ART are stuck to the versions that were burned into the silicon.
Which is a problem with how Android updates are distributed, not the principle of doing AOT compilation on byte code. I think pretty much everyone agrees that the push of updates to Android devices sucks, compared to iOS or, to some extend, Windows Phone.
Also, for optimization for a particular CPU it should not matter if ART is not upgraded, as long ART was optimized for the CPU at the time the phone was released. (Of course, you would miss out on newer optimizations in ART.)
That is why I said:
-- quote
That is the theory, which I preached for a long time as well.
The real life looks a bit different.
-- quote
So one is bound to use the approach that works best, regardless of how it could be.
I have a collection of M68K and PPC Mac binaries, that nobody is going to recompile for me. I would take sub optimally running app over not-running-at-all app any day.
Apple did.
Classic, which provided the ability to run Classic M68K and PPC binaries, had it's last release in 10.4. It wasn't supported in 10.5 and it never run on Intel Macs.
Not to say, that both these technologies are limited hacks compared to proper platform-independent bytecode ala Dalvik, ART, Java or CIL.
I don't understand this comment? What hardware is the Dalvik and ART stuff wedded to?
Except for the top OEMs, most Android devices don't get any updates, so you are stuck with the JIT that was burnt into the firmware.
Of course, you know this, so I can only assume that you are using such words for dramatic effect ;).
It doesn't matter if it is flash, eprom, rom, whatever.
The practical result is that most devices die with the Android version they were bought with.
An app either runs, or not. Dalvik allows the apps to run, without the user having to know about cpu architecture in their phone or whatever.
Yes, having the AOT compilation done on the device is an handicap, given how OEMs barely update Android versions.
So while Apple and Microsoft approaches mean you can target older devices while enjoying improvements in code generation, with Google's approach you're stuck with whatever the device supports, unless you use the NDK instead.