Interpreting Multicore Performance Trace (Eclipse/Android)

后端 未结 2 786
后悔当初
后悔当初 2020-12-30 02:37

I\'m working on an android game, and I started noticing a little sluggishness during development so I wanted to try to utilize multithreading for fun and learning.

相关标签:
2条回答
  • 2020-12-30 02:55

    Thanks for the question. A full answer by an insider will be helpful to me, too. I'll say what I know.

    • Some (all?) phones have an option to enable/disable the second core. Have you checked that yours is turned on?

    • In my own app I've noticed that merely going from one thread to two (on one core) with no change in total work done causes a factor of 1.5 slowdown, so clearly threading itself has a cost.

    • It's been in the news that Intel is calling Google out on poor implementation of multicore threading:

      http://www.pcworld.com/article/257307/dual_core_processors_wasted_on_android_intel_claims.html

      Your results validate this.

    • One other thing to bear in mind is that multi-core is not multi-processor. You're sharing cache and memory controller bandwidth between cores. One can stall while it waits for the other to finish with a shared resource, in particular for writes on shared cache lines. However this effect ought not account for the single-threading you are seeing.

    0 讨论(0)
  • 2020-12-30 03:02

    Very nice question, let me start with answers:

    1. You have mixed up threads/methods/activeMethod. Each line in traceview is thread (and if you named your threads, you'll see it's name on left side, like "GL Thread", "main", etc..). Rectangles(colored) represents active executing methods inside each thread, while colored lines represents "paused" methods inside thread. By "paused", i mean "method is still executing, but context was switched to some other thread, and when context switched again to this thread, this method will continue to work. In terminology you've used in your question, ye, lines are sleeping thread's methods, and rectangle is active thread executing method. You can find more info about DDMS traceview here.
    2. Distributing threads among cores is another story and heavily depends on underlying Android OS mechanisms. First of all, be sure that target Android OS is started with SMP (Symmetric Multi-Processing) option on, which is default case for multicore phones, i guess :), but i'm not expert in those things. Some words about SMP you can find here.
    3. Thread switching depends on OS Thread/Process scheduler, thread priority, etc. More info about this things you can find in this answers.
    4. Even if you ran application in non-debugging mode, when you connect with DDMS, and do things such Method profiling, you'll activate debugging parts of davlik vm. More details about debugging here, section "Implementation".

    Hope you'll find this answer helpful.

    0 讨论(0)
提交回复
热议问题