Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Why to not use hub with RubyGems
# No RubyGems
$ time hub version
git version 1.6.0
hub version 0.2.0
real 0m0.047s
user 0m0.015s
sys 0m0.028s
# With RubyGems
$ time hub version
git version 1.6.0
hub version 0.2.0
real 0m0.438s
user 0m0.352s
sys 0m0.089s
# If you have the current git branch in your bash prompt,
# you're going to notice the extra half second before it
# renders.
@sunaku

This comment has been minimized.

Show comment
Hide comment
@sunaku

sunaku Apr 3, 2010

This patch on the RubyGems issue tracker tries to speed things up:
http://rubyforge.org/tracker/index.php?func=detail&aid=28050&group_id=126&atid=577

sunaku commented Apr 3, 2010

This patch on the RubyGems issue tracker tries to speed things up:
http://rubyforge.org/tracker/index.php?func=detail&aid=28050&group_id=126&atid=577

@chastell

This comment has been minimized.

Show comment
Hide comment
@chastell

chastell Dec 1, 2011

$ time hub version
git version 1.7.7.2
hub version 1.7.0

real  0m0.085s
user  0m0.060s
sys   0m0.016s

$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ which hub
/home/chastell/.rvm/gems/ruby-1.9.3-p0@global/bin/hub

chastell commented Dec 1, 2011

$ time hub version
git version 1.7.7.2
hub version 1.7.0

real  0m0.085s
user  0m0.060s
sys   0m0.016s

$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ which hub
/home/chastell/.rvm/gems/ruby-1.9.3-p0@global/bin/hub
@minhajuddin

This comment has been minimized.

Show comment
Hide comment
@minhajuddin

minhajuddin Dec 9, 2011

@chastell How did reduce the startup time? can you show us your output of cat $(type -P hub)

minhajuddin commented Dec 9, 2011

@chastell How did reduce the startup time? can you show us your output of cat $(type -P hub)

@chastell

This comment has been minimized.

Show comment
Hide comment
@chastell

chastell Dec 9, 2011

$ cat $(type -P hub)
#!/home/chastell/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'hub' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'hub', version
load Gem.bin_path('hub', 'hub', version)

Note that I have only 14 gems in my global gemset, so the require 'rubygems' call is cheap. Also note that it’s Ruby 1.9.3, which much faster require handling in general.

chastell commented Dec 9, 2011

$ cat $(type -P hub)
#!/home/chastell/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'hub' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'hub', version
load Gem.bin_path('hub', 'hub', version)

Note that I have only 14 gems in my global gemset, so the require 'rubygems' call is cheap. Also note that it’s Ruby 1.9.3, which much faster require handling in general.

@minhajuddin

This comment has been minimized.

Show comment
Hide comment
@minhajuddin

minhajuddin Dec 10, 2011

@chastell Thanks for the info, I didn't know the number of gems slowed down the load time, good to know that ruby 1.9.3 has some fixes.

minhajuddin commented Dec 10, 2011

@chastell Thanks for the info, I didn't know the number of gems slowed down the load time, good to know that ruby 1.9.3 has some fixes.

@gutenye

This comment has been minimized.

Show comment
Hide comment
@gutenye

gutenye Dec 14, 2011

it's still slow.

# No Rubygems
$ time hub version
> 0.03s user 0.01s system 49% cpu 0.093 total 

# With Rubygems
$ time hub version
> 0.21s user 0.01s system 95% cpu 0.229 total

$ ruby --version
> ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ gem --version
> 1.8.11

$ gem list | wc -l
> 356

tested in ArchLinux with SSD.

gutenye commented Dec 14, 2011

it's still slow.

# No Rubygems
$ time hub version
> 0.03s user 0.01s system 49% cpu 0.093 total 

# With Rubygems
$ time hub version
> 0.21s user 0.01s system 95% cpu 0.229 total

$ ruby --version
> ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ gem --version
> 1.8.11

$ gem list | wc -l
> 356

tested in ArchLinux with SSD.

@elgalu

This comment has been minimized.

Show comment
Hide comment
@elgalu

elgalu Mar 14, 2013

Personal Conclusion

Standalone version 3 times faster than rubygems equivalent.

Environment

sisop ubuntu 12.04 in a virtual machine
ruby version 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
gem version 2.0.2
git version 1.7.9.5
hub version 1.10.5

Tests

# No Rubygems
time hub version
#=> real 0m0.096s  user 0m0.060s  sys 0m0.016s

# With Rubygems
time hub version
#=> real 0m0.266s  user 0m0.208s  sys 0m0.008s

elgalu commented Mar 14, 2013

Personal Conclusion

Standalone version 3 times faster than rubygems equivalent.

Environment

sisop ubuntu 12.04 in a virtual machine
ruby version 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
gem version 2.0.2
git version 1.7.9.5
hub version 1.10.5

Tests

# No Rubygems
time hub version
#=> real 0m0.096s  user 0m0.060s  sys 0m0.016s

# With Rubygems
time hub version
#=> real 0m0.266s  user 0m0.208s  sys 0m0.008s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment