fastup 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 187041c365e33a8fb054fcbe1abec1dccf3b75e7
4
- data.tar.gz: 9a8915b07b587b342f586f472c8abab0054d73ae
2
+ SHA256:
3
+ metadata.gz: eff7fb62d73261c1f323338c749f82791546ab1b74de3d257e2254f7d19485ef
4
+ data.tar.gz: fc7578d69d7c3da331cd4515da1f25344b9d30597e744aab26802ec929822e66
5
5
  SHA512:
6
- metadata.gz: 6c36d9f60a561d1c701bee9c97658cfcf45babf0fd3bcd32226ddf0180c41ddc5d7a97868676c9068b4edf51fbf53da1369ac1bd2a064cbf1a5bc55d66e39ffd
7
- data.tar.gz: 12b04e54a23dab14c32e26b84a5c7570e7764885430d01ab6979cf6f0a8d399baf89cb795fd9da1d80cb34a1d17f792fd9caca143417da35f56421bc6727c55d
6
+ metadata.gz: 3b320c6cfb22ae4c3e9c8cbd3a55d7c009a3503b4b6bd0e090205c5578ffe4564194047bd6e2336e2759431840d3c45cc7c20320bc92bdfe768872e7ae8d94c1
7
+ data.tar.gz: 07a1a6f7e9fcc4694a60b9770842bf33e7e8e64fd7b3dd1916c61f8bba4ff2366c78f05875063e118b8dc7e5c6c42a032f2a22027369fe08bac96f622d0baaac
data/README.md CHANGED
@@ -4,33 +4,19 @@ Fastup builds an index from `$LOAD_PATH` and patches `require` to use
4
4
  that index to significantly speed up booting up large Rails apps with
5
5
  many dependencies.
6
6
 
7
- ```
8
- $ bundle show | wc -l
9
- 375
10
-
11
- ### before fastup
12
-
13
- $ time echo 'puts "loaded #{$LOADED_FEATURES.size} features"' | bundle exec rails c
14
- loaded 5095 features
15
-
16
- real 0m23.652s
17
- user 0m14.300s
18
- sys 0m9.237s
7
+ When `require 'code'` is called, Ruby searches each element of
8
+ `$LOAD_PATH`, attempting to load `code.rb` from each directory in
9
+ `$LOAD_PATH`. Watching the output of `strace` while starting a Ruby
10
+ program reveals a large number of failed attempts to open non-existent
11
+ files, until the correct path is found. The index built by `fastup`
12
+ allows skipping many of these failed attempts.
19
13
 
20
- ### with fastup enabled
14
+ The speedup is most noticeable in applications with many
15
+ dependencies. With few dependencies, the overhead of `fastup` will
16
+ cause a small slowdown. Test the speedup first, to see if `fastup` is
17
+ worth it or not for any particular application.
21
18
 
22
- $ time echo 'puts "loaded #{$LOADED_FEATURES.size} features"' | bundle exec rails c
23
- loaded 5097 features
24
-
25
- real 0m15.142s
26
- user 0m11.005s
27
- sys 0m4.058s
28
- ```
29
-
30
- With fewer dependencies, the speedup is smaller. At some point, the
31
- overhead of building the index means `fastup` will cause a small
32
- slowdown. Test the speedup first, to see if `fastup` is worth it or
33
- not for any particular application.
19
+ ![plot](plot.png)
34
20
 
35
21
  ## Usage
36
22
 
@@ -41,7 +27,7 @@ populated with all dependencies and before most of them have been
41
27
 
42
28
  For example in `config/boot.rb` of a Rails app:
43
29
 
44
- ```
30
+ ```ruby
45
31
  require 'rubygems'
46
32
 
47
33
  # Set up gems listed in the Gemfile.
data/lib/fastup.rb CHANGED
@@ -27,7 +27,9 @@ module Fastup
27
27
  ret
28
28
  end
29
29
  end
30
- Object.prepend mod
30
+
31
+ Object.prepend mod # normal "require 'somegem'" invokes this
32
+ Kernel.singleton_class.prepend mod # explicit "Kernel.require 'somegem'"
31
33
  end
32
34
 
33
35
  module XFile
data/test/fastup_test.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  require 'benchmark'
2
2
  require 'tmpdir'
3
3
 
4
- require 'minitest/autorun'
5
-
6
- require 'fastup'
4
+ require 'test_helper'
7
5
 
8
6
  module Fastup
9
7
  class TestAppBoot < Minitest::Test
8
+ tag :slow
10
9
  def test_app_boot
11
10
  results = {}
12
11
 
@@ -18,12 +17,12 @@ module Fastup
18
17
  results[:total_fastup] = Benchmark.measure {
19
18
  out = `USE_FASTUP=1 bundle exec ruby boot.rb 2>/dev/null`
20
19
  raise "fastup exited with error: #{out}" unless $?.success?
21
- results[:output_fastup] = out.lines.reject{ |p| p =~ %r{fastup/lib/fastup} }
20
+ results[:output_fastup] = out.lines.reject{ |p| p =~ %r{/lib/fastup} }
22
21
  }
23
22
  results[:total_nofastup] = Benchmark.measure {
24
23
  out = `bundle exec ruby boot.rb`
25
24
  raise "nofastup exited with error: #{out}" unless $?.success?
26
- results[:output_nofastup] = out.lines.reject{ |p| p =~ %r{fastup/lib/fastup} }
25
+ results[:output_nofastup] = out.lines.reject{ |p| p =~ %r{/lib/fastup} }
27
26
  }
28
27
  end
29
28
  end
@@ -31,7 +30,7 @@ module Fastup
31
30
  results[:output_fastup].reject!{ |p| p =~ %r{fastup/lib/fastup} }
32
31
  results[:output_nofastup].reject!{ |p| p =~ %r{fastup/lib/fastup} }
33
32
 
34
- # warn("\nfastup: %.2f nofastup: %.2f" % [results[:total_fastup].total, results[:total_nofastup].total])
33
+ warn("\nfastup: %.2f nofastup: %.2f" % [results[:total_fastup].total, results[:total_nofastup].total])
35
34
 
36
35
  assert results[:total_fastup].total < results[:total_nofastup].total,
37
36
  "expected fastup (#{results[:total_fastup]}) to be faster than without (#{results[:total_nofastup]})"
@@ -0,0 +1,6 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/tagz'
3
+ Minitest::Tagz.choose_tags(*ENV['TAGS'].split(',')) if ENV['TAGS']
4
+
5
+ require 'fastup'
6
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Mahoney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-16 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-tagz
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +95,7 @@ files:
81
95
  - lib/fastup/autoapply.rb
82
96
  - test/app/boot.rb
83
97
  - test/fastup_test.rb
98
+ - test/test_helper.rb
84
99
  homepage: https://github.com/raisemarketplace/fastup
85
100
  licenses:
86
101
  - MIT
@@ -101,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
116
  version: '0'
102
117
  requirements: []
103
118
  rubyforge_project:
104
- rubygems_version: 2.6.13
119
+ rubygems_version: 2.7.6
105
120
  signing_key:
106
121
  specification_version: 4
107
122
  summary: index load path to accelerate boot