Just like Qt, android dalvik also use sysconf(_SC_NPROCESSORS_ONLN) to report the number of available cpus to applications which then create the thread pools based on that information. Obviously, applications can suffer significant performance hit by dynamic hotplugging.
The right solution should be using sysconf(_SC_NPROCESSORS_CONF) which, in theory, should return the total available cpus instead of online ones.
The problem is that libc implementations, at least the android libc i used, do not distinguish the two and simply they are the same. i.e., report #of online cpus although _SC_NPROCESSORS_CONF is requested. They should be fixed as desired.
Then a question would be whether kernel has standard interface to userspace to report #online cpus and #available cpus so that libc can properlly implement both _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_CONF.
Posted Feb 29, 2012 19:45 UTC (Wed) by BenHutchings (subscriber, #37955)
[Link]
Last time I looked, glibc was using /proc/cpuinfo. I think it should be using /sys/devices/system/cpu/online and
/sys/devices/system/cpu/possible, with a fallback to /proc/cpuinfo.