ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 353 forks source link

opam exec overhead #5752

Open jonahbeckford opened 10 months ago

jonahbeckford commented 10 months ago

Something like the following is instantaneous:

opam.exe: [EXEC:312] ["C:\Users\WDAGUT~1\AppData\Local\Programs\DKMLNA~1\tools\MSYS2\usr\bin\env.exe"
                      "C:\Users\WDAGUT~1\AppData\Local\Programs\DKMLNA~1\bin\opam-real.exe"
                      "--version"]
2.2.0~alpha0~20221228

But the following (opam exec -- C:\Windows\System32\where.exe /?) visibly pauses for at least one second before executing the command:

opam.exe: [EXEC:296] ["C:\Users\WDAGUT~1\AppData\Local\Programs\DKMLNA~1\tools\MSYS2\usr\bin\env.exe"
                      "C:\Users\WDAGUT~1\AppData\Local\Programs\DKMLNA~1\bin\opam-real.exe"
                      "exec" "--" "C:\Windows\System32\where.exe" "/?"]

I get this one second pause with opam var as well.

This is related to https://github.com/ocaml/opam/issues/5741

kit-ty-kate commented 10 months ago

This is related to #5741

That indeed looks related to this as opam exec -- reads a couple files (to lead the switch state). Do you have any idea what could be different from Unix-likes when reading files?

jonahbeckford commented 10 months ago

Speed test for my mac M1 (the green numbers on right hand side are statistically accurate; ignore the speedometers which are just a snapshot of fluctuations):

DiskSpeedTest
jonahbeckford commented 10 months ago

And for my Windows drive Y: which is where I have my current opam root and opam switch.

DiskSpeedTest
jonahbeckford commented 10 months ago

So, in the numbers I am reporting the mac M1 mini drive is significantly faster. (I have a Z: drive that is faster than the mac M1, but I don't use that for opam. And I expect my slower Y: drive is more typical for average Windows users so I'll focus on my Y: drive.)

jonahbeckford commented 10 months ago

I realized that this issue (not #5741 though) I had measured using Windows Sandbox. The opam root would have been a virtualized file system; that is not representative. So, in the table below you'll see numbers from my Y: drive ... the same drive I attached disk speed numbers.

Times rounded to the nearest tenth of a second. The opam-real is regular opam executable without any DkML shims.

Time What Where
0.2s measure-command { opam-real --version } Windows
0.1s time opam --version M1
0.3s measure-command { opam-real var --global } Windows
0.1s time opam var --global M1
0.0s measure-command { C:\Windows\System32\where.exe /? } Windows
0.0s time /usr/bin/true M1
0.2s measure-command { opam-real exec -- C:\Windows\System32\where.exe /? } Windows
0.1s time opam exec -- /usr/bin/true M1
jonahbeckford commented 10 months ago

Conclusion:

I think this is lower priority but given that students especially are often on older Windows hardware (and definitely not SSDs), this hit will be noticeable for a significant fraction of new users.