Patches item #28050, was opened at 2010-04-03 09:08
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=577&aid=28050&group_id=126
Category: `gem install`
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Suraj Kurapati (snk)
Assigned to: Nobody (None)
Summary: speed up proxy executables in Ruby 1.9
Initial Comment:
Hello,
I am using RubyGems 1.3.6 with Ruby 1.9.1p378.
I consistently observe a huge time overhead when running proxy
executables (installed by RubyGems in /usr/bin/) in comparison to
directly running the underlying executables provided by gems in
their bin/ directory.
The attached tarball serves to demonstrate this observation:
# tar zxf rubygems-fast-proxy-executable.tgz
# cd rubygems-fast-proxy-executable/
# tree -F
.
├── bin/
│ └── foobarbaz*
└── foobarbaz.gemspec
1 directory, 2 files
# cat bin/foobarbaz
#!/usr/bin/env ruby
puts __FILE__
# cat foobarbaz.gemspec
spec = Gem::Specification.new do |s|
s.name = 'foobarbaz'
s.version = '0.0.0'
s.summary = 'make rubygems proxy executables fast!'
s.executables = s.name
s.files = "bin/#{s.name}"
end
# gem build foobarbaz.gemspec
WARNING: no author specified
WARNING: no description specified
WARNING: no email specified
WARNING: no homepage specified
WARNING: no rubyforge_project specified
Successfully built RubyGem
Name: foobarbaz
Version: 0.0.0
File: foobarbaz-0.0.0.gem
# sudo gem install foobarbaz-0.0.0.gem
Successfully installed foobarbaz-0.0.0
1 gem installed
# which foobarbaz
/usr/bin/foobarbaz
# time foobarbaz
/usr/lib/ruby/gems/1.9.1/gems/foobarbaz-0.0.0/bin/foobarbaz
real 0m1.926s
user 0m1.730s
sys 0m0.180s
# time ./bin/foobarbaz
./bin/foobarbaz
real 0m0.050s
user 0m0.043s
sys 0m0.007s
In Ruby 1.9, the $LOAD_PATH is already pre-seeded with the bin/ and
lib/ directories of all gems installed in the environment, so the
proxy executable (such as /usr/bin/foobarbaz) could be reduced to
the following:
#!/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'foobarbaz' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = []
if ARGV.first =~ /^_(.+)_$/ and Gem::Version.correct? $1 then
version << $1
ARGV.shift
end
if RUBY_VERSION < '1.9' or not version.empty? then
gem 'foobarbaz', *version
end
load 'foobarbaz'
After making this change, the runtime overhead of the RubyGems
proxy executable is greatly reduced:
# time foobarbaz
/usr/lib/ruby/gems/1.9.1/gems/foobarbaz-0.0.0/bin/foobarbaz
real 0m0.054s
user 0m0.043s
sys 0m0.010s
However, I do not observe any improvement (or degradation) in
performance after trying these changes in Ruby 1.8:
# time ~/.multiruby/install/1.8.6-p383/bin/foobarbaz
/home/sun/.multiruby/install/1.8.6-p383/lib/ruby/gems/1.8/gems/foobarbaz-0.0.0/bin/foobarbaz
real 0m0.157s
user 0m0.130s
sys 0m0.027s
Since this change does not negatively affect Ruby 1.8, I say let's
do it and make RubyGems proxy executables *super fast* in Ruby 1.9!
Thanks for your consideration.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=577&aid=28050&group_id=126
_______________________________________________
Rubygems-developers mailing list
http://rubyforge.org/projects/rubygems
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers