0

I'm reading Ignite documentation and now I'm at the section about performance. Here is what it's written (emphasized mine):

By default, Ignite has it's main thread pool size set to 2 times the available CPU count. In most cases, keeping 2 threads per core will result in faster application performance, since there will be less context switching and CPU caches will work better.

I don't understand why is it less context switching if we have 2 threads per core? I thought if all threads are busy with some job there will be pretty much of context-switch because we cannot run jobs twice as the number of cores. Which will hurt performance.

What did they mean by that?

St.Antario
  • 26,175
  • 41
  • 130
  • 318

1 Answers1

0

The answer is an interpretation of the statement - hence assumes what the writer may be thinking and provides my view.

The statement may be right if we were to assume each core is hyper threaded, & each thread maximizes use of the CPU time it is allocated, and threads remain bound to the CPU core.

Or

core is single threaded and each of the threads maximizes the usage of available CPU time by minimizing the number of context switches (when one is blocked, other does computation)

For cache related mention to hold true the process threads must remain bound to the same core for considerable period of time.


A nice thought on why right number of threads is important than more number of threads with good example is here: https://blogs.mulesoft.com/biz/news/chasing-the-bottleneck-true-story-about-fighting-thread-contention-in-your-code/

Beyond that what is context switch overhead at processor level: though dated - gives good idea - http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-make-context.html

  • 3
    *guesses are not answers, they are guesses*, Please read [How do I write a good answer?](http://stackoverflow.com/help/how-to-answer) before attempting to answer more questions. –  Dec 27 '17 at 19:42