[Python-ideas] multiprocessing and physical CPU cores count

Christian Heimes christian at python.org
Thu Sep 12 22:19:45 CEST 2013

Am 12.09.2013 21:51, schrieb Giampaolo Rodola':
> I'd be +0.5 for multiprocessing because:
> - cpu_count() is already there
> - physical_cpu_count() will likely be used by multiprocessing users only
> ...but my main concern was first figuring out whether it might actually
> make sense to distinguish between virtual and physical CPUs in a real
> world app.

I would go one step further and expose the topology of the CPUs. It's
much, much more complicated than just physical and logical CPUs.

For example with Intel CPUs, two hyper-threading units have different
registers but share the same L1 and L2 cache. All CPU core inside a
physical processor share a common L3 cache. Multiple processor on
machines with several processor slots have to communicate through QPI
(QuickPath Interconnect). ccNUMA (cache coherent non-uniform memory
access) ensures that memory barriers syncs these caches when a process
uses multiple processors. Every processor has its own memory banks so
'remote' memory is more expensive to access. Other processors have a
different internal structure. Some aren't ccNUMA ...


More information about the Python-ideas mailing list