-1

Per mine current understanding, Ideally for best perormance, we should not create threads more than number of cores in processor as there will be overheads like thread switching. But this video Apache Spark Video says at 91 minute, we should oversubscribe the thread i.e. create more threads than cores for better performaance .

Only Advantage i can think of creating extra thread all tasks will get cpu cycles in kind of round robin fashion instead of limited threads finishing first set of task then pick another set.

I am not sure which one is correct ?

scott miles
  • 1,511
  • 2
  • 21
  • 36

1 Answers1

3

In an ideal world, where a thread has a continuous stream of steady work to do, having one thread per core might be a good idea.

In the real world, there are plenty of times where threads have to wait. They wait for a resource to be available, or for the user to do something productive. When they are waiting, the core sits idle and has nothing to do. Why not fill that time by switching to another thread and doing it's work?

Eric
  • 601
  • 7
  • 22
  • 1
    Exactly. If the thread-per-core fallacy was true, it would also apply to multitasking and multiprogramming, and we would never have got beyond batch computing. – user207421 May 24 '17 at 04:34