Scheduling Algorithms

Bezoar

Ars Scholae Palatinae
820
I have a Win 10 Pro 1809 machine 56 logical cores. Typically I run 48 compute threads so the machine has some reserve to stay fully responsive.

These threads are substantially similar and under the above conditions execute in approximately the same amount of time.

If I don't care about it being responsive I'll toss on 96 threads and would expect roughly double the run time, while this is largely the case a small number of the threads appear to be orphaned having received a small fraction of the cycles required to complete the task in a timely manner.

Are there any benchmarks or reference material comparing scheduling algorithms across OS's under such conditions?
 

ComradeXavier

Ars Scholae Palatinae
881
Subscriptor++
I have never seen any benchmarks comparing scheduler fairness between OSes.

If you're interested in how the Windows scheduler works, the best account of it you're likely to find is in Windows Internals Part 1.

The Linux scheduler is (of course) open to examination if you care to read the source. I think it's still using the "Completely Fair Scheduler" by default, but I haven't been following Linux kernel development much lately.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
The reason to over provision threads verses cores is because you expect to have the threads blocking on IO every so often so having something else to do becomes a net win against the costs of pre-emption, cache dirtying etc...

With access to main memory being so many cycles these days having something to cover those gaps is useful too (though you state nothing should go past L2 so that’s not much benefit either)

But if you have that many cores I suspect either:

A) Your IO/memory access may well now be becoming the bottle neck (at s certain point the set associativity of the cache will bite you)
B) If there’s no meaningful IO memory access from the programs then why are you bothering over provisioning. The context switch and scheduler overhead is going to hurt you, go to 1:1 instead.
C) Your apps are not as light as you think, use a sampling profiler with the ability to trigger on cache misses to find out about memory, use etw/straw to find out about the io
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
You've still not explained why you think going beyond the number of logical/physical cores would be _expected_ to do better...

hyperthreading is very complex, and dependent on the implementation in place (what execution hardware is duplicated/shared, how many pipeline stalls you expect, etc. so is hard to establish without just sucking it and seeing). If you do no significant IO _why_ do you expect that going over the number of logical cores should help?
 

Bezoar

Ars Scholae Palatinae
820
does a thread stay in the same cluster the whole run? the allocation may still be fair overall even though it doesn't appear fair at each snapshot.
Yes, they stay in the same cluster until the threads start finishing.

You've still not explained why you think going beyond the number of logical/physical cores would be _expected_ to do better...
I'm not expecting it to do more work, I was surprised by how relatively broken the cycle allocation becomes when overloaded. It's a matter of 2X the work requiring 3X+ the real world time for the total job.
 

fitten

Ars Legatus Legionis
55,632
Subscriptor++
I'm not expecting it to do more work, I was surprised by how relatively broken the cycle allocation becomes when overloaded. It's a matter of 2X the work requiring 3X+ the real world time for the total job.

Not surprising. Overdecomposition of compute bound threads/processes will wreak havoc on caches and the like, depending on the processes themselves. It's one of the reasons that people avoid doing it.
 

Lt_Storm

Ars Tribunus Angusticlavius
21,343
Subscriptor++
Yes, there is a reason that people use the same number of threads as they have logical cores for compute bound tasks. Anything more will just serve to push data out of the processor caches and result in more time spent waiting for main memory. It is entirely possible that there is some process which preferentially causes some threads to suffer more of those waits.
 

rain shadow

Ars Tribunus Angusticlavius
6,679
Subscriptor++
Maybe look at it from a different perspective. The goal (of the kernel) isn't always to distribute timeslices completely fairly at all times, rather it's to get the tasks to finish as quickly as possible overall. Giving some threads preference (even if it seems arbitrary) can and should allow the workload as a whole to finish sooner by avoiding process swaps and cache reloads, to say nothing of i/o contention.

Maybe graph the number of threads against total time to execute a large job. That should gradually level off, maybe rise slowly as you get past the number of real cores/hyperthreads. Anyway, look at the graph and find the minimum time to completion. Just go with the corresponding number of threads and don't sweat the details.

I've never seen anyone worry about clustering by %cpu. About all you can say is that the fact that they are clustering at all indicates that the kernel is making some intentional decisions, not just randomly doing whatever.
 

MilleniX

Ars Tribunus Angusticlavius
8,138
Subscriptor++
The term I'm used to seeing for this is oversubscription, not overdecomposition. As far as I've seen previously, the research lab I was part of in grad school was the only group using the term overdecomposition. Our usage was similar, in that it involved expressing more units of parallel work then available parallel execution capacity, but with a clear view that they couldn't be run in a way that would turn out like this. They were usually individual pieces of a tightly-coupled simulation, too, so even one piece getting shafted would have been disastrous for performance.
 

fitten

Ars Legatus Legionis
55,632
Subscriptor++
Possibly... my time in HPC was some time back. We called it "overdecomposition" because it was decomposing the problem into more work processes/threads than there were available compute resources. We pretty much only used it in terms of a parallel job (and yeah, if it's a fine grained job, it will cause even more havoc... the more coarse grained the better it would deal with it but still far from ideal). In either case, it sounds like we're talking about the same thing.