Is there any language that native-compiles faster than D?
James Lu
jamtlu at gmail.com
Wed Aug 26 01:13:47 UTC 2020
On Thursday, 20 August 2020 at 20:50:25 UTC, Per Nordlöw wrote:
> After having evaluated the compilation speed of D compared to
> other languages at
>
> https://github.com/nordlow/compiler-benchmark
>
> I wonder; is there any language that compiles to native code
> anywhere nearly as fast or faster than D, except C?
>
> If so it most likely needs to use a backend other than LLVM.
>
> I believe Jai is supposed to do that but it hasn't been
> released yet.
V8 JavaScript compiles faster:
$ d8 --always-opt --trace-opt --single-threaded
--no-compilation-cache mandelbrot.js | ts -s "%.s"
0.000025 [compiling method 0x3fc50821068d <JSFunction (sfi =
0x3fc508210165)> using TurboFan]
0.001651 [optimizing 0x3fc50821068d <JSFunction (sfi =
0x3fc508210165)> - took 4.455, 41.945, 0.052 ms]
0.001707 [optimizing 0x3fc508085b65 <JSFunction Complex (sfi =
0x3fc508210261)> because --always-opt]
0.001736 [compiling method 0x3fc508085b65 <JSFunction Complex
(sfi = 0x3fc508210261)> using TurboFan]
0.001763 [optimizing 0x3fc508085b65 <JSFunction Complex (sfi =
0x3fc508210261)> - took 0.125, 0.284, 0.019 ms]
0.001789 [optimizing 0x3fc508211665 <JSFunction
iterate_mandelbrot (sfi = 0x3fc508210229)> because --always-opt]
0.001817 [compiling method 0x3fc508211665 <JSFunction
iterate_mandelbrot (sfi = 0x3fc508210229)> using TurboFan]
0.001842 [optimizing 0x3fc508211665 <JSFunction
iterate_mandelbrot (sfi = 0x3fc508210229)> - took 0.167, 1.197,
0.022 ms]
0.001868 [optimizing 0x3fc508085b85 <JSFunction abs (sfi =
0x3fc508210299)> because --always-opt]
0.001892 [compiling method 0x3fc508085b85 <JSFunction abs (sfi =
0x3fc508210299)> using TurboFan]
0.001916 [optimizing 0x3fc508085b85 <JSFunction abs (sfi =
0x3fc508210299)> - took 0.125, 0.421, 0.025 ms]
0.002093 [optimizing 0x3fc508085bbd <JSFunction mul (sfi =
0x3fc508210309)> because --always-opt]
0.002337 [compiling method 0x3fc508085bbd <JSFunction mul (sfi =
0x3fc508210309)> using TurboFan]
0.002365 [optimizing 0x3fc508085bbd <JSFunction mul (sfi =
0x3fc508210309)> - took 0.134, 0.550, 0.023 ms]
0.002389 [optimizing 0x3fc508085ba1 <JSFunction add (sfi =
0x3fc5082102d1)> because --always-opt]
0.002498 [compiling method 0x3fc508085ba1 <JSFunction add (sfi =
0x3fc5082102d1)> using TurboFan]
--single-threaded disables compilation background tasks
--always-opt makes V8 immediately compile the function without
profiling
Timestamps thanks to "ts" from moreutils.
$ time dmd -c mandelbrot.d
real 0m0.507s
user 0m0.416s
sys 0m0.094s
V8 compiles 202x faster.
-c to omit linking, which can be slow.
That's using the struct/double version. (I also ran it with
timestamps on the verbose version, writing to disk accounted for
a negligible amount of time.)
Obviously, take these results with a grain of salt, since
--always-opt makes the compiled program very slow. But still,
even with it off, V8 can compile very fast.
---
LDC2 takes 1.695 seconds to compile with no flags, and 2.126
seconds with O2.
QuickJS takes around 0.36 seconds to compile, but the program
output is unbearably slow.
However, I suspect by the time the fastest and most balanced D
compiler finishes compiling the program and executing it, V8 will
already have finished executing it.
More information about the Digitalmars-d
mailing list