How fast is Gluon?

Hi,
I'm looking for an embedded scripting language for a game. Something like Lua, but written natively in Rust and statically typed.

Currently Gluon seems to be a good choice, but I want to know how fast it is compared to other scripting languages like Lua or Python. If it is slower than Lua or even slower than Python it might be to slow for what I want to do with it. Similar or better performance to Lua would be nice.

I don't expect the performance of Node.js or even LuaJIT, even if that would be optimal.

Regards
Markus

cc @Marwes

Did a quick and dirty comparison of factorial compared to lua, it is not that great atm since vm optimization has been less of a priority than language features.

factorial/gluon         time:   [13.705 us 13.812 us 13.932 us]
                        change: [+23.875% +25.569% +27.223%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 7 outliers among 100 measurements (7.00%)
  4 (4.00%) high mild
  3 (3.00%) high severe
factorial/lua           time:   [1.4681 us 1.4778 us 1.4895 us]
                        change: [-4.4998% -1.9454% +1.1977%] (p = 0.17 > 0.05)
                        No change in performance detected.
Found 18 outliers among 100 measurements (18.00%)
  3 (3.00%) high mild
  15 (15.00%) high severe

Part of the overhead is certainly because of bounds checking, some of that could be fixed without major changes without resorting wildly unsafe code (ala C) but some would need larger changes such as a bytecode validator. The function call preparation in gluon is also a bit more expensive in gluon than it should be which should be improved.

Most egregiously, I had to modify the gluon benchmark to directly use the primitive operators #Int* . Using the normally, overload + etc implies two(!) extra function calls per operation. Without those changes gluon performs much worse still but once function inlining (which is the works, but blocked on salsa-rs/salsa#147) that change won't be necessary.

Add some mention of performance to documentation · Issue #561 · gluon-lang/gluon · GitHub

4 Likes

With refactor(vm): Track rooting better in the vm to reduce unsafety by Marwes · Pull Request #764 · gluon-lang/gluon · GitHub the gluon times are roughly halved.

factorial/gluon/1       time:   [346.49 ns 348.52 ns 350.77 ns]                              
                        change: [-14.644% -13.254% -11.667%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  5 (5.00%) high mild
  2 (2.00%) high severe
factorial/gluon/10      time:   [3.4676 us 3.5005 us 3.5388 us]                                
                        change: [-15.823% -14.227% -12.660%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  2 (2.00%) high mild
  4 (4.00%) high severe
factorial/gluon/20      time:   [7.0148 us 7.0680 us 7.1256 us]                                
                        change: [-12.142% -10.964% -9.8744%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe
factorial/lua/1         time:   [311.94 ns 315.15 ns 319.15 ns]                            
                        change: [-11.530% -10.437% -9.3352%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  1 (1.00%) low mild
  5 (5.00%) high mild
  5 (5.00%) high severe
factorial/lua/10        time:   [857.27 ns 861.57 ns 866.42 ns]                              
                        change: [-15.759% -14.308% -12.986%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 15 outliers among 100 measurements (15.00%)
  2 (2.00%) low severe
  1 (1.00%) low mild
  6 (6.00%) high mild
  6 (6.00%) high severe
factorial/lua/20        time:   [1.4435 us 1.4504 us 1.4588 us]                              
                        change: [-15.585% -14.067% -12.673%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  1 (1.00%) low severe
  2 (2.00%) low mild
  3 (3.00%) high mild
  5 (5.00%) high severe
5 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.