So, it looks like simply putting the exisiting code on different threads will not improve the app speed as either the second processor is never used or, if it is used, there is some synchronization going on, maybe when opening the same file multiple times.To verify I added some time code that measured how long rendering a single tile took. It turned out that with a single MapWorker rendering a single tile took on average 75 milliseconds (just the rendering, not putting into cache or displaying), but with two threads it took on average 150 milliseconds, cancelling out any gain from having two threads working at once (this was measured on a Nexus 10).The first visual impression was that it was not really any faster than just running with one MapWorker thread.I then set the number of threads to the number of processors with Runtime.getRuntime().availableProcessors(); (There seems to be some discussion if this actually works, but on the physical devices I have the returned value was correct, but this is all Android 4.1+) and created as many mapworker threads as processors. The idea was that multiple mapworkers should be render the same amount of tiles faster than just one thread.Just a quick result from playing around with a multithreaded renderer.
The minimal changes to make it work are simply to give each mapworker their own MapDatabase and DatabaseRenderer (in TileRendererLayer). That of course means a pretty significant overhead as each worker has now their own RenderTheme and map file, but my initial goal was just to see what would need to change.
i.e. WAIT_FOR_CONCURRENT_GC in logs). That result does not surprise me. The whole tile renderer code is old, untested and not at all designed for multi-threading. Therefore I plan to rewrite it from scratch after the 0.4.0 release.
You also have to keep in mind that at least the labeling needs to be shared across all tile renderer threads safely. If you just start several threads, each will use its own labeling and thus names and icons will be cut off at tile borders very often.
Greetings,
Thilo
--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/2a520d32-771b-4fd0-aa39-06a6cdab998f%40googlegroups.com.
Rob
--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/c9b2534d-2d3d-4b4c-83e7-14a25a0a12b9%40googlegroups.com.
Thanks,I had put only a bit of effort in once to see how much work it would overall be to make the renderer multi-thread safe. The problem I encountered was that I somehow could not get a real device to actually run the code on different cores at the same time, despite technically multi-threaded, I could see that everything was just time-sharing the same core, resulting in not much improvement. I did not investigate this enough to find if there is a secret to make a device activate on more than one core.
Lots of mapsforge based apps are classed as battery-intensive, one of problems is the use of location polling.Ludwig--On 26 January 2014 17:39, robvr <r.van...@gmail.com> wrote:Hi Ludwig
You do not sleep much too I see :)
It is not based on mapsforge at all, so i can't make à patch off it.
It is à OpenGL ES based app, closed source for now, as it is à prototype and not as clean coded as
Mapsforge. I am impressed by the high quality of your code, but i want to make my own.
Allthough i did borrow your vbeint i must confess.
I Will clean up à little and try to send you THE relvevant sources.
Grts
RobTo view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/c9b2534d-2d3d-4b4c-83e7-14a25a0a12b9%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/CAAvpVPAFFXj%2B1y2FP4-KTBQYsmJqWRMnM9ZaPLBdurNAESwUTw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/CA%2BjkZB1J6UDjg6K1o9t4%3DLvJ2fcuCsLedWB6nioa6neu9AW%3Dow%40mail.gmail.com.