Search code examples
multithreadingperformancemulticore

Single-threaded/event-based software vs cores and H/W threads


I'm a bit confused here about cores and threads on CPUs

Often in configuration files eg. nginx, golang you have to define the number of cores to get the best performance

If you look at this CPU http://ark.intel.com/products/52213/Intel-Core-i7-2600-Processor-8M-Cache-up-to-3_80-GHz

How many "cores" does it have?

In the specs it has 4 cores and 8 threads.. Does that mean 4*8 = 32 "cores" ??


Solution

  • No, the CPU you linked to has four cores. It can, however, run two threads at the same time per core with a technology called Hyper-Threading (HT), thus has 8 "threads". The OS will be presented with 8 processors, unless you disable HT in the BIOS or elsewhere.

    Note that hyper threading works in a special way: It uses unused execution units (in the sense of a superscalar processor) of a core for the second thread. AFAIK there are really good algorithms that re-order instructions for this to be most effective, but bear in mind that the hyper threads may not bring the best performance for all applications. For example: if you already use all floating point execution units in the four "real" threads all the time, the hyper threads will not be able to use them most of the time.