4 ms·
"They can also reallocate elements into the stack frame rather than heap when they detect specific allocation usage." I've always been interested in whether th
by dougk16 13y ago
"They can also reallocate elements into the stack frame rather than heap when they detect specific allocation usage."
I've always been interested in whether this is done in various managed languages. Since I never know the answer, one pattern I've taken to is to allocate memory in static const/final fields that I would normally put on the stack in C, instead of doing a heap allocation to a variable whose scope is completely within one function. You have to watch out for some gotchas like recursing into the same function, but overall it's a pretty painless and clear pattern for me. Multiple functions can all share the same static memory too.
Not that I'm religious about this design pattern, but it's something I try to do in performance-critical code.
- CountHackulus 13y agoJava does this a whole bunch, it's decently easy for compiler writers to implement and it gets a good speedup on most benchmarks.
- rsynnott 13y agoGood Java JIT environments (HotSpot etc) do this. It looks like Dalvik does not.
- pjmlp 13y agoFrom the few times I tried to read Android code, I think the JIT is not touched since Android 2.3. I am still curious what Google is going to do with Java and Dalvik, as the whole thing seems to be frozen since the whole process with Oracle, and they only add new APIs. The last two Google IOs did not have any Dalvik related talk.
- Zigurd 13y agoIt's unclear if Dalvik's JIT compiler needs updating. For non-mobile uses like GoogleTV, it might be worth making a much more aggressive JIT compiler, since battery use would not be an issue. Other than that, it seems like changes would have a small benefit, a large risk, and a very large testing burden. Android is, still, a very lean project inside and lean corporate structure. If it's a third of the way down the priority list, it probably ain't happening.
- pjmlp 13y ago> It's unclear if Dalvik's JIT compiler needs updating. Well the people doing games already gave up on it since the NDK is available, but given that Google gives a second class treatment to the folks using the NDK, it would be nice if they cared to improve the JIT.
- Zigurd 13y agoAndroid contains a variety of performance strategies: Dalvik's JIT is transparent to the developer and it provides a performance boost for most Java apps, Renderscript is for compute-intensive operations. The NDK enables native code modules and makes it fairly convenient to support multiple architectures. Somewhere in there you should be able to find what you need. But I really don't see why anyone developing action games for a multi-threaded, multi-tasking Java OS isn't aware they are going to find it difficult to get a consistently performing game loop. Android just isn't designed for that. Perhaps if Google is really thinking of making a console, they will provide game-oriented scheduling.
- pjmlp 13y agoI see you are well informed about Android. :) Sure we can find how way around what is provided, but the performance story could be made better, specially when compared what is given to us in iOS and Windows Phone 8 environments.