faster_rubygems 0.9.2 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,3 +1,5 @@
1
+ = Faster Rubygems =
2
+
1
3
  A helper gem to dramatically speedup the time it takes to startup a ruby script.
2
4
 
3
5
  i.e. it makes it so that requiring rubygems no longer takes as long.
@@ -7,18 +9,18 @@ Speed difference (a demo gem script, ruby 1.8 windows mingw):
7
9
  normal rubygems:
8
10
 
9
11
  $ timer ruby whichr
10
- 0.83
12
+ 0.83s
11
13
 
12
14
  with faster_rubygems:
13
15
 
14
16
  $ timer ruby whichr
15
- 0.19
17
+ 0.19s
16
18
 
17
19
  Yea!
18
20
 
19
- It acts as a beefed up version of gem_prelude (prelude is 1.9 only currently), but only adds load paths on demand.
21
+ It acts like a beefed up version of gem_prelude (prelude is 1.9 only currently), with a bit more cacheing thrown in there.
20
22
 
21
- It makes even more of a difference when used with 1.9:
23
+ It makes even more of a difference when used with 1.9 on windows:
22
24
 
23
25
  normal rubygems:
24
26
 
@@ -34,33 +36,46 @@ with faster_rubygems:
34
36
 
35
37
  $ gem install faster_rubygems
36
38
 
39
+ now there is a manual step that must be followed:
40
+
37
41
  1.9
38
- :
39
- $ export RUBYOPT=-rfaster_rubygems --disable-gems
42
+
43
+ Set this environment variable:
44
+ RUBYOPT=-rfaster_rubygems --disable-gems
40
45
 
41
46
  1.8:
47
+ Installs itself by default.
48
+
49
+
50
+ Note that full rubygems will still be loaded when necessary (for example when installing new gems). This is automatic.
51
+
42
52
 
43
- you currently have to install to override normal rubygems by doing the following (in an irb session):
53
+ == Rails ==
44
54
 
45
- >> require 'rubygems'
46
- >> require 'faster_rubygems/override' # installs faster_rubygems to be use in place of normal rubygems when you do a "require 'rubygems'" so you don't have to worry about anything
55
+ Unfortunately this gem does not greatly speed up rails--it speeds up any script that
56
+ doesn't require full rubygems (which is most, but not rails).
47
57
 
48
- # later, to revert this override, back to normal rubygems, should you so desire, do the following:
49
- >> require 'rubygems'
50
- >> require 'faster_rubygems/unoverride'
58
+ If you want to speed up rails, you'll want to use the faster_require gem
59
+ (though they do work together splendidly). http://github.com/rdp/faster_require
60
+
61
+ See http://github.com/rdp/faster_rubygems/blob/master/benchmarks.txt for a full breakdown and more benchmarks.
62
+
63
+ == Trouble Shooting ==
64
+
65
+ # if you wish to revert back to normal rubygems, do the following:
66
+ >> require 'rubygems'
67
+ >> require 'faster_rubygems/unoverride'
51
68
 
52
- If all else fails in this process (it has typically worked fine), you can
53
- reinstall normal rubygems by downloading its package (.tgz) and running ruby setup.rb within it.
69
+ If all else fails in this process (it has typically worked fine), you can
70
+ reinstall normal rubygems by downloading its package (.tgz) and running ruby setup.rb within it.
54
71
 
55
- After installation, usage is automatic.
56
72
 
73
+ To regenerate cache files (should never really be necessary, but if you for some reason think yours are stale) do the following:
57
74
 
58
- To regenerate cache files (should never be necessary, but if you for some reason think yours are stale) do
59
75
  >> require 'rubygems'
60
76
  >> require 'faster_rubygems/create_cache_for_all'
61
77
 
62
- Note that it still loads full rubygems when it necessary (like when installing gems). This is also automatic.
63
- Most of the credit for this goes to gem prelude.
78
+ Most of the credit for this gem goes to gem prelude.
64
79
 
65
80
  == Related projects ==
66
81
 
@@ -72,4 +87,4 @@ the Builder gem
72
87
 
73
88
  Source/feedback:
74
89
 
75
- http://www.github.com/rdp/faster_rubygems
90
+ http://www.github.com/rdp/faster_rubygems
data/Rakefile CHANGED
@@ -7,13 +7,22 @@ require 'jeweler'
7
7
 
8
8
  s.post_install_message = "
9
9
 
10
- faster_rubygems installed! see the readme for post-install instructions: http://github.com/rdp/faster_rubygems
10
+ faster_rubygems installed into your site_ruby directory.
11
+
12
+ If you're on 1.9 please set your RUBYOPT env. variable thus, to use it:
13
+
14
+ $ export RUBYOPT=--disable-gems -rfaster_rubygems
15
+
16
+ or (windows)
17
+
18
+ C:\>set RUBYOPT=--disable-gems -rfaster_rubygems
11
19
 
12
20
  "
13
21
  s.add_development_dependency 'test-unit', '=1.2.3'
14
22
  s.add_development_dependency 'test-unit', '=2.0.6'
15
23
  s.add_development_dependency 'after', '=0.7.0'
16
24
  s.add_development_dependency 'sane'
25
+ s.add_development_dependency 'rspec', '>=2.0.0'
17
26
  # s.add_dependency 'faster_require'
18
27
 
19
28
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.11.1
data/benchmarks.txt CHANGED
@@ -1,4 +1,8 @@
1
- whichr whichr benchmarks (best time seen):
1
+ Benchmarks against normal rubygems and gem_prelude in 1.9 (its normal)
2
+
3
+
4
+
5
+ benchmarks runing [$ whichr whichr] (the whichr gem just behaves like the "which" command in Linux), best time seen:
2
6
 
3
7
  mingw 1.8
4
8
 
@@ -22,50 +26,69 @@ mingw 1.9
22
26
  faster_rubygems without cache:
23
27
  0.50
24
28
 
25
- jruby, faster_rubygems with "full load path"
29
+ jruby, 1.8 mode
26
30
 
27
- faster_rubygems without cache:
31
+ normal rubygems:
32
+ 2.31
33
+
34
+ faster_rubygems without cache (deleted the cache file temporarily to force it to not use it):
28
35
  1.15
29
36
 
30
37
  faster_rubygems with cache:
31
38
  1.11
32
39
 
33
- normal rubygems:
34
- 2.31
35
-
36
40
 
37
-
38
- rails 3 [ $ ruby script\rails runner -e production "puts 3" ]
41
+ rails 2.3.8 [ $ ruby script\runner -e production "puts 3" ]
42
+ Unfortunately rails requires a load of full rubygems. So currently faster_rubygems doesn't help it much.
39
43
 
40
- unfortunately with rails 3 currently it loads "full rubygems" no matter what, which is the thing we were trying to avoid.
44
+ faster_require (other gem) seems to help, however.
41
45
 
42
46
  1.9
43
- faster_rubygems with cache[RUBYOPT=-rfaster_rubygems --disable-gems]:
44
- 11.26
47
+ normal gem_prelude[RUBYOPT=]
48
+ 20.85
49
+
50
+ faster_rubygems without cache [RUBYOPT=-rfaster_rubygems]
51
+ 20.7
52
+
53
+ faster_rubygems with cache [RUBYOPT=-rfaster_rubygems --disable-gems]:
54
+ 12.10
45
55
 
46
- faster_rubygems without cache [RUBYOPT=-rfaster_rubygems]:
47
- 13.73
56
+ normal gem_prelude, with faster_require gem [RUBYOPT=-rfaster_require]:
57
+ 8.93
48
58
 
49
- normal rubygems (with gem prelude [straight ruby]):
50
- 13.88
59
+ faster_rubygems, without cache, with faster_require [RUBYOPT=-rfaster_rubygems -rfaster_require]:
60
+ 8.99
51
61
 
52
- normal rubygems (ruby --disable-gems):
53
- 10.41
54
-
55
- rails 2.3.8 [ $ ruby script\runner -e production "puts 3" ]
62
+ * recommend this configuration for ruby 1.9 and rails.
56
63
 
57
- 1.9
58
- faster_rubygems with cache[RUBYOPT=-rfaster_rubygems --disable-gems]:
59
- 12.4
64
+ faster_rubygems, with cache [RUBYOPT=--disable-gems -rfaster_rubygems -rfaster_require]
65
+ fail (gotta fix that, then will probably be fastest option)
66
+
67
+ 1.8
68
+
69
+ normal rubygems:
70
+ 6.54
71
+
72
+ faster_rubygems without cache:
73
+ 6.12
74
+
75
+ faster_rubygems with cache:
76
+ 6.48
77
+
78
+ normal rubygems, faster_require:
79
+ 3.53
80
+
81
+ faster_rubygems with cache and with faster_require (have to use it as require 'faster_require')
82
+ 2.97
60
83
 
84
+ * recommend this configuration, which means you'll have to add a require 'faster_require' to your rails script at the beginning, like in boot.rb
61
85
 
86
+ faster_rubygems without cache and with faster_require
87
+ 3.31
62
88
 
63
89
 
64
- lacking:
65
- rails benchmarks, faster_require for everybody...
66
-
67
90
  TODO:
68
- jruby spawning itself was *so slow* it seemed (timer.rb)
69
-
70
- only regenerate appropriate cache files after gem installs...
71
- only cache lib filenames, not spec files, et al...
91
+ jruby spawning itself was *so slow* it seemed (timer.rb)
92
+ only regenerate appropriate cache files after gem installs...I guess.
93
+ only cache lib filenames, not spec files, et al...
94
+ chmod after create (check if necessary first)
data/ext/mkrf_conf.rb CHANGED
@@ -8,6 +8,18 @@ load File.expand_path(File.dirname(__FILE__)) + "/../internalize.rb" # install t
8
8
 
9
9
  require File.dirname(__FILE__) + "/../lib/faster_rubygems/create_cache_for_all.rb"
10
10
 
11
+
12
+ if RUBY_VERSION[0..2] == '1.8'
13
+ begin
14
+ require File.dirname(__FILE__) + "/../lib/faster_rubygems/override.rb" # install it by default...
15
+ rescue RuntimeError => e
16
+ # swallow if it's a double install...for now...
17
+ raise e unless e.to_s =~ /cannot install twice/
18
+ end
19
+
20
+ end
21
+
22
+
11
23
  f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
12
24
  f.write("task :default\n")
13
25
  f.close
@@ -200,12 +200,12 @@ if defined?(Gem) then
200
200
  GemsActivated = {}
201
201
  def push_gem_version_on_load_path(gem_name, *version_requirements)
202
202
  if version_requirements.empty?
203
- unless path = GemPaths[(gem_name)] then
203
+ unless path = GemPaths[gem_name] then
204
204
  puts "Could not find RubyGem #{gem_name} (>= 0)\n" if $VERBOSE || $DEBUG
205
205
  raise Gem::LoadError, "Could not find RubyGem #{gem_name} (>= 0)\n"
206
206
  end
207
207
  # highest version gems *not* already active
208
- if !ALL_CACHES.empty?
208
+ if !AllCaches.empty?
209
209
  # then we are using the caches, and the stuff isn't preloaded yet
210
210
  # copied and pasted...
211
211
  require_paths = []
@@ -256,7 +256,7 @@ if defined?(Gem) then
256
256
 
257
257
  if loaded_version = GemVersions[gem_name] then
258
258
  case requirement
259
- when ">", ">=" then
259
+ when ">", ">=", '=' then
260
260
  return false if
261
261
  (loaded_version <=> Gem.integers_for(version)) >= 0
262
262
  when "~>" then
@@ -345,7 +345,7 @@ if defined?(Gem) then
345
345
  end
346
346
 
347
347
  # if the gem dir doesn't exist, don't count it against us
348
- ALL_CACHES = Gem.path.select{|path| File.exist?(path)}.map{|path|
348
+ AllCaches = Gem.path.select{|path| File.exist?(path)}.map{|path|
349
349
  cache_name = path + '/.faster_rubygems_cache'
350
350
  if File.exist?(cache_name)
351
351
  File.open(cache_name, 'rb') do |f|
@@ -358,7 +358,7 @@ if defined?(Gem) then
358
358
  }
359
359
 
360
360
  # we will use a clear cache as an indication of "non success" loading caches
361
- ALL_CACHES.clear if ALL_CACHES.index(nil)
361
+ AllCaches.clear if AllCaches.index(nil)
362
362
 
363
363
  end
364
364
 
@@ -368,8 +368,8 @@ if defined?(Gem) then
368
368
 
369
369
 
370
370
  begin
371
- if !Gem::QuickLoader::ALL_CACHES.empty?
372
- puts 'faster_rubygems using caches', Gem::QuickLoader::ALL_CACHES.map{|fn, contents| fn} if $VERBOSE
371
+ if !Gem::QuickLoader::AllCaches.empty?
372
+ puts 'faster_rubygems using caches', Gem::QuickLoader::AllCaches.map{|fn, contents| fn} if $VERBOSE
373
373
  Gem.calculate_all_highest_version_gems false
374
374
  # use cached load instead of loading lib paths into the load path here
375
375
  require File.expand_path(File.dirname(__FILE__)) + "/prelude_cached_load"
@@ -1,2 +1,3 @@
1
+ require 'rubygems' # in case it helps
1
2
  require File.dirname(__FILE__) + '/install_helper'
2
3
  FasterRubyGems.install_over_rubygems!
@@ -18,16 +18,16 @@ module Gem
18
18
  def push_all_gems_that_might_match_and_reload_files lib, error
19
19
  sub_lib = lib.gsub("\\", '/').split('/')[-1].split('.')[0]
20
20
  success = false
21
- raise if ALL_CACHES.empty? # should never be empty...
22
- ALL_CACHES.each{|path, gem_list|
21
+ raise if AllCaches.empty? # should never be empty...
22
+ AllCaches.each{|path, gem_list|
23
23
  for gem_name, long_file_list in gem_list
24
- if idx = long_file_list.index(sub_lib)
25
- puts 'activating' + gem_name + sub_lib.to_s if $DEBUG
24
+ if long_file_list[sub_lib.downcase]
25
+ puts 'activating' + gem_name + ' ' + sub_lib.to_s if $DEBUG
26
26
  if gem(gem_name)
27
- puts 'gem activated ' + gem_name + ' ' + sub_lib + ' ' + long_file_list[idx] if $VERBOSE || $DEBUG
27
+ puts 'gem activated ' + gem_name + ' ' + sub_lib if $VERBOSE || $DEBUG
28
28
  success = true
29
29
  end
30
- puts 'done activeating' + gem_name + sub_lib if $DEBUG
30
+ puts 'done activeating' + gem_name + ' ' + sub_lib if $DEBUG
31
31
  end
32
32
 
33
33
  end
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/prelude_bin_path" # Gem.integers_for, for 1.9
3
3
  module Gem
4
4
  module QuickLoader
5
5
  def create_cache gems_paths
6
- puts 'faster_rubygems: creating caches'
6
+ puts 'faster_rubygems: creating all caches'
7
7
  gems_paths.each do |path|
8
8
  gem_versions = {}
9
9
  gem_paths = {}
@@ -26,16 +26,23 @@ module Gem
26
26
  # strip out directories, and the gem-d.d.d prefix
27
27
  gem_paths.each{|k, v|
28
28
 
29
- gem_paths_with_contents[k] = Dir[v + '/**/*.{rb,so,bundle}'].select{|f|
29
+ files = Dir[v + '/**/*.{rb,so,bundle}'].select{|f|
30
30
  !File.directory? f
31
31
  }.map{ |full_name|
32
32
  full_name.sub(v + '/', '')
33
33
  full_name.split('/')[-1].split('.')[0] # just a of a.b.c.rb, for now
34
34
  }
35
+
36
+ hash_of_files = {}
37
+ files.each{|small_filename|
38
+ hash_of_files[small_filename] = true
39
+ }
40
+ gem_paths_with_contents[k] = hash_of_files
35
41
  }
36
42
 
37
43
  cache_path = path + '/.faster_rubygems_cache'
38
- puts '.'
44
+ print '.'
45
+ puts cache_path if $VERBOSE
39
46
  $stdout.flush
40
47
  # accomodate for those not running as sudo...
41
48
  if File.writable? path
@@ -1,2 +1,3 @@
1
+ require 'rubygems' # in case it helps
1
2
  require File.dirname(__FILE__) + '/install_helper'
2
3
  FasterRubyGems.uninstall_over_rubygems!
@@ -1,7 +1,14 @@
1
- Gem.post_install { |gem_installer_instance|
2
- require File.dirname(__FILE__) + "/faster_rubygems/create_cache_for_all"
1
+ Gem.post_install {
2
+ require "faster_rubygems/create_cache_for_all"
3
3
  }
4
4
 
5
5
  Gem.post_uninstall {
6
- require File.dirname(__FILE__) + "/faster_rubygems/create_cache_for_all"
6
+ require "faster_rubygems/create_cache_for_all"
7
+ }
8
+
9
+ Gem.pre_uninstall { |gem_installer_instance, gem_spec|
10
+
11
+ if gem_installer_instance.spec.name == 'faster_rubygems' && RUBY_VERSION[0..2] == '1.8'
12
+ require "faster_rubygems/unoverride" # just in case
13
+ end
7
14
  }
@@ -0,0 +1,3 @@
1
+ raise if ENV['RUBYOPT']
2
+ require File.dirname(__FILE__) + '/../../lib/faster_rubygems'
3
+ require 'rspec/expectations' # rspec 2 gem, unfortunately
@@ -1,8 +1,7 @@
1
1
  # to test in 1.8.x, make sure to use ruby specname.rb
2
2
  require File.dirname(__FILE__) + "/../lib/faster_rubygems"
3
3
  require 'sane'
4
- require 'spec' # rspec 1
5
- require 'spec/autorun'
4
+ require 'rspec' # rspec 2
6
5
  require 'fileutils'
7
6
  raise if ENV['RUBYOPT']
8
7
 
@@ -1,8 +1,7 @@
1
1
  require File.dirname(__FILE__) + "/../lib/faster_rubygems"
2
2
  require File.dirname(__FILE__) + "/../lib/faster_rubygems/prelude_create_cache"
3
3
  require 'sane'
4
- require 'spec' # rspec 1
5
- require 'spec/autorun'
4
+ require 'rspec' # rspec 2
6
5
  require 'fileutils'
7
6
  raise if ENV['RUBYOPT'] # avoid silly testing conflicts
8
7
  require 'rbconfig'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faster_rubygems
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 49
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
8
+ - 11
9
+ - 1
10
+ version: 0.11.1
11
11
  platform: ruby
12
12
  authors: []
13
13
 
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-24 00:00:00 -06:00
18
+ date: 2010-06-29 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,22 @@ dependencies:
80
80
  version: "0"
81
81
  type: :development
82
82
  version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 15
92
+ segments:
93
+ - 2
94
+ - 0
95
+ - 0
96
+ version: 2.0.0
97
+ type: :development
98
+ version_requirements: *id005
83
99
  description:
84
100
  email:
85
101
  executables: []
@@ -107,15 +123,13 @@ files:
107
123
  - lib/faster_rubygems/prelude_cached_load.rb
108
124
  - lib/faster_rubygems/prelude_create_cache.rb
109
125
  - lib/faster_rubygems/unoverride.rb
110
- - lib/faster_rubygems_with_faster_require_too.rb
111
126
  - lib/rubygems_plugin.rb
112
127
  - spec/files/test_gem.rb
113
128
  - spec/files/test_gem_const.rb
114
129
  - spec/files/test_gem_func.rb
115
- - spec/spec.can_create_cache_file.rb
130
+ - spec/files/test_load_sub.rb
116
131
  - spec/spec.faster_rubygems.rb
117
- - things_prelude_needs.txt
118
- - spec/reload.rb
132
+ - spec/spec.uses_cache_files.rb
119
133
  has_rdoc: true
120
134
  homepage:
121
135
  licenses: []
@@ -123,7 +137,15 @@ licenses: []
123
137
  post_install_message: |+
124
138
 
125
139
 
126
- faster_rubygems installed! see the readme for post-install instructions: http://github.com/rdp/faster_rubygems
140
+ faster_rubygems installed into your site_ruby directory.
141
+
142
+ If you're on 1.9 please set your RUBYOPT env. variable thus, to use it:
143
+
144
+ $ export RUBYOPT=--disable-gems -rfaster_rubygems
145
+
146
+ or (windows)
147
+
148
+ C:>set RUBYOPT=--disable-gems -rfaster_rubygems
127
149
 
128
150
  rdoc_options:
129
151
  - --charset=UTF-8
@@ -158,6 +180,6 @@ test_files:
158
180
  - spec/files/test_gem.rb
159
181
  - spec/files/test_gem_const.rb
160
182
  - spec/files/test_gem_func.rb
161
- - spec/reload.rb
162
- - spec/spec.can_create_cache_file.rb
183
+ - spec/files/test_load_sub.rb
163
184
  - spec/spec.faster_rubygems.rb
185
+ - spec/spec.uses_cache_files.rb
@@ -1,2 +0,0 @@
1
- require 'faster_rubygems'
2
- require 'faster_require'
data/spec/reload.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'benchmark'
2
- puts Benchmark.realtime {
3
- puts Marshal.load File.open("c:/ruby19/lib/ruby/gems/1.9.1/.faster_rubygems_cache", "rb")
4
- }
@@ -1,2 +0,0 @@
1
- handle gem 'rails', '2.3.8'
2
- it uses find instead of index for $: