Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby ten times slower as a global command #2343

Open
2 tasks done
iandol opened this issue Oct 23, 2024 · 3 comments
Open
2 tasks done

Ruby ten times slower as a global command #2343

iandol opened this issue Oct 23, 2024 · 3 comments
Labels
⏩ performance An issue related to performance

Comments

@iandol
Copy link

iandol commented Oct 23, 2024

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

pixi global install ruby
pixi global install python
pixi global install hyperfine
hyperfine --warmup 3 "/Users/ian/.pixi/bin/ruby -e 'puts \"Ruby Hello\"'"
hyperfine --warmup 3 "/Users/ian/.pixi/envs/ruby/bin/ruby -e 'puts \"Ruby Hello\"'"
hyperfine --warmup 3 "/Users/ian/.pixi/bin/python -c 'print(\"Python Hello\")'"
hyperfine --warmup 3 "/Users/ian/.pixi/envs/python/bin/python -c 'print(\"Python Hello\")'"

Issue description

Running ruby results in 355ms time vs. 29.6ms when run from the enviroment bin directory directly. Python for comparison shows roughly the same performance.

ε ➪ hyperfine --warmup 3 "/Users/ian/.pixi/bin/ruby -e 'puts \"Ruby Hello\"'"
Benchmark 1: /Users/ian/.pixi/bin/ruby -e 'puts "Ruby Hello"'
  Time (mean ± σ):     355.7 ms ±   7.5 ms    [User: 126.6 ms, System: 207.4 ms]
  Range (min … max):   351.1 ms … 376.9 ms    10 runs
 
ε ➪ hyperfine --warmup 3 "/Users/ian/.pixi/envs/ruby/bin/ruby -e 'puts \"Ruby Hello\"'"
Benchmark 1: /Users/ian/.pixi/envs/ruby/bin/ruby -e 'puts "Ruby Hello"'
  Time (mean ± σ):      29.6 ms ±   0.4 ms    [User: 24.7 ms, System: 4.4 ms]
  Range (min … max):    28.2 ms …  30.8 ms    92 runs
                                                                                                                                                                                                                                 
ε ➪ hyperfine --warmup 3 "/Users/ian/.pixi/bin/python -c 'print(\"Python Hello\")'"
Benchmark 1: /Users/ian/.pixi/bin/python -c 'print("Python Hello")'
  Time (mean ± σ):      10.3 ms ±   0.2 ms    [User: 7.4 ms, System: 2.2 ms]
  Range (min … max):     9.8 ms …  11.1 ms    228 runs
                                                                                                                                                                                                                                  
ε ➪ hyperfine --warmup 3 "/Users/ian/.pixi/envs/python/bin/python -c 'print(\"Python Hello\")'"
Benchmark 1: /Users/ian/.pixi/envs/python/bin/python -c 'print("Python Hello")'
  Time (mean ± σ):       8.2 ms ±   0.2 ms    [User: 6.6 ms, System: 1.2 ms]
  Range (min … max):     7.8 ms …   8.7 ms    274 runs

Expected behavior

Ruby should be the same speed no matter where it is run from...

@Hofer-Julian Hofer-Julian added the ⏩ performance An issue related to performance label Oct 23, 2024
@wolfv
Copy link
Member

wolfv commented Oct 23, 2024

Awesome, thank you for the benchmark! We are actually currently working on a slightly adjusted way of launching the executables. The new way caches the activation variables and so it should be faster. This will be helpful.

cc @nichmor maybe you can run this locally?

@iandol
Copy link
Author

iandol commented Oct 23, 2024

It does seem this might just be lots of conda cruft:

ε ➪ cat .pixi/bin/ruby
   1 #!/bin/sh
   2 export PATH="/Users/ian/.pixi/envs/ruby/bin:${PATH}"
   3 export CONDA_PREFIX="/Users/ian/.pixi/envs/ruby"
   4 . "/Users/ian/.pixi/envs/ruby/etc/conda/activate.d/activate-gfortran_osx-arm64.sh"
   5 . "/Users/ian/.pixi/envs/ruby/etc/conda/activate.d/activate_clang_osx-arm64.sh"
   6 . "/Users/ian/.pixi/envs/ruby/etc/conda/activate.d/activate_clangxx_osx-arm64.sh"
   7 . "/Users/ian/.pixi/envs/ruby/etc/conda/activate.d/libxml2_activate.sh"
   8 . "/Users/ian/.pixi/envs/ruby/etc/conda/activate.d/ruby_activate.sh"
   9 "/Users/ian/.pixi/envs/ruby/bin/ruby" "$@"

If I comment out lines 4-7 then ruby takes ~33ms, much better!

ε ◎ hyperfine --warmup 3 "/Users/ian/.pixi/bin/ruby -e 'puts \"Ruby Hello\"'"
Benchmark 1: /Users/ian/.pixi/bin/ruby -e 'puts "Ruby Hello"'
  Time (mean ± σ):      33.1 ms ±   0.4 ms    [User: 26.1 ms, System: 5.9 ms]
  Range (min … max):    31.8 ms …  34.0 ms    84 runs

@nichmor
Copy link
Contributor

nichmor commented Oct 23, 2024

Benchmarks results using new way of launching executables:

hyperfine --warmup 3 "/Users/graf/.pixi/bin/ruby -e 'puts \"Ruby Hello\"'"
Benchmark 1: /Users/graf/.pixi/bin/ruby -e 'puts "Ruby Hello"'
  Time (mean ± σ):      33.2 ms ±   0.7 ms    [User: 26.3 ms, System: 5.8 ms]
  Range (min … max):    31.9 ms …  34.6 ms    85 runs

hyperfine --warmup 3 "/Users/graf/.pixi/envs/ruby/bin/ruby -e 'puts \"Ruby Hello\"'"
Benchmark 1: /Users/graf/.pixi/envs/ruby/bin/ruby -e 'puts "Ruby Hello"'
  Time (mean ± σ):      32.0 ms ±   0.8 ms    [User: 25.7 ms, System: 5.3 ms]
  Range (min … max):    30.5 ms …  34.4 ms    84 runs

I think by switching to the new way of launching them we will avoid this slow problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏩ performance An issue related to performance
Projects
None yet
Development

No branches or pull requests

4 participants