Open chrisseaton opened 3 years ago
Right, that explains why it only happens on macOS then, it's due to the subprocesses of https://github.com/oracle/truffleruby/blob/634c0ae2517d04261b05e357b79da009eeac62ff/lib/truffle/truffle/openssl-prefix.rb. I'll look into it (running an extra subcommand when loading RubyGems to find libssl also seems suboptimal).
https://github.com/oracle/truffleruby/commit/8ca9852433bb4974bdf4e7306feee7e06235faec avoids creating autorelease pointers for spawning subprocesses.
It would be interesting to know how long brew --prefix
takes to see if it's worth optimizing for the common case of Homebrew being in /usr/local
.
@chrisseaton Could you measure that?
Regarding having Pointer finalizers without an extra thread, that's something that probably makes more sense in Truffle, and NFI has a NativeAllocation
that does something very similar.
With the new Truffle safepoints it might also be possible to simply run all finalizers on the main Ruby thread, but I'm unsure if it's a good idea or not.
Almost a second!
chrisseaton@Chris-Seatons-MacBook-Pro graal % disable -r time
chrisseaton@Chris-Seatons-MacBook-Pro graal % time -p brew --prefix openssl
/usr/local/opt/openssl@1.1
real 0.89
user 0.48
sys 0.40
chrisseaton@Chris-Seatons-MacBook-Pro graal % time -p brew --prefix openssl
/usr/local/opt/openssl@1.1
real 0.86
user 0.47
sys 0.38
chrisseaton@Chris-Seatons-MacBook-Pro graal % time -p brew --prefix openssl
/usr/local/opt/openssl@1.1
real 0.85
user 0.47
sys 0.37
chrisseaton@Chris-Seatons-MacBook-Pro ~ % time -p brew --prefix
/usr/local
real 0.02
user 0.01
sys 0.01
chrisseaton@Chris-Seatons-MacBook-Pro ~ % time -p brew --prefix
/usr/local
real 0.02
user 0.01
sys 0.01
chrisseaton@Chris-Seatons-MacBook-Pro ~ % time -p brew --prefix
/usr/local
real 0.03
user 0.01
sys 0.01
Right, so that's more like 20-30ms, seems worth optimizing the common case.
https://github.com/oracle/truffleruby/commit/3b05154d2bc1344eb161514388d8d8917b847c3e avoids that extra subprocess if Homebrew is in /usr/local
.
We should possibly: