bootsnap 1.4.2 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/ext/bootsnap/bootsnap.c +32 -2
- data/lib/bootsnap/compile_cache.rb +1 -1
- data/lib/bootsnap/load_path_cache/store.rb +12 -9
- data/lib/bootsnap/setup.rb +4 -1
- data/lib/bootsnap/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be54a60d54f32f824d5c2fdccf189cdcb5409d1848c55f6e654fe44ace1d3f21
|
4
|
+
data.tar.gz: c6239c30984a936b76e218c2b1292a7e72d817d3e4847a6c58f0121c1e3068dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c251990457406cd51726eec8d62e0e1028bbeade6e24f266cb743d6f00f53650841beed9ee8e1795c78febd18ea234691125920c16aa5a95031718a28619bb31
|
7
|
+
data.tar.gz: 554a885bf2264f088618c41864fb84069d0664b35af0ae4b619c8fbb1cf285c80fad564d36845161f8044c35c6b53a33e66f27eb75c6715f25869af2795c97f6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 1.4.5
|
2
|
+
|
3
|
+
* MRI 2.7 support
|
4
|
+
* Fixed concurrency bugs
|
5
|
+
|
6
|
+
# 1.4.4
|
7
|
+
|
8
|
+
* Disable ISeq cache in `bootsnap/setup` by default in Ruby 2.5
|
9
|
+
|
10
|
+
# 1.4.3
|
11
|
+
|
12
|
+
* Fix some cache permissions and umask issues after switch to mkstemp
|
13
|
+
|
1
14
|
# 1.4.2
|
2
15
|
|
3
16
|
* Fix bug when removing features loaded by relative path from `$LOADED_FEATURES`
|
data/ext/bootsnap/bootsnap.c
CHANGED
@@ -74,6 +74,8 @@ static uint32_t current_ruby_platform;
|
|
74
74
|
static uint32_t current_ruby_revision;
|
75
75
|
/* Invalidates cache when RubyVM::InstructionSequence.compile_option changes */
|
76
76
|
static uint32_t current_compile_option_crc32 = 0;
|
77
|
+
/* Current umask */
|
78
|
+
static mode_t current_umask;
|
77
79
|
|
78
80
|
/* Bootsnap::CompileCache::{Native, Uncompilable} */
|
79
81
|
static VALUE rb_mBootsnap;
|
@@ -94,6 +96,7 @@ static int cache_key_equal(struct bs_cache_key * k1, struct bs_cache_key * k2);
|
|
94
96
|
static VALUE bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler);
|
95
97
|
static int open_current_file(char * path, struct bs_cache_key * key, char ** errno_provenance);
|
96
98
|
static int fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE * output_data, int * exception_tag, char ** errno_provenance);
|
99
|
+
static uint32_t get_ruby_revision(void);
|
97
100
|
static uint32_t get_ruby_platform(void);
|
98
101
|
|
99
102
|
/*
|
@@ -134,7 +137,7 @@ Init_bootsnap(void)
|
|
134
137
|
rb_mBootsnap_CompileCache_Native = rb_define_module_under(rb_mBootsnap_CompileCache, "Native");
|
135
138
|
rb_eBootsnap_CompileCache_Uncompilable = rb_define_class_under(rb_mBootsnap_CompileCache, "Uncompilable", rb_eStandardError);
|
136
139
|
|
137
|
-
current_ruby_revision =
|
140
|
+
current_ruby_revision = get_ruby_revision();
|
138
141
|
current_ruby_platform = get_ruby_platform();
|
139
142
|
|
140
143
|
uncompilable = rb_intern("__bootsnap_uncompilable__");
|
@@ -142,6 +145,9 @@ Init_bootsnap(void)
|
|
142
145
|
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "coverage_running?", bs_rb_coverage_running, 0);
|
143
146
|
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "fetch", bs_rb_fetch, 3);
|
144
147
|
rb_define_module_function(rb_mBootsnap_CompileCache_Native, "compile_option_crc32=", bs_compile_option_crc32_set, 1);
|
148
|
+
|
149
|
+
current_umask = umask(0777);
|
150
|
+
umask(current_umask);
|
145
151
|
}
|
146
152
|
|
147
153
|
/*
|
@@ -191,6 +197,26 @@ fnv1a_64(const char *str)
|
|
191
197
|
return fnv1a_64_iter(h, str);
|
192
198
|
}
|
193
199
|
|
200
|
+
/*
|
201
|
+
* Ruby's revision may be Integer or String. CRuby 2.7 or later uses
|
202
|
+
* Git commit ID as revision. It's String.
|
203
|
+
*/
|
204
|
+
static uint32_t
|
205
|
+
get_ruby_revision(void)
|
206
|
+
{
|
207
|
+
VALUE ruby_revision;
|
208
|
+
|
209
|
+
ruby_revision = rb_const_get(rb_cObject, rb_intern("RUBY_REVISION"));
|
210
|
+
if (RB_TYPE_P(ruby_revision, RUBY_T_FIXNUM)) {
|
211
|
+
return FIX2INT(ruby_revision);
|
212
|
+
} else {
|
213
|
+
uint64_t hash;
|
214
|
+
|
215
|
+
hash = fnv1a_64(StringValueCStr(ruby_revision));
|
216
|
+
return (uint32_t)(hash >> 32);
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
194
220
|
/*
|
195
221
|
* When ruby's version doesn't change, but it's recompiled on a different OS
|
196
222
|
* (or OS version), we need to invalidate the cache.
|
@@ -482,7 +508,6 @@ atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data, char
|
|
482
508
|
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:mkpath";
|
483
509
|
return -1;
|
484
510
|
}
|
485
|
-
close(fd);
|
486
511
|
fd = open(tmp_path, O_WRONLY | O_CREAT, 0664);
|
487
512
|
if (fd < 0) {
|
488
513
|
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:open";
|
@@ -517,6 +542,11 @@ atomic_write_cache_file(char * path, struct bs_cache_key * key, VALUE data, char
|
|
517
542
|
ret = rename(tmp_path, path);
|
518
543
|
if (ret < 0) {
|
519
544
|
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:rename";
|
545
|
+
return -1;
|
546
|
+
}
|
547
|
+
ret = chmod(path, 0664 & ~current_umask);
|
548
|
+
if (ret < 0) {
|
549
|
+
*errno_provenance = (char *)"bs_fetch:atomic_write_cache_file:chmod";
|
520
550
|
}
|
521
551
|
return ret;
|
522
552
|
}
|
@@ -28,7 +28,7 @@ module Bootsnap
|
|
28
28
|
raise(
|
29
29
|
PermissionError,
|
30
30
|
"bootsnap doesn't have permission to write cache entries in '#{cpath}' " \
|
31
|
-
"(or, less likely, doesn't have
|
31
|
+
"(or, less likely, doesn't have permission to read '#{path}')",
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
@@ -11,7 +11,8 @@ module Bootsnap
|
|
11
11
|
|
12
12
|
def initialize(store_path)
|
13
13
|
@store_path = store_path
|
14
|
-
|
14
|
+
# TODO: Remove conditional once Ruby 2.2 support is dropped.
|
15
|
+
@txn_mutex = defined?(::Mutex) ? ::Mutex.new : ::Thread::Mutex.new
|
15
16
|
@dirty = false
|
16
17
|
load_data
|
17
18
|
end
|
@@ -21,7 +22,7 @@ module Bootsnap
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def fetch(key)
|
24
|
-
raise(SetOutsideTransactionNotAllowed) unless @
|
25
|
+
raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
|
25
26
|
v = get(key)
|
26
27
|
unless v
|
27
28
|
@dirty = true
|
@@ -32,7 +33,7 @@ module Bootsnap
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def set(key, value)
|
35
|
-
raise(SetOutsideTransactionNotAllowed) unless @
|
36
|
+
raise(SetOutsideTransactionNotAllowed) unless @txn_mutex.owned?
|
36
37
|
if value != @data[key]
|
37
38
|
@dirty = true
|
38
39
|
@data[key] = value
|
@@ -40,12 +41,14 @@ module Bootsnap
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def transaction
|
43
|
-
raise(NestedTransactionError) if @
|
44
|
-
@
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
raise(NestedTransactionError) if @txn_mutex.owned?
|
45
|
+
@txn_mutex.synchronize do
|
46
|
+
begin
|
47
|
+
yield
|
48
|
+
ensure
|
49
|
+
commit_transaction
|
50
|
+
end
|
51
|
+
end
|
49
52
|
end
|
50
53
|
|
51
54
|
private
|
data/lib/bootsnap/setup.rb
CHANGED
@@ -24,12 +24,15 @@ unless cache_dir
|
|
24
24
|
cache_dir = File.join(app_root, 'tmp', 'cache')
|
25
25
|
end
|
26
26
|
|
27
|
+
ruby_version = Gem::Version.new(RUBY_VERSION)
|
28
|
+
iseq_cache_enabled = ruby_version < Gem::Version.new('2.5.0') || ruby_version >= Gem::Version.new('2.6.0')
|
29
|
+
|
27
30
|
Bootsnap.setup(
|
28
31
|
cache_dir: cache_dir,
|
29
32
|
development_mode: development_mode,
|
30
33
|
load_path_cache: true,
|
31
34
|
autoload_paths_cache: true, # assume rails. open to PRs to impl. detection
|
32
35
|
disable_trace: false,
|
33
|
-
compile_cache_iseq:
|
36
|
+
compile_cache_iseq: iseq_cache_enabled,
|
34
37
|
compile_cache_yaml: true,
|
35
38
|
)
|
data/lib/bootsnap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.7.6
|
170
|
+
rubygems_version: 3.0.2
|
172
171
|
signing_key:
|
173
172
|
specification_version: 4
|
174
173
|
summary: Boot large ruby/rails apps faster
|