Benchmark of D against other languages
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 31 14:30:54 PDT 2015
On 03/31/2015 09:07 PM, Andrei Alexandrescu wrote:
>
> True. I don't have time to put this on my plate, does anyone? -- Andrei
Very little, here is my outcome.
- brainfuck => better backend, better AA
The switch in the run loop doesn't use a switch table.
A lot of time is also spent on AA lookup.
- base64 => Base64.decode could be optimized
It's already quite OK, but a few things could be done better.
https://issues.dlang.org/show_bug.cgi?id=14384
- JSON => replace std.json, better AA and GC
std.json is horribly bad + slow AA + slow GC. It got almost 3x faster
with the new GC changes though.
- matmul => need linear algebra library
Can use std.numeric.dotProduct making it 33% faster.
https://github.com/kostya/benchmarks/pull/6
A good linear algebra library could radically improve this.
- havlak => alternative memory management, better AA and GC
Got ~30% faster by the recent GC improvements.
People too often new classes/create arrays like crazy (in loops).
Using alternative memory management schemes is non-obvious or simply
too hard.
Action Points:
- I'll ask him to use dmd 2.067.0 and add ldc.
- We should finally acknowledge that dmd's backend has no future for
optimized code.
- D's AA is really slow, because of the C-ish interface.
Making AA's a library type is mandatory, but difficult (already failed
thrice). I outlined clear acceptance criteria for a good AA
implementation here
https://github.com/D-Programming-Language/druntime/pull/934#issuecomment-65916801.
I currently lean towards adding a new implementation as `AA!(Key,
Value)` while slowly deprecating any semantic of the builtin AA that
can't be supported in a library implementation,
then switching the implementations.
Changing the builtin AA to a library type would break a lot of code,
because of the subtle semantic/attribute differences.
- We have a phobos candidate for a std.json replacement that comes with
a pull parser, we should move it to std.experimental asap.
http://code.dlang.org/packages/std_data_json
- The GC can never be fast enough, but we're already working on it.
- Make GC alternatives more prominent, e.g. tell people to favor structs
over classes.
- Add getOrSet to AA
Simple optimization for a common use-case.
https://issues.dlang.org/show_bug.cgi?id=14386
- Use open addressing for AA
Considerable speeds up AA, fairly simple to implement.
https://issues.dlang.org/show_bug.cgi?id=14385
Now I spent way more than 1 hour on this ;).
-Martin
More information about the Digitalmars-d
mailing list