The program below runs slower with threads (no "-s" option) than in one thread (with the "-s" option). The opposite happens when compiling with gdc, which is the expected behaviour. Found with dmd 2.065 on Arch Linux 64-bit.
import std.parallelism;
import std.getopt;
import std.array;
import std.ascii;
import std.base64;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.cstream;
alias TestFunction = void function();
auto getTests(Modules...)() {
TestFunction[] tests;
foreach(mod; Modules) {
foreach(test; __traits(getUnitTests, mod)) {
tests ~= &test;
}
}
return tests;
}
void main(string[] args) {
bool single;
getopt(args,
"single|s", &single
);
enum tests = getTests!(
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.concurrency,
std.container,
std.cstream,
);
if(single) {
foreach(test; tests) {
test();
}
} else {
foreach(test; tests.parallel) {
test();
}
}
}
Comment #1 by dlang-bugzilla — 2014-05-10T08:07:29Z
This is a regression? Can you indicate a version when the problem did not manifest?
For me the program runs in about 24 ms both with and without -s.
Comment #2 by atila.neves — 2014-05-20T21:52:24Z
(In reply to Vladimir Panteleev from comment #1)
> This is a regression? Can you indicate a version when the problem did not
> manifest?
>
> For me the program runs in about 24 ms both with and without -s.
I called it a regression because I assume threading worked to make it faster before. I wasn't sure about that one.
Funny that you can't reproduce it, I can on my system. I thought maybe because I use ld.gold instead of bfd but that wasn't it. I might have to try this on a Ubuntu VM and see what happens.
Comment #3 by atila.neves — 2014-06-02T18:14:38Z
(In reply to Vladimir Panteleev from comment #1)
> This is a regression? Can you indicate a version when the problem did not
> manifest?
>
> For me the program runs in about 24 ms both with and without -s.
I fired up an Ubuntu 14.04 VM and reproduced the issue. Definitely running slower using threads with dmd.
Comment #4 by bugzilla — 2014-06-19T21:44:18Z
Reclassified as a normal bug, not a regression, since nobody has checked to see if this behavior is new or not.