mini_racer_rs 1.1.0 → 1.2.0

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.
@@ -0,0 +1,123 @@
1
+ use std::cell::Cell;
2
+ use std::sync::OnceLock;
3
+ use std::time::Duration;
4
+
5
+ /// How long a Ruby thread spins for a runner's answer before it gives up the
6
+ /// GVL, and then before it parks.
7
+ #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8
+ pub struct Budget {
9
+ pub gvl: Duration,
10
+ pub nogvl: Duration,
11
+ }
12
+
13
+ impl Budget {
14
+ fn parse(setting: &str) -> Self {
15
+ let parts: Vec<Option<u64>> = setting
16
+ .split(',')
17
+ .map(|part| part.trim().parse().ok())
18
+ .collect();
19
+ let at = |i: usize, default: u64| {
20
+ Duration::from_micros(parts.get(i).copied().flatten().unwrap_or(default))
21
+ };
22
+ Self {
23
+ gvl: at(0, 20),
24
+ nogvl: at(1, 50),
25
+ }
26
+ }
27
+
28
+ pub const fn total(&self) -> Duration {
29
+ self.gvl.saturating_add(self.nogvl)
30
+ }
31
+ }
32
+
33
+ // Unstable tuning knob: MINI_RACER_RS_SPIN_US=<with GVL>,<without GVL>.
34
+ pub fn budget() -> &'static Budget {
35
+ static BUDGET: OnceLock<Budget> = OnceLock::new();
36
+ BUDGET
37
+ .get_or_init(|| Budget::parse(&std::env::var("MINI_RACER_RS_SPIN_US").unwrap_or_default()))
38
+ }
39
+
40
+ // A context whose answers outlast the budget, such as one rendering pages,
41
+ // gains nothing from spinning: each wait burns the whole budget on the
42
+ // caller's CPU, the first part holding the GVL from other threads, and then
43
+ // parks anyway. A few in a row are enough to tell it from a one-off.
44
+ const STREAK: u8 = 3;
45
+
46
+ /// One context's recent waits: after `STREAK` in a row outlast the budget its
47
+ /// waits park at once, until one is answered within the budget.
48
+ #[derive(Debug, Default)]
49
+ pub struct History {
50
+ slow: Cell<u8>,
51
+ }
52
+
53
+ impl History {
54
+ pub const fn spins(&self) -> bool {
55
+ self.slow.get() < STREAK
56
+ }
57
+
58
+ pub fn record(&self, within_budget: bool) {
59
+ let slow = if within_budget {
60
+ 0
61
+ } else {
62
+ self.slow.get().saturating_add(1).min(STREAK)
63
+ };
64
+ self.slow.set(slow);
65
+ }
66
+ }
67
+
68
+ #[cfg(test)]
69
+ mod tests {
70
+ use super::*;
71
+
72
+ #[test]
73
+ fn the_budget_defaults_and_reads_the_knob() {
74
+ let us = Duration::from_micros;
75
+ assert_eq!(
76
+ Budget::parse(""),
77
+ Budget {
78
+ gvl: us(20),
79
+ nogvl: us(50)
80
+ }
81
+ );
82
+ assert_eq!(
83
+ Budget::parse("0,0"),
84
+ Budget {
85
+ gvl: us(0),
86
+ nogvl: us(0)
87
+ }
88
+ );
89
+ assert_eq!(
90
+ Budget::parse("5, x"),
91
+ Budget {
92
+ gvl: us(5),
93
+ nogvl: us(50)
94
+ }
95
+ );
96
+ assert_eq!(Budget::parse("").total(), us(70));
97
+ }
98
+
99
+ #[test]
100
+ fn a_streak_of_slow_answers_stops_spinning() {
101
+ let history = History::default();
102
+ for _ in 1..STREAK {
103
+ history.record(false);
104
+ assert!(history.spins());
105
+ }
106
+ history.record(false);
107
+ assert!(!history.spins());
108
+ history.record(false);
109
+ assert!(!history.spins());
110
+ }
111
+
112
+ #[test]
113
+ fn one_answer_within_the_budget_brings_spinning_back() {
114
+ let history = History::default();
115
+ for _ in 0..STREAK {
116
+ history.record(false);
117
+ }
118
+ history.record(true);
119
+ assert!(history.spins());
120
+ history.record(false);
121
+ assert!(history.spins());
122
+ }
123
+ }
@@ -1,8 +1,12 @@
1
1
  a4a5484444ad4b5f10dc7bed141236dd9dbeabf2006d14520f19b935d4db4227 librusty_v8_release_aarch64-apple-darwin.a.gz
2
2
  c40196bbf182532e583f65b7daf0196fdbb3354e6fac59b31d0539c20f931f3d librusty_v8_release_aarch64-unknown-linux-gnu.a.gz
3
+ 419a242557833151cf9dde82c12c8272c3c00015bfe7e340e48164a600d34039 librusty_v8_release_aarch64-unknown-linux-musl.a.gz
3
4
  04cbc1c36c4cd5459c54049775d92889337c69d936fb0b011f9b26f1d454610d librusty_v8_release_x86_64-apple-darwin.a.gz
4
5
  b6683e9afcb77fbd8cb2c3acf45d34d52029ab216b332522c95179c12f0fed3c librusty_v8_release_x86_64-unknown-linux-gnu.a.gz
6
+ 68f284fb8184b9f9e8d7e23b8f2675dbe464f43f77c0bf152f705bf7ead29558 librusty_v8_release_x86_64-unknown-linux-musl.a.gz
5
7
  b9d5652ebca515eb2bf4c2ee4a6551b2567117b5aa720f430d2032616dd7e3b5 src_binding_release_aarch64-apple-darwin.rs
6
8
  3e4d5fecdbe0f98a6017e69d7ca82519a77fb032c5eb5e4cdbecdd3e2ec519d5 src_binding_release_aarch64-unknown-linux-gnu.rs
9
+ 3e4d5fecdbe0f98a6017e69d7ca82519a77fb032c5eb5e4cdbecdd3e2ec519d5 src_binding_release_aarch64-unknown-linux-musl.rs
7
10
  b9d5652ebca515eb2bf4c2ee4a6551b2567117b5aa720f430d2032616dd7e3b5 src_binding_release_x86_64-apple-darwin.rs
8
11
  3e4d5fecdbe0f98a6017e69d7ca82519a77fb032c5eb5e4cdbecdd3e2ec519d5 src_binding_release_x86_64-unknown-linux-gnu.rs
12
+ 3e4d5fecdbe0f98a6017e69d7ca82519a77fb032c5eb5e4cdbecdd3e2ec519d5 src_binding_release_x86_64-unknown-linux-musl.rs
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacerRs
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -18,3 +18,4 @@ simdutf LICENSE https://chromium.googlesource.com/chromium/src/third_party/simdu
18
18
  fast_float LICENSE-MIT https://chromium.googlesource.com/external/github.com/fastfloat/fast_float/+/34164f547b7df3f5d794ff67e9f885c36819ebfc/LICENSE-MIT e562f3f974ced7e69dd1db77b820b36bcf8f30377f1aa105723fba449c53c4e6
19
19
  dragonbox LICENSE-Boost https://chromium.googlesource.com/external/github.com/jk-jeon/dragonbox/+/beeeef91cf6fef89a4d4ba5e95d47ca64ccb3a44/LICENSE-Boost c9bff75738922193e67fa726fa225535870d2aa1059f91452c411736284ad566
20
20
  chromium-build LICENSE https://chromium.googlesource.com/chromium/src/+/refs/tags/152.0.7977.89/LICENSE 368cca1106be99d39ecd32a38d8305585d802a475effb66380b91ffc9bcf709b
21
+ musl COPYRIGHT https://git.musl-libc.org/cgit/musl/plain/COPYRIGHT?h=v1.2.5 f9bc4423732350eb0b3f7ed7e91d530298476f8fec0c6c427a1c04ade22655af
@@ -1,8 +1,9 @@
1
1
  # Code compiled into rusty_v8's prebuilt archives. archive_path is a source
2
2
  # directory the archives' debug strings name: a top-level directory, or one
3
3
  # third_party/<name>. source is where its license comes from: a rusty_v8
4
- # submodule at the release tag ("submodule:<path>"), or a pinned base URL; "-"
5
- # with file "-" means another section of THIRD_PARTY_NOTICES.md covers it.
4
+ # submodule at the release tag ("submodule:<path>"), or a pinned base URL, whose
5
+ # query (a cgit ref) follows the file; "-" with file "-" means another section
6
+ # of THIRD_PARTY_NOTICES.md covers it.
6
7
  # component archive_path source file
7
8
  v8 v8 submodule:v8 LICENSE
8
9
  v8 v8 submodule:v8 LICENSE.fdlibm
@@ -24,6 +25,9 @@ dragonbox third_party/dragonbox submodule:third_party/dragonbox/src LICENSE-Boos
24
25
  # Chromium's build/ has no license file of its own; its sources defer to
25
26
  # Chromium's, pinned at the release line matching V8 15.2.
26
27
  chromium-build build https://chromium.googlesource.com/chromium/src/+/refs/tags/152.0.7977.89 LICENSE
28
+ # The musl archives compile against the musl headers of rusty_v8's release
29
+ # sysroot: musl 1.2.2 for x86_64, 1.2.5 for aarch64, whose COPYRIGHT files match.
30
+ musl musl-sysroot https://git.musl-libc.org/cgit/musl/plain?h=v1.2.5 COPYRIGHT
27
31
  # rusty_v8's own bindings: the v8 crate in the Rust crates section.
28
32
  rusty_v8 src - -
29
33
  temporal_capi third_party/rust/chromium_crates_io/vendor/temporal_capi-v0_2 - -
@@ -0,0 +1,193 @@
1
+ musl as a whole is licensed under the following standard MIT license:
2
+
3
+ ----------------------------------------------------------------------
4
+ Copyright © 2005-2020 Rich Felker, et al.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ----------------------------------------------------------------------
25
+
26
+ Authors/contributors include:
27
+
28
+ A. Wilcox
29
+ Ada Worcester
30
+ Alex Dowad
31
+ Alex Suykov
32
+ Alexander Monakov
33
+ Andre McCurdy
34
+ Andrew Kelley
35
+ Anthony G. Basile
36
+ Aric Belsito
37
+ Arvid Picciani
38
+ Bartosz Brachaczek
39
+ Benjamin Peterson
40
+ Bobby Bingham
41
+ Boris Brezillon
42
+ Brent Cook
43
+ Chris Spiegel
44
+ Clément Vasseur
45
+ Daniel Micay
46
+ Daniel Sabogal
47
+ Daurnimator
48
+ David Carlier
49
+ David Edelsohn
50
+ Denys Vlasenko
51
+ Dmitry Ivanov
52
+ Dmitry V. Levin
53
+ Drew DeVault
54
+ Emil Renner Berthing
55
+ Fangrui Song
56
+ Felix Fietkau
57
+ Felix Janda
58
+ Gianluca Anzolin
59
+ Hauke Mehrtens
60
+ He X
61
+ Hiltjo Posthuma
62
+ Isaac Dunham
63
+ Jaydeep Patil
64
+ Jens Gustedt
65
+ Jeremy Huntwork
66
+ Jo-Philipp Wich
67
+ Joakim Sindholt
68
+ John Spencer
69
+ Julien Ramseier
70
+ Justin Cormack
71
+ Kaarle Ritvanen
72
+ Khem Raj
73
+ Kylie McClain
74
+ Leah Neukirchen
75
+ Luca Barbato
76
+ Luka Perkov
77
+ M Farkas-Dyck (Strake)
78
+ Mahesh Bodapati
79
+ Markus Wichmann
80
+ Masanori Ogino
81
+ Michael Clark
82
+ Michael Forney
83
+ Mikhail Kremnyov
84
+ Natanael Copa
85
+ Nicholas J. Kain
86
+ orc
87
+ Pascal Cuoq
88
+ Patrick Oppenlander
89
+ Petr Hosek
90
+ Petr Skocik
91
+ Pierre Carrier
92
+ Reini Urban
93
+ Rich Felker
94
+ Richard Pennington
95
+ Ryan Fairfax
96
+ Samuel Holland
97
+ Segev Finer
98
+ Shiz
99
+ sin
100
+ Solar Designer
101
+ Stefan Kristiansson
102
+ Stefan O'Rear
103
+ Szabolcs Nagy
104
+ Timo Teräs
105
+ Trutz Behn
106
+ Valentin Ochs
107
+ Will Dietz
108
+ William Haddon
109
+ William Pitcock
110
+
111
+ Portions of this software are derived from third-party works licensed
112
+ under terms compatible with the above MIT license:
113
+
114
+ The TRE regular expression implementation (src/regex/reg* and
115
+ src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
116
+ under a 2-clause BSD license (license text in the source files). The
117
+ included version has been heavily modified by Rich Felker in 2012, in
118
+ the interests of size, simplicity, and namespace cleanliness.
119
+
120
+ Much of the math library code (src/math/* and src/complex/*) is
121
+ Copyright © 1993,2004 Sun Microsystems or
122
+ Copyright © 2003-2011 David Schultz or
123
+ Copyright © 2003-2009 Steven G. Kargl or
124
+ Copyright © 2003-2009 Bruce D. Evans or
125
+ Copyright © 2008 Stephen L. Moshier or
126
+ Copyright © 2017-2018 Arm Limited
127
+ and labelled as such in comments in the individual source files. All
128
+ have been licensed under extremely permissive terms.
129
+
130
+ The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
131
+ The Android Open Source Project and is licensed under a two-clause BSD
132
+ license. It was taken from Bionic libc, used on Android.
133
+
134
+ The AArch64 memcpy and memset code (src/string/aarch64/*) are
135
+ Copyright © 1999-2019, Arm Limited.
136
+
137
+ The implementation of DES for crypt (src/crypt/crypt_des.c) is
138
+ Copyright © 1994 David Burren. It is licensed under a BSD license.
139
+
140
+ The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
141
+ originally written by Solar Designer and placed into the public
142
+ domain. The code also comes with a fallback permissive license for use
143
+ in jurisdictions that may not recognize the public domain.
144
+
145
+ The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
146
+ Valentin Ochs and is licensed under an MIT-style license.
147
+
148
+ The x86_64 port was written by Nicholas J. Kain and is licensed under
149
+ the standard MIT terms.
150
+
151
+ The mips and microblaze ports were originally written by Richard
152
+ Pennington for use in the ellcc project. The original code was adapted
153
+ by Rich Felker for build system and code conventions during upstream
154
+ integration. It is licensed under the standard MIT terms.
155
+
156
+ The mips64 port was contributed by Imagination Technologies and is
157
+ licensed under the standard MIT terms.
158
+
159
+ The powerpc port was also originally written by Richard Pennington,
160
+ and later supplemented and integrated by John Spencer. It is licensed
161
+ under the standard MIT terms.
162
+
163
+ All other files which have no copyright comments are original works
164
+ produced specifically for use as part of this library, written either
165
+ by Rich Felker, the main author of the library, or by one or more
166
+ contibutors listed above. Details on authorship of individual files
167
+ can be found in the git version control history of the project. The
168
+ omission of copyright and license comments in each file is in the
169
+ interest of source tree size.
170
+
171
+ In addition, permission is hereby granted for all public header files
172
+ (include/* and arch/*/bits/*) and crt files intended to be linked into
173
+ applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
174
+ the copyright notice and permission notice otherwise required by the
175
+ license, and to use these files without any requirement of
176
+ attribution. These files include substantial contributions from:
177
+
178
+ Bobby Bingham
179
+ John Spencer
180
+ Nicholas J. Kain
181
+ Rich Felker
182
+ Richard Pennington
183
+ Stefan Kristiansson
184
+ Szabolcs Nagy
185
+
186
+ all of whom have explicitly granted such permission.
187
+
188
+ This file previously contained text expressing a belief that most of
189
+ the files covered by the above exception were sufficiently trivial not
190
+ to be subject to copyright, resulting in confusion over whether it
191
+ negated the permissions granted in the license. In the spirit of
192
+ permissive licensing, and of not having licensing issues being an
193
+ obstacle to adoption, that text has been removed.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer_rs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Aragon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-19 00:00:00.000000000 Z
10
+ date: 2026-10-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rb_sys
@@ -82,6 +82,7 @@ files:
82
82
  - crates/mini_racer_sync/src/termination.rs
83
83
  - crates/mini_racer_sync/src/workers.rs
84
84
  - crates/mini_racer_wire/Cargo.toml
85
+ - crates/mini_racer_wire/benches/wire.rs
85
86
  - crates/mini_racer_wire/src/decode.rs
86
87
  - crates/mini_racer_wire/src/lib.rs
87
88
  - crates/mini_racer_wire/src/marker.rs
@@ -104,6 +105,7 @@ files:
104
105
  - ext/mini_racer_rs/src/rb_raw.rs
105
106
  - ext/mini_racer_rs/src/snapshot.rs
106
107
  - ext/mini_racer_rs/src/source_maps.rs
108
+ - ext/mini_racer_rs/src/spin.rs
107
109
  - ext/mini_racer_rs/v8-archives.sha256
108
110
  - lib/mini_racer.rb
109
111
  - lib/mini_racer/shared.rb
@@ -131,6 +133,7 @@ files:
131
133
  - licenses/v8/libc++/LICENSE.TXT
132
134
  - licenses/v8/libc++abi/LICENSE.TXT
133
135
  - licenses/v8/llvm-libc/LICENSE.TXT
136
+ - licenses/v8/musl/COPYRIGHT
134
137
  - licenses/v8/rapidhash/LICENSE
135
138
  - licenses/v8/simdutf/LICENSE
136
139
  - licenses/v8/siphash/LICENSE