September 25, 2017
On Monday, 25 September 2017 at 08:36:31 UTC, Vadim Lopatin wrote:
> On Monday, 25 September 2017 at 08:01:02 UTC, tchaloupka wrote:
>> On Monday, 25 September 2017 at 07:05:57 UTC, Vadim Lopatin wrote:
>>> On Monday, 25 September 2017 at 06:56:58 UTC, Vadim Lopatin wrote:
>>>> On Sunday, 24 September 2017 at 22:54:11 UTC, Sönke Ludwig wrote:
>>>>> How on earth can that be unfair when the Go, node.js and Scala versions appear to use multi-threading, too?
>>>>
>>>> Looks like repo owner thinks they are single threaded.
>>>
>>> Just checked threads of Go version. I see 7 'go' and 7 'main' threads.
>>
>> I've just tried this on my linux box (only dmd as ldc2 fails with release build - https://github.com/ldc-developers/ldc/issues/2280).
>>
>> rust:			Requests/sec:	38757.2625
>> vibe-d:core libevent:	Requests/sec:	27906.8119
>> vibe-d:core libasync:	Requests/sec:	20534.3057
>> vibe-core:		Requests/sec:	18042.4251
>>
>> Didn't include the Go version as it's indeed using more threads.
>> Results are just for the base url to not include the regex matching there.
>
> I've sent PR https://github.com/nuald/simple-web-benchmark/pull/11 to re-enable multithreading in D test app.
>
> BTW, does Rust version use multithreading?

Rust doesn't seem to use multiple threads, it's just faster I'm afraid.

Tried the ldc release build with the suggested switch removal (https://github.com/ldc-developers/ldc/issues/2280#issuecomment-331823377), and the results are:

ldc2 vibe-d:core libevent:	Requests/sec:	29782.9605
ldc2 vibe-core:			Requests/sec:	21396.2019
September 25, 2017
Not at all. Rust test is fake.  Does not process headers,  does not write headers. Does not send right output.  Does not work with browser.  Every one or two request it will die.  Rust result shoud not be taken seriously. Until fixed

Dne 25. 9. 2017 11:50 dopoledne napsal uživatel "tchaloupka via Digitalmars-d" <digitalmars-d@puremagic.com>:

> On Monday, 25 September 2017 at 08:36:31 UTC, Vadim Lopatin wrote:
>
>> On Monday, 25 September 2017 at 08:01:02 UTC, tchaloupka wrote:
>>
>>> On Monday, 25 September 2017 at 07:05:57 UTC, Vadim Lopatin wrote:
>>>
>>>> On Monday, 25 September 2017 at 06:56:58 UTC, Vadim Lopatin wrote:
>>>>
>>>>> On Sunday, 24 September 2017 at 22:54:11 UTC, Sönke Ludwig wrote:
>>>>>
>>>>>> How on earth can that be unfair when the Go, node.js and Scala versions appear to use multi-threading, too?
>>>>>>
>>>>>
>>>>> Looks like repo owner thinks they are single threaded.
>>>>>
>>>>
>>>> Just checked threads of Go version. I see 7 'go' and 7 'main' threads.
>>>>
>>>
>>> I've just tried this on my linux box (only dmd as ldc2 fails with release build - https://github.com/ldc-developers/ldc/issues/2280).
>>>
>>> rust:                   Requests/sec:   38757.2625 vibe-d:core libevent:   Requests/sec:   27906.8119 vibe-d:core libasync:   Requests/sec:   20534.3057 vibe-core:              Requests/sec:   18042.4251
>>>
>>> Didn't include the Go version as it's indeed using more threads. Results are just for the base url to not include the regex matching there.
>>>
>>
>> I've sent PR https://github.com/nuald/simple-web-benchmark/pull/11 to re-enable multithreading in D test app.
>>
>> BTW, does Rust version use multithreading?
>>
>
> Rust doesn't seem to use multiple threads, it's just faster I'm afraid.
>
> Tried the ldc release build with the suggested switch removal ( https://github.com/ldc-developers/ldc/issues/2280#issuecomment-331823377), and the results are:
>
> ldc2 vibe-d:core libevent:      Requests/sec:   29782.9605 ldc2 vibe-core:                 Requests/sec:   21396.2019
>


September 25, 2017
On Monday, 25 September 2017 at 13:18:45 UTC, Daniel Kozak wrote:
> Not at all. Rust test is fake.  Does not process headers,  does not write headers. Does not send right output.  Does not work with browser.  Every one or two request it will die.  Rust result shoud not be taken seriously. Until fixed
>

Well I didn't expected that it would be this way and didn't check myself.. Thanks for testing and clarification :)


September 26, 2017
On Monday, 25 September 2017 at 09:45:13 UTC, tchaloupka wrote:
> On Monday, 25 September 2017 at 08:36:31 UTC, Vadim Lopatin wrote:
>> On Monday, 25 September 2017 at 08:01:02 UTC, tchaloupka wrote:
>>> On Monday, 25 September 2017 at 07:05:57 UTC, Vadim Lopatin wrote:
>>>> [...]
>>>
>>> I've just tried this on my linux box (only dmd as ldc2 fails with release build - https://github.com/ldc-developers/ldc/issues/2280).
>>>
>>> rust:			Requests/sec:	38757.2625
>>> vibe-d:core libevent:	Requests/sec:	27906.8119
>>> vibe-d:core libasync:	Requests/sec:	20534.3057
>>> vibe-core:		Requests/sec:	18042.4251
>>>
>>> Didn't include the Go version as it's indeed using more threads.
>>> Results are just for the base url to not include the regex matching there.
>>
>> I've sent PR https://github.com/nuald/simple-web-benchmark/pull/11 to re-enable multithreading in D test app.
>>
>> BTW, does Rust version use multithreading?
>
> Rust doesn't seem to use multiple threads, it's just faster I'm afraid.
>
> Tried the ldc release build with the suggested switch removal (https://github.com/ldc-developers/ldc/issues/2280#issuecomment-331823377), and the results are:
>
> ldc2 vibe-d:core libevent:	Requests/sec:	29782.9605
> ldc2 vibe-core:			Requests/sec:	21396.2019

From my benchmarks comparing D to Rust using an MQTT broker I wrote, Rust wasn't faster, mio (a Rust async IO library) was. i.e. Rust/mio and D/mio performed similarly, D/vibe.d was slower. That was over a year ago, I haven't tried it again since.

Atila
October 30, 2017
On Thursday, 21 September 2017 at 13:09:33 UTC, Daniel Kozak wrote:
> wrong version, this is my letest version: https://paste.ofcode.org/qWsQikdhKiAywgBpKwANFR
>
> On Thu, Sep 21, 2017 at 3:01 PM, Daniel Kozak <kozzi11@gmail.com> wrote:
>
>> my version: https://paste.ofcode.org/RLX7GM6SHh3DjBBHd7wshj
>>
>> On Thu, Sep 21, 2017 at 2:50 PM, Sönke Ludwig via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>>
>>> Am 21.09.2017 um 14:41 schrieb Vadim Lopatin:
>>>
>>>>[...]
>>> Oh, sorry, I forgot the reusePort option, so that multiple sockets can listen on the same port:
>>>
>>>     auto settings = new HTTPServerSettings("0.0.0.0:3000");
>>>     settings.options |= HTTPServerOption.reusePort;
>>>     listenHTTP(settings, &handleRequest);

Hi, would it be possible to re-share the example of vibe.d woth multithreaded support.

The pastebin link has expired and the pull request doesnt have the latest version.

Thanks

Ade
October 30, 2017
Maybe this one:

import vibe.d;
import std.regex;
import std.array : appender;

static reg = ctRegex!"^/greeting/([a-z]+)$";

void main()
{
    setupWorkerThreads(logicalProcessorCount);
    runWorkerTaskDist(&runServer);
    runApplication();
}

void runServer()
{
    auto settings = new HTTPServerSettings;
    settings.options |= HTTPServerOption.reusePort;
    settings.port = 3000;
    settings.serverString = null;
    listenHTTP(settings, &handleRequest);
}

void handleRequest(HTTPServerRequest req,
                    HTTPServerResponse res)
{
    switch(req.path)
    {
    case "/": res.writeBody("Hello World", "text/plain");
        break;
    default:
        auto m = matchFirst(req.path, reg);
        string message = "Hello, ";
        auto app = appender(message);
        app.reserve(32);
        app ~= m[1];
        res.writeBody(app.data, "text/plain");
    }
}

On Mon, Oct 30, 2017 at 5:41 PM, ade90036 via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> On Thursday, 21 September 2017 at 13:09:33 UTC, Daniel Kozak wrote:
>
>> wrong version, this is my letest version: https://paste.ofcode.org/qWsQi kdhKiAywgBpKwANFR
>>
>> On Thu, Sep 21, 2017 at 3:01 PM, Daniel Kozak <kozzi11@gmail.com> wrote:
>>
>> my version: https://paste.ofcode.org/RLX7GM6SHh3DjBBHd7wshj
>>>
>>> On Thu, Sep 21, 2017 at 2:50 PM, Sönke Ludwig via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>>>
>>> Am 21.09.2017 um 14:41 schrieb Vadim Lopatin:
>>>>
>>>> [...]
>>>>>
>>>> Oh, sorry, I forgot the reusePort option, so that multiple sockets can listen on the same port:
>>>>
>>>>     auto settings = new HTTPServerSettings("0.0.0.0:3000");
>>>>     settings.options |= HTTPServerOption.reusePort;
>>>>     listenHTTP(settings, &handleRequest);
>>>>
>>>
> Hi, would it be possible to re-share the example of vibe.d woth multithreaded support.
>
> The pastebin link has expired and the pull request doesnt have the latest version.
>
> Thanks
>
> Ade
>


November 03, 2017
On Monday, 30 October 2017 at 17:23:02 UTC, Daniel Kozak wrote:
> Maybe this one:
>
> import vibe.d;
> import std.regex;
> import std.array : appender;
>
> static reg = ctRegex!"^/greeting/([a-z]+)$";
>
> void main()
> {
>     setupWorkerThreads(logicalProcessorCount);
>     runWorkerTaskDist(&runServer);
>     runApplication();
> }
>
> void runServer()
> {
>     auto settings = new HTTPServerSettings;
>     settings.options |= HTTPServerOption.reusePort;
>     settings.port = 3000;
>     settings.serverString = null;
>     listenHTTP(settings, &handleRequest);
> }
>
> void handleRequest(HTTPServerRequest req,
>                     HTTPServerResponse res)
> {
>     switch(req.path)
>     {
>     case "/": res.writeBody("Hello World", "text/plain");
>         break;
>     default:
>         auto m = matchFirst(req.path, reg);
>         string message = "Hello, ";
>         auto app = appender(message);
>         app.reserve(32);
>         app ~= m[1];
>         res.writeBody(app.data, "text/plain");
>     }
> }
>
> On Mon, Oct 30, 2017 at 5:41 PM, ade90036 via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>
>> On Thursday, 21 September 2017 at 13:09:33 UTC, Daniel Kozak wrote:
>>
>>> wrong version, this is my letest version: https://paste.ofcode.org/qWsQi kdhKiAywgBpKwANFR
>>>
>>> On Thu, Sep 21, 2017 at 3:01 PM, Daniel Kozak <kozzi11@gmail.com> wrote:
>>>
>>> my version: https://paste.ofcode.org/RLX7GM6SHh3DjBBHd7wshj
>>>>
>>>> On Thu, Sep 21, 2017 at 2:50 PM, Sönke Ludwig via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>>>>
>>>> Am 21.09.2017 um 14:41 schrieb Vadim Lopatin:
>>>>>
>>>>> [...]
>>>>>>
>>>>> Oh, sorry, I forgot the reusePort option, so that multiple sockets can listen on the same port:
>>>>>
>>>>>     auto settings = new HTTPServerSettings("0.0.0.0:3000");
>>>>>     settings.options |= HTTPServerOption.reusePort;
>>>>>     listenHTTP(settings, &handleRequest);
>>>>>
>>>>
>> Hi, would it be possible to re-share the example of vibe.d woth multithreaded support.
>>
>> The pastebin link has expired and the pull request doesnt have the latest version.
>>
>> Thanks
>>
>> Ade

I tried to run the example, and I'm struck with a linker error DMD v2.076.1 and LDC 1.4.0.

03-11-2017 11:34:16 arun-desk-r7 ~/code/personal/d/simple-web-benchmark
$ dub run --root=d --compiler=dmd --build=release --config=dmd
Fetching libevent 2.0.2+2.0.16 (getting selected version)...
Fetching diet-ng 1.4.3 (getting selected version)...
Fetching taggedalgebraic 0.10.7 (getting selected version)...
Fetching openssl 1.1.5+1.0.1g (getting selected version)...
Fetching botan 1.12.9 (getting selected version)...
Fetching memutils 0.4.9 (getting selected version)...
Fetching vibe-d 0.8.2-alpha.2 (getting selected version)...
Fetching vibe-core 1.2.1-alpha.2 (getting selected version)...
Fetching libasync 0.8.3 (getting selected version)...
Fetching botan-math 1.0.3 (getting selected version)...
Fetching eventcore 0.8.20 (getting selected version)...
Package vibe-core can be upgraded from 1.2.1-alpha.2 to 1.3.0-alpha.2.
Package eventcore can be upgraded from 0.8.20 to 0.8.21.
Use "dub upgrade" to perform those changes.
Performing "release" build using dmd for x86_64.
vibe-d:utils 0.8.2-alpha.2: building configuration "library"...
vibe-d:data 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:core 0.8.2-alpha.2: building configuration "libevent"...
immutable(ubyte)[]
vibe-d:crypto 0.8.2-alpha.2: building configuration "library"...
diet-ng 1.4.3: building configuration "library"...
vibe-d:stream 0.8.2-alpha.2: building configuration "library"...
vibe-d:textfilter 0.8.2-alpha.2: building configuration "library"...
vibe-d:inet 0.8.2-alpha.2: building configuration "library"...
vibe-d:tls 0.8.2-alpha.2: building configuration "notls"...
vibe-d:http 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:mail 0.8.2-alpha.2: building configuration "library"...
vibe-d:mongodb 0.8.2-alpha.2: building configuration "library"...
vibe-d:redis 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:web 0.8.2-alpha.2: building configuration "library"...
vibe-d 0.8.2-alpha.2: building configuration "libevent"...
vibedtest ~master: building configuration "dmd"...
Linking...
/usr/bin/ld: cannot find -levent
/usr/bin/ld: cannot find -levent_pthreads
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.
03-11-2017 11:35:10 arun-desk-r7 ~/code/personal/d/simple-web-benchmark
$

November 03, 2017
On Friday, 3 November 2017 at 18:44:30 UTC, Arun Chandrasekaran wrote:
> I tried to run the example, and I'm struck with a linker error DMD v2.076.1 and LDC 1.4.0.
>
> /usr/bin/ld: cannot find -levent
> /usr/bin/ld: cannot find -levent_pthreads

Did you try installing libevent and libevent-pthreads?
November 03, 2017
On Friday, 3 November 2017 at 18:44:30 UTC, Arun Chandrasekaran wrote:
> On Monday, 30 October 2017 at 17:23:02 UTC, Daniel Kozak wrote:
>> Maybe this one:
>>
>
>   clip
>
> vibedtest ~master: building configuration "dmd"...
> Linking...
> /usr/bin/ld: cannot find -levent
> /usr/bin/ld: cannot find -levent_pthreads
> collect2: error: ld returned 1 exit status
> Error: linker exited with status 1
> dmd failed with exit code 1.
> 03-11-2017 11:35:10 arun-desk-r7 ~/code/personal/d/simple-web-benchmark
> $

Perhaps you need to install the libevent development package on your system (libevent-dev or something similar).
May 09, 2018
On Monday, 30 October 2017 at 17:23:02 UTC, Daniel Kozak wrote:
> Maybe this one:
>
> import vibe.d;
> import std.regex;
> import std.array : appender;
>
> static reg = ctRegex!"^/greeting/([a-z]+)$";
>
> void main()
> {
>     setupWorkerThreads(logicalProcessorCount);
>     runWorkerTaskDist(&runServer);
>     runApplication();
> }
>
> void runServer()
> {
>     auto settings = new HTTPServerSettings;
>     settings.options |= HTTPServerOption.reusePort;
>     settings.port = 3000;
>     settings.serverString = null;
>     listenHTTP(settings, &handleRequest);
> }
>
> void handleRequest(HTTPServerRequest req,
>                     HTTPServerResponse res)
> {
>     switch(req.path)
>     {
>     case "/": res.writeBody("Hello World", "text/plain");
>         break;
>     default:
>         auto m = matchFirst(req.path, reg);
>         string message = "Hello, ";
>         auto app = appender(message);
>         app.reserve(32);
>         app ~= m[1];
>         res.writeBody(app.data, "text/plain");
>     }
> }
>
> On Mon, Oct 30, 2017 at 5:41 PM, ade90036 via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>
>> On Thursday, 21 September 2017 at 13:09:33 UTC, Daniel Kozak wrote:
>>
>>> wrong version, this is my letest version: https://paste.ofcode.org/qWsQi kdhKiAywgBpKwANFR
>>>
>>> On Thu, Sep 21, 2017 at 3:01 PM, Daniel Kozak <kozzi11@gmail.com> wrote:
>>>
>>> my version: https://paste.ofcode.org/RLX7GM6SHh3DjBBHd7wshj
>>>>
>>>> On Thu, Sep 21, 2017 at 2:50 PM, Sönke Ludwig via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>>>>
>>>> Am 21.09.2017 um 14:41 schrieb Vadim Lopatin:
>>>>>
>>>>> [...]
>>>>>>
>>>>> Oh, sorry, I forgot the reusePort option, so that multiple sockets can listen on the same port:
>>>>>
>>>>>     auto settings = new HTTPServerSettings("0.0.0.0:3000");
>>>>>     settings.options |= HTTPServerOption.reusePort;
>>>>>     listenHTTP(settings, &handleRequest);
>>>>>
>>>>
>> Hi, would it be possible to re-share the example of vibe.d woth multithreaded support.
>>
>> The pastebin link has expired and the pull request doesnt have the latest version.
>>
>> Thanks
>>
>> Ade

With vibe.d 0.8.2, even when multiple worker threads are setup, only one thread handles the requests:

```
import core.thread;
import vibe.d;
import std.experimental.all;

auto reg = ctRegex!"^/greeting/([a-z]+)$";

void main()
{
    writefln("Master %d is running", getpid());
    setupWorkerThreads(logicalProcessorCount + 1);
    runWorkerTaskDist(&runServer);
    runApplication();
}

void runServer()
{
    auto settings = new HTTPServerSettings;
    settings.options |= HTTPServerOption.reusePort;
    settings.port = 8080;
    settings.bindAddresses = ["127.0.0.1"];
    listenHTTP(settings, &handleRequest);
}

void handleRequest(HTTPServerRequest req,
                    HTTPServerResponse res)
{
    writeln("My Thread Id: ", to!string(thisThreadID));
    // simulate long runnig task
    Thread.sleep(dur!("seconds")(3));
	
    if (req.path == "/")
        res.writeBody("Hello, World! from " ~ to!string(thisThreadID), "text/plain");
    else if (auto m = matchFirst(req.path, reg))
        res.writeBody("Hello, " ~ m[1] ~ " from " ~ to!string(thisThreadID), "text/plain");
}
```

That could be the reason for slowness.