bootscale 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -1
- data/lib/bootscale/file_storage.rb +2 -1
- data/lib/bootscale/utils.rb +30 -0
- data/lib/bootscale/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f9aae3eeb86052322d2ae6b745e8c0f0385e2d4
|
4
|
+
data.tar.gz: 0bbe7af30e7de21a6641771d8571d3f63efb9e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a54144b441ef4dd3a233a8d22ce838ff6a3a13d8204a5304bd614bbd2f88b3c415b0ab62f62281e48df3a396ad2470a594387f9312997d5d6748b2d2dce5388
|
7
|
+
data.tar.gz: 72699fc3cf785bfa26ba3b25917978ec4f109a3b71260f92320d9b6db6f419f378e0550592f3473a5d901c7231cebfa868f0cb259285db87df892852b68336b0
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Bootscale
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/byroot/bootscale.svg)](http://travis-ci.org/byroot/bootscale)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/bootscale.png)](http://badge.fury.io/rb/byroot/bootscale)
|
5
|
+
|
3
6
|
Speedup applications boot by caching file locations during require calls.
|
4
7
|
|
5
8
|
Speed gain depends on your number of gems. Under 100 gems you likely won't see the difference,
|
@@ -39,7 +42,20 @@ end
|
|
39
42
|
|
40
43
|
## Faster cache loading
|
41
44
|
|
42
|
-
|
45
|
+
In order to gain ~10-30ms of extra load speed, you can use the msgpack gem:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# Gemfile
|
49
|
+
gem 'msgpack', require: false
|
50
|
+
gem 'bootscale', require: false
|
51
|
+
```
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# config/application.rb (or wherever you have the require of bundler/setup)
|
55
|
+
require 'bundler/setup'
|
56
|
+
require 'msgpack'
|
57
|
+
require 'bootscale/setup'
|
58
|
+
```
|
43
59
|
|
44
60
|
## Under the hood
|
45
61
|
|
@@ -48,6 +64,10 @@ patches `require` + `autoload` to use these absolute paths, thereby avoiding hav
|
|
48
64
|
|
49
65
|
Problem outlined in this [talk](https://www.youtube.com/watch?v=kwkbrOwLsZY)
|
50
66
|
|
67
|
+
## Troubleshooting
|
68
|
+
|
69
|
+
If you're experiencing problems with loading your application and are unable to successfully run `Bootscale.regenerate`, try deleting the `tmp/bootscale` folder.
|
70
|
+
|
51
71
|
## Contributing
|
52
72
|
|
53
73
|
Bug reports and pull requests are welcome on GitHub at https://github.com/byroot/bootscale.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'digest/md5'
|
2
|
+
require_relative 'utils'
|
2
3
|
|
3
4
|
module Bootscale
|
4
5
|
class FileStorage
|
@@ -14,7 +15,7 @@ module Bootscale
|
|
14
15
|
def dump(load_path, cache)
|
15
16
|
path = cache_path(load_path)
|
16
17
|
FileUtils.mkdir_p(File.dirname(path))
|
17
|
-
|
18
|
+
Utils.atomic_write(path) { |f| f.write(Serializer.dump(cache)) }
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bootscale
|
2
|
+
module Utils
|
3
|
+
# Write to a file atomically. Useful for situations where you
|
4
|
+
# don't want other processes or threads to see half-written files.
|
5
|
+
#
|
6
|
+
# Utils.atomic_write('important.file') do |file|
|
7
|
+
# file.write('hello')
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# Returns nothing.
|
11
|
+
def self.atomic_write(filename)
|
12
|
+
dirname, basename = File.split(filename)
|
13
|
+
basename = [
|
14
|
+
basename,
|
15
|
+
Thread.current.object_id,
|
16
|
+
Process.pid,
|
17
|
+
rand(1000000)
|
18
|
+
].join('.'.freeze)
|
19
|
+
tmpname = File.join(dirname, basename)
|
20
|
+
|
21
|
+
File.open(tmpname, 'wb+') do |f|
|
22
|
+
yield f
|
23
|
+
end
|
24
|
+
|
25
|
+
File.rename(tmpname, filename)
|
26
|
+
ensure
|
27
|
+
File.delete(tmpname) if File.exist?(tmpname)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/bootscale/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootscale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inspired by Aaron Patterson's talk on the subject
|
14
14
|
email:
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/bootscale/entry.rb
|
26
26
|
- lib/bootscale/file_storage.rb
|
27
27
|
- lib/bootscale/setup.rb
|
28
|
+
- lib/bootscale/utils.rb
|
28
29
|
- lib/bootscale/version.rb
|
29
30
|
homepage: https://github.com/byroot/bootscale
|
30
31
|
licenses: []
|
@@ -45,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
46
|
version: '0'
|
46
47
|
requirements: []
|
47
48
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.
|
49
|
+
rubygems_version: 2.5.1
|
49
50
|
signing_key:
|
50
51
|
specification_version: 4
|
51
52
|
summary: Speedup applications boot by caching require calls
|