You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It takes at least 1 second to start ruby.exe on my PC while it starts instantly on other OS. So I opened process monitor to see what actually happens:
(runs ruby -e 1)
My ruby's arch is x64-mingw-ucrt.
It is obvious that ruby loads its stdlib on start, there're a lot of files. For each file, it seems ruby.exe will query fs info of every parent path to get a normalized path.
There're a lot of duplicated works, the CreateFile .. CloseFile pattern occurs about a hundred of times to test the same folder. Each task is very quick, but when there're 100 tasks it will cost > 1 second.
Additional contexts:
I noticed that this code in ruby's source code may be doing these path checking works.
For comparison, I also profiles node.exe -r ./a.js, which is quite fast:
The reasons behind, which I could come up with, are that:
node.exe intentionally bundles all it's stdlib into the binary, that reduces a lot of time to load the hundreds of files.
As of loading a single file, node.exe does very little work (4 winapi calls) where ruby.exe does a lot (8 * N calls (where N is the dir depth of a file path) + 1 CreateFileMapping which seems to lock the readers of a file).
Activity
daniel-rikowski commentedon Sep 19, 2025
This is a long-standing problem with Ruby on Windows. (e.g. https://bugs.ruby-lang.org/issues/19378)
I've had good experience using Bootsnap, especially the path pre-scanning feature (https://github.com/rails/bootsnap?tab=readme-ov-file#path-pre-scanning), perhaps it's suitable for your application, too.