Windows multi-threading performance issues on multi-core systems only
dsimcha
dsimcha at yahoo.com
Tue Dec 15 07:28:37 PST 2009
== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> Maybe I'm wrong, is there a good test case to prove it is worse on
> multiple cores?
> -Steve
This is a synthetic, extreme corner case benchmark, but I think it hammers home
the point that such problems are at least plausible. Tested on a Core 2 Quad with
-O -inline -release:
import std.stdio, std.perf, core.thread;
void main() {
writeln("Set affinity, then press enter.");
readln();
auto pc = new PerformanceCounter;
pc.start;
enum nThreads = 4;
auto threads = new Thread[nThreads];
foreach(ref thread; threads) {
thread = new Thread(&doAppending);
thread.start();
}
foreach(thread; threads) {
thread.join();
}
pc.stop;
writeln(pc.milliseconds);
}
void doAppending() {
uint[] arr;
foreach(i; 0..1_000_000) {
arr ~= i;
}
}
Timing with affinity for all 4 CPUs: 28390 milliseconds
Timing with affinity for only 1 CPU: 533 milliseconds
More information about the Digitalmars-d
mailing list