4 ms·
While I write most of my scripts in Ruby and enjoy doing so, there is one gripe I have with it: its slow start-up time. On my machine, running an empty Ruby scr
by floppy-disk 2y ago
While I write most of my scripts in Ruby and enjoy doing so, there is one gripe I have with it: its slow start-up time.
On my machine, running an empty Ruby script takes about 100ms, compared to <10ms for Python, Perl, Lua, Bash.
One can mitigate the problem somewhat using the `--disable-gems` flag, but that's not a good general solution.
- Borg3 2y ago100ms !!!! wtf? :) [borg@cube] time ruby -e 'nil' real 0m0.007s
- floppy-disk 2y agoWhoa, interesting... What version are you running? Here's my system: $ ruby -v ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux] $ time ruby -e '' real 0m0.122s user 0m0.102s sys 0m0.020s I found an old Reddit thread also hinting at bad start-up times: https://old.reddit.com/r/ruby/comments/aqxepw/rubys_startup_time_seems_to_get_worse https://old.reddit.com/r/ruby/comments/aqxepw/rubys_startup_....
- Borg3 2y agoVery old one :) Because its reliable. Version 1.8.7 here. I want controllable delays. I want controllable threads :) I want portability. Of course, if you need more peformance, you need to go for newer stuff.
- Alifatisk 2y agoI’ll try this out sometime, but probably through docker https://hub.docker.com/r/hublogix/minimal-ruby https://hub.docker.com/r/hublogix/minimal-ruby
- Borg3 2y agoYeah.. old ruby have interesting build system. It first build miniruby with is single selfcontained binary having all core ruby functionality. Then, it is used to run some more .rb build scripts to finaly make fully functional ruby. Actyally that miniruby is pretty usefull. For basic stuff. Also, its very easy to build static ruby containing all extra stuff you care about, like Win32 API for example. I myself have custom ruby binary on Win32 (Cygwin) with GRX library added in, So I can do basic graph stuff directly from ruby :) That stuff is written in it: http://borg.uu3.net/~borg/?gperf http://borg.uu3.net/~borg/?gperf
- Alifatisk 2y ago> It first build miniruby with is single selfcontained binary having all core ruby functionality. > For basic stuff. Also, its very easy to build static ruby containing all extra stuff you care about, like Win32 API for example. Wow, this reminds me abit of MRuby. So I could basically ship a script with the self-contained ruby executable instead of having to force users to install Ruby on their machine? How can I get ahold of miniruby? Or is there any resource somewhere that I can dig into?
- Borg3 2y agoHmm, I think this is not supported, but probably not very hard to do it at least for Windows (PE executable). Hard to say about new Ruby versions like 3.x or even 2.x. 1.8.x have pretty simple building process, just grab the old source. You can use --enable-static builds there. Miniruby is build by default, always, because its part of building process. Also, if you are platform are you targeting? Win32 only?
- Alifatisk 2y agoOkey thank you for the details. I am mainly targetting windows but I wouldn’t mind being able to include mac & linux aswell. I wonder if experimenting miniruby with cosmopolitian would help with that?
- 2y ago