April 18, 2017
I've written multi-threaded regex-redux benchmark for D language and made some tests. This is my first program written in D, I didn't know much about D a week ago.

Here are the results for other languages:

http://benchmarksgame.alioth.debian.org/u64q/regexredux.html

I have newer CPU than one used on this page. Tests were made on Debian 8 with i7-3770 3.4 Ghz (4C/8T) CPU.

I've tested C and Rust besides D becasue those are the top two languages on this benchmark.

Rust version 1.16 (newest stable)
GCC ver 4.9.2 (newest debian 8 stable)

I've changed target-cpu in Rust compile command to match my cpu.

C was the fastest (1.32) but used the most CPU, D was second (1.45) with lowest CPU usage!, Rust was third (1.55). In this benchmark D is faster than any other language besides C.

Code in D is very clean and readable, GC is operating normally.


Exacts results are below:

D
  User time (seconds): 1.91
        System time (seconds): 0.14
        Percent of CPU this job got: 140%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.45
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 263848

Rust

  User time (seconds): 2.72
        System time (seconds): 0.09
        Percent of CPU this job got: 181%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.55
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 199008

C
    User time (seconds): 4.51
        System time (seconds): 0.08
        Percent of CPU this job got: 346%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.32
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 151716


I got inspired by those results that's why I thought I will write all the other benchmarks from benchmarks game also for D and share the code and results on github + comparison to couple other languages.
April 18, 2017
On Monday, 17 April 2017 at 22:44:52 UTC, Stanislav Blinov wrote:
> On Monday, 17 April 2017 at 21:20:42 UTC, Jerry wrote:
>
>> So what happens when the resource outlives the object's lifetime.
>
> Then RAII rule is violated.
>
>> That's exactly what is happening when you are using the garbage collector.
>
> Correction, that is what *may* happen in some cases when you are using GC.

Not may, will definitely happen. Even if the destructor is called the memory is freed, alas the resource isn't freed and is freed at a later time when the object is destroyed. And as your above statement says, this violates the RAII rule.

>> That's exactly the case with the containers in phobos. So calling them RAII container is just incorrect.
>
> I never said they were.

Then why are you arguing for Jack..

> My argument was, from the start, that assessing the *language* RAII capability has nothing to do with *library* containers or the (lack of) use of @nogc attribute.

I never replied to you, you replied to me an my argument. I never said RAII capability has anything to do with, go back and read the comments and user names. You are confusing me for someone else it seems.
April 18, 2017
> D would have the ability to have a nice container that would do RAII
> (for classes since for structs, __dtors are called automatically)

That's just it, though. They are not. Not reliably.

Shachar
April 18, 2017
On Tuesday, 18 April 2017 at 02:57:59 UTC, prdan wrote:
> I've written multi-threaded regex-redux benchmark for D language and made some tests.

Nice!

> Rust version 1.16 (newest stable)
> GCC ver 4.9.2 (newest debian 8 stable)

Which compiler did you use for D?

> C was the fastest (1.32) but used the most CPU, D was second (1.45) with lowest CPU usage!

In benchmarks where some fixed amount of work should be done as fast as possible low CPU usage is not a good sign, it just means some cores were idle when they could really be working.
April 18, 2017
On Tuesday, 18 April 2017 at 07:22:29 UTC, thedeemon wrote:
> In benchmarks where some fixed amount of work should be done as fast as possible low CPU usage is not a good sign, it just means some cores were idle when they could really be working.

Minor note: sometimes high CPU usage isn't good either, if the CPU is used for multithreading overhead/bookkeeping (eg: scheduler).

April 18, 2017
On Tuesday, 18 April 2017 at 07:22:29 UTC, thedeemon wrote:
> Which compiler did you use for D?
>

I've used newest LDC.

> In benchmarks where some fixed amount of work should be done as fast as possible low CPU usage is not a good sign, it just means some cores were idle when they could really be working.

Not in this case, there is a batch of the job that need to be done parallel but second part is done sequential (that takes majority of the time) so in this case this is good. Just look at source code of the algorithm in the link I've provided.
I've also looked at callgrind and majority of the time is spent in regex so it's good.
April 18, 2017
On 04/17/2017 10:57 PM, prdan wrote:
> I've written multi-threaded regex-redux benchmark for D language and
> made some tests. This is my first program written in D, I didn't know
> much about D a week ago.
>
> Here are the results for other languages:
>
> http://benchmarksgame.alioth.debian.org/u64q/regexredux.html
>
> I have newer CPU than one used on this page. Tests were made on Debian 8
> with i7-3770 3.4 Ghz (4C/8T) CPU.

Cool, thanks for this work! However, a word of caution - experiments ran on different CPUs can't count as comparable.

> I got inspired by those results that's why I thought I will write all
> the other benchmarks from benchmarks game also for D and share the code
> and results on github + comparison to couple other languages.

That's an awesome initiative, please keep us posted!


Andrei
April 18, 2017
On 18/04/2017 1:22 PM, Andrei Alexandrescu wrote:
> On 04/17/2017 10:57 PM, prdan wrote:
>> I've written multi-threaded regex-redux benchmark for D language and
>> made some tests. This is my first program written in D, I didn't know
>> much about D a week ago.
>>
>> Here are the results for other languages:
>>
>> http://benchmarksgame.alioth.debian.org/u64q/regexredux.html
>>
>> I have newer CPU than one used on this page. Tests were made on Debian 8
>> with i7-3770 3.4 Ghz (4C/8T) CPU.
>
> Cool, thanks for this work! However, a word of caution - experiments ran
> on different CPUs can't count as comparable.

Even if the hardware is identical, all it takes is a setting changed in the thread scheduler of an OS and you will be getting wildly different results, beware of separate computers for benchmarking period.

April 18, 2017
On Tuesday, 18 April 2017 at 12:22:10 UTC, Andrei Alexandrescu wrote:

> Cool, thanks for this work! However, a word of caution - experiments ran on different CPUs can't count as comparable.
>

I didn't compare D times to numbers from benchmarks game site.
I've ran other languages on the same CPU also, all the numbers I've posted are from the same CPU for those 3 languages so they are comparable in this case :)


> That's an awesome initiative, please keep us posted!
>
>
> Andrei

Thanks, maybe I will write a blog post about my experiences also.
April 18, 2017
On 4/18/17 8:48 AM, prdan wrote:
> Thanks, maybe I will write a blog post about my experiences also.

That would be great! Michael Parker may be of help if you consider publishing in the official D Blog. -- Andrei