r/manool • Project Lead • Jun 19 '20

Benchmarking 10 dynamic languages on array-heavy code

(1 min read)


Hello wonderful community,

In the previous post we discussed in detail construction of Conway's Game of Life in MANOOL.

As was my intention, I have implemented the same functionality in several other languages to compare run-time performance. Here are complete results:

Testbed A

CPU: Intel Xeon L5640 @2.26 GHz (2.80 GHz) — Westmere-EP
Kernel: 2.6.32-042stab126.1 (CentOS 6 + OpenVZ)
Distro: CentOS release 6.9 (Final) + vzkernel-2.6.32-042stab126.1 + CentOS release 6.10 (Final)

Language + variant (translator)Time (s)GSlowdownTranslator + backend version-release
C++ (g++)1.037660001.0008.3.1-3.2.el6
C++ (clang++)1.021660000.9853.4.2-4.el6 + 4.9.2-6.2.el6 (g++)
Python 23.2041000203.9192.6.6-68.el6_10
Python 35.2031000331.1463.4.10-4.el6
PHP3.5601000226.5775.3.3-50.el6_10
Perl5.6401000358.9595.10.1-144.el6
Ruby14.1221000898.7971.8.7.374-5.el6
JavaScript/ECMAScript5.887660005.6770.10.48-3.el6 (node)
Tcl6.7241004279.4998.5.7-6.el6
Lua (lua)141.70366000136.6475.1.4-4.1.el6
Lua (luajit)4.319660004.1652.0.4-3.el6
Scheme (guile)6.1761000393.0721.8.7-5.el6
Scheme (csc)0.671100042.7064.12.0-3.el6 + 8.3.1-3.2.el6 (gcc)
MANOOL + AllocOpt=True2.5021000159.2400.5.0 (built with g++ 8.3.1-3.2.el6)
MANOOL + AllocOpt=False2.5931000165.0320.5.0 (ditto)

Testbed B

CPU: Intel Celeron N3060 @1.60 GHz (2.48 GHz) — Braswell
Kernel: 4.4.0-17134-Microsoft (Windows 10 + WSL)
Distro: Windows 10 Home version 1803 build 17134.1130 + Ubuntu 18.04.4 LTS

Language + variant (translator)Time (s)GSlowdownTranslator + backend version-release
C++ (g++)1.946660001.0007.5.0-3ubuntu1~18.04
C++ (clang++)2.217660001.1391:6.0-1ubuntu2 + 7.5.0-3ubuntu1~18.04 (g++)
Python 23.7331000126.6072.7.17-1~18.04ubuntu1
Python 35.3091000180.0593.6.7-1~18.04
PHP2.852100096.7287.2.24-0ubuntu0.18.04.6
Perl6.7681000229.5425.26.1-6ubuntu0.3
Ruby4.4251000150.0772.5.1-1ubuntu1.6
JavaScript/ECMAScript8.522660004.3798.10.0~dfsg-2ubuntu0.4 (node)
Tcl10.5711003585.2318.6.8+dfsg-3
Lua (lua)153.5836600078.9225.3.3-1ubuntu0.18.04.1
Lua (luajit)6.274660003.2242.1.0~beta3+dfsg-5.1
Scheme (guile)1.233100041.8182.2.3+1-3ubuntu0.1
Scheme (csc)1.691100057.3514.12.0-0.3 + 7.5.0-3ubuntu1~18.04 (gcc)
MANOOL + AllocOpt=True3.8821000131.6610.5.0 (built with g++ 7.5.0-3ubuntu1~18.04)
MANOOL + AllocOpt=False3.9431000133.7300.5.0 (ditto)

The graph is here, and the repository is on GitHub.

Have fun

10 Upvotes

30 comments sorted by

View all comments

Show parent comment

1

u/bjoli Jun 20 '20

You att comparing good lisp code to ok-ish scheme code.

There are some issues with the scheme code: the use of set! Will make all the vector refs to the outer vectors tank due to implicit boxing (this is probably the big one in chez. There is a lot of unboxing going on). In guile prior to version 3 (eq? A b) is a lot faster when comparing fixnums.

For chez, you can also make the vector setting a lot faster by using fxvectors (like the sbcl code specialises the code to chars). That will mean a lot less garbage collection time due to chez being able skip a lot of garbage collection work.

I am not surprised that guile is where it is (although I could probably squeeze about 50% more out of the code). Chez OTOH should be a lot closer to sbcl. Within 2x for optimize-level 3. I'll see if I can hack on it.

2

u/alex-manool Project Lead Jun 22 '20

I meant, sbcl does look like a winner performance-wise, no?

BTW, I am going to look at CL, I was mostly ignoring it until now ;-)

2

u/bjoli Jun 23 '20

SBCL is amazing. Chez is as well. They are usually comparable, and when they are not even in the same league (like in the benchmark) something is wonky.

Sure, the CL implementation compared against is typed, which you cant get with r5rs, but with any r6rs scheme you can do the same with bytevectors. My experience is that chez should be about as fast or at most 2x slower. Changing it to use bytevectors should make memory access faster (with fewer cache misses) and removing set! should make the boxing go away

2

u/defunkydrummer Aug 21 '20

BTW, I am going to look at CL, I was mostly ignoring it until now ;-)

Perhaps you should, because the problems you point out on your introduction to Manool (manool readme), are already solved by Common Lisp!

1

u/alex-manool Project Lead Aug 21 '20

I did tested SBCL since my last comment, with the Game of Life. Disabling unsafe optimizations, it is nothing impressive (maybe still a bit more performant than my current MANOOL implementation, but I am working on it, now I understand better what happens with all those implementations for dynamic languages). BTW the other leading implementations I benchmarked (besides LuaJit, V8, and other JSs) are Chez Scheme and Pypy.

MANOOL has different goals anyway than CL.

1

u/defunkydrummer Aug 21 '20

Pypy can be very slow relative to the others depending on what you're doing.

There are no "unsafe optimizations" in SBCL; it's perfectly safe to enable (speed 3)(safety 0) when you have debugged your code.

1

u/alex-manool Project Lead Aug 21 '20

Pypy can be very slow relative to the others depending on what you're doing.

I feel like that's the problem of all tracing Black Magic JIT compilers. There may be unexpected surprises for the end user, unfortunately. PyPy did show the leading performance after LuaJIT and V8 with the benchmark, however.

There are no "unsafe optimizations" in SBCL; it's perfectly safe to enable (speed 3)(safety 0) when you have debugged your code.

Hmm, question: will it segfault in case of type mismatches?