Comment #0 by noizeless.vril — 2022-02-06T13:06:01Z
Hi folks, thanks a lot for D language.
I need create hightload multithread application, so, I had create a simple test code to verify how much the D could give performance and met a strange error:
// Error output:
// ...
// destructed: 32631
// destructed: 32632
// core.thread.threadbase.ThreadError@src/core/thread/threadbase.d(1217): Error creating thread
The application stopped with same error at the same point always. Also while the app is running I see how fast memory consumption grows to 400Mb and then crashed. At the same time a GC works well because messages about threads destruction are printed.
I have did similar performance test on JDK 17 and got stable memory consumption about 60Mb max.
module test.thread;
import std.stdio;
import core.thread.osthread;
import core.time;
void main() { massThreadTest(); }
private shared Duration dur1ms = dur!("msecs")(1);
private class LogThread : Thread {
private static shared int destructed;
this(void function() fn, size_t sz = 0) { super(fn, sz); }
this(void delegate() dg, size_t sz = 0 ){ super(dg, sz); }
~this() {
destructed = destructed + 1;
writeln("destructed: ", destructed);
}
}
private void massThreadTest() {
writeln("Start");
const int count = 1_000_000;
foreach(int i; 1..count) {
new LogThread(&run).start();
//write(i);write(' ');
Thread.sleep(dur1ms);
}
writeln("End");
}
private void run() {}
Comment #1 by noizeless.vril — 2022-02-06T13:11:51Z
My environment:
Manjaro Linux
Linux 5.15.12-1-MANJARO #1 SMP PREEMPT Wed Dec 29 18:08:07 UTC 2021 x86_64 GNU/Linux
DMD64 D Compiler v2.098.1
libphobos 2.098.1-2
Comment #2 by robert.schadek — 2024-12-07T13:41:46Z