-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Description
I'm not sure if this is the right place to ask...
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:
- 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 .. CloseFilepattern 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.exeintentionally 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.exedoes very little work (4 winapi calls) whereruby.exedoes a lot (8 * N calls (where N is the dir depth of a file path) + 1CreateFileMappingwhich seems to lock the readers of a file).
Metadata
Metadata
Assignees
Labels
No labels
