Open phortx opened 5 years ago
Hi thanks for trying out TruffleRuby - we appreciate it.
Before that I added a simple benchmark to be able to compare the performance. But from all I've read about truffleruby and all the benchmark charts I've seen, I expected truffleruby to be much faster.
TruffleRuby is designed to be primarily faster for longer-running workloads, such as servers. The technology we use to optimise Ruby - just-in-time compilation - needs time to profile your application and then compile it at runtime. This warm up period is needed to be effective. This isn't unique to TruffleRuby - the same thing applies to JRuby, the V8 JavaScript interpreter in Node.js, and others. The MRI JIT doesn't need it because it's currently simpler. As it gets more advanced it'll need more warm-up period.
I'm on macos and installed truffle via asdf-ruby (which uses ruby-build): asdf install ruby truffleruby-1.0.0-rc15:
Could you try a more recent version of TruffleRuby? Please try 19.0.0. This probably won't make a big difference, however.
I ran bundle and then executed my gem. I was confused because it took way longer: 11.478s.
Yes, so with such a short-running program the just-in-time compiler doesn't really have long enough to run and make a difference.
Now - we are interested in short-running programs, and we want to make these fast as well. We have some unique technology here, where we're looking at pre-initialising programs so that we remove the overhead of loading and parsing Ruby code, and setting up libraries, but these are just proposals at the moment.
So I've added some benchmark calls (via the ruby benchmark module) to see whether the code is slow at all or just parts (maybe I make use of a slow feature or whatever).
Which benchmark tool are you using here? We'd normally recommend benchmark-ips
, because it's designed to account for the warm-up period.
or not suitable for small programs.
It isn't focused on small programs at the moment, that's true. We're working on improving that.
Any ideas? :)
Are you able to share the code of your program and benchmarks? Either publicly or privately? So we could investgiate ourselves.
Thank you very much for the comprehensive answer! :)
I understand that truffle targets longer running processes. However I love ruby but I'm also bothered by rubys performance and thus I'm searching for alternatives.
I'll send you a mail with the repo of the project.
FWIW, there are cases where we're fast on short-running programs, see https://eregon.me/blog/2018/02/19/truffleruby-native-fast-short-scripts.html
Those programs load very little code though, I think part of the bottleneck currently is loading code, as you noticed (requires
). I think we can improve quite a bit there, but it's much easier to optimize with a given workload.
Hi folks,
I have a simple ruby written CLI tool, for which performance is really important. So I wanted to give truffleruby a try today.
Before that I added a simple benchmark to be able to compare the performance. But from all I've read about truffleruby and all the benchmark charts I've seen, I expected truffleruby to be much faster.
With MRI 2.6.3 and
--jit
flag, my cli tool needs 1.150s to run.I'm on macos and installed truffle via asdf-ruby (which uses ruby-build):
asdf install ruby truffleruby-1.0.0-rc15
:Looks good so far:
I ran
bundle
and then executed my gem. I was confused because it took way longer: 11.478s.So I've added some benchmark calls (via the ruby benchmark module) to see whether the code is slow at all or just parts (maybe I make use of a slow feature or whatever).
Results:
So truffle is slower in all aspects of the script. Especially the startup time.
Now I'm not sure whether my installation is broken, truffle is very slow or not suitable for small programs.
Any ideas? :)