www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIyNzQzXSBOZXc6IGNvcmUudGhyZWFkLnRocmVhZGJh?=

https://issues.dlang.org/show_bug.cgi?id=22743

          Issue ID: 22743
           Summary: core.thread.threadbase.ThreadError src/core/thread/thr
                    eadbase.d(1217): Error creating thread
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: noizeless.vril ctemplar.com

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() {}

--
Feb 06 2022