mini_racer_rs 1.4.0 → 1.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/COMPATIBILITY.md +36 -48
- data/Cargo.lock +5 -5
- data/Cargo.toml +1 -1
- data/README.md +38 -37
- data/crates/mini_racer_engine/src/context.rs +1 -6
- data/crates/mini_racer_engine/src/error.rs +26 -9
- data/crates/mini_racer_engine/src/snapshot.rs +259 -41
- data/crates/mini_racer_sync/src/termination.rs +1 -1
- data/ext/mini_racer_rs/src/decode.rs +10 -2
- data/ext/mini_racer_rs/src/encode.rs +72 -27
- data/ext/mini_racer_rs/src/host.rs +1 -1
- data/ext/mini_racer_rs/src/options.rs +1 -1
- data/ext/mini_racer_rs/src/snapshot.rs +6 -10
- data/lib/mini_racer/version.rb +1 -1
- data/lib/mini_racer_rs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf41190f924dfa0445ada46e1b47ed422f25b4d88de74d4c4f0397f4190282c9
|
|
4
|
+
data.tar.gz: 330258ac6f3a92e31e23e8123dedeae52befe9eecb0a2409a10da574a9cf7893
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fc22cbc008d1db4a8b8bf22e8d79177e20cd8ae97da99ab5f1962f601097dc8f37580ed4882ed5178c35c8be47bfb0d9a6b533fcf5b0ca281f928dfc2428c4b
|
|
7
|
+
data.tar.gz: 288df9055b1beb4231c3701e523a2176ac2907ae7762c8282c6534ca6119197c7f1c46a3ff1f534364c30c29825877637433a6144636e52ffd0d0d22da10e3e2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.5.0](https://github.com/andymai/mini_racer_rs/compare/v1.4.0...v1.5.0) (2026-10-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* target mini_racer 0.22.2 ([#137](https://github.com/andymai/mini_racer_rs/issues/137)) ([586475f](https://github.com/andymai/mini_racer_rs/commit/586475f231473ade936f69eb7344e9d5619fa045))
|
|
9
|
+
|
|
3
10
|
## [1.4.0](https://github.com/andymai/mini_racer_rs/compare/v1.3.0...v1.4.0) (2026-10-23)
|
|
4
11
|
|
|
5
12
|
|
data/COMPATIBILITY.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Compatibility with mini_racer 0.22.
|
|
1
|
+
# Compatibility with mini_racer 0.22.2
|
|
2
2
|
|
|
3
3
|
<!-- Generated by `rake compat:render` from compat.toml and compat/surface.json; do not edit. -->
|
|
4
4
|
|
|
5
5
|
| Engine | Done | Planned | Deviation |
|
|
6
6
|
|---|---|---|---|
|
|
7
|
-
| CRuby | 54 | 0 |
|
|
7
|
+
| CRuby | 54 | 0 | 26 |
|
|
8
8
|
| TruffleRuby | 58 | 0 | 0 |
|
|
9
9
|
|
|
10
10
|
## Surface
|
|
@@ -113,168 +113,156 @@ What mini_racer_rs adds under `MiniRacerRs`. An internal id is not for callers.
|
|
|
113
113
|
|
|
114
114
|
### `behavior:bigint-objects@ruby`
|
|
115
115
|
|
|
116
|
-
mini_racer_rs returns a BigInt wrapper object's wrapped value as an Integer: `Object(1n)` returns `1`, and `[Object(-5n)]` returns `[-5]`. mini_racer 0.22.
|
|
116
|
+
mini_racer_rs returns a BigInt wrapper object's wrapped value as an Integer: `Object(1n)` returns `1`, and `[Object(-5n)]` returns `[-5]`. mini_racer 0.22.2 instead raises `MiniRacer::RuntimeError` with the message `bad tag: z`. Returning the primitive value makes BigInt wrappers consistent with Boolean, Number, and String wrapper objects, which both gems already return as their primitive values.
|
|
117
117
|
|
|
118
118
|
Approved 2026-10-16.
|
|
119
119
|
|
|
120
120
|
### `behavior:callback-error-text@ruby`
|
|
121
121
|
|
|
122
|
-
When an attached Ruby callback raises, JavaScript receives an `Error` whose message is the exception’s `to_s`. mini_racer_rs gives V8 that text using the same rules as `eval` source: ISO-8859-1 as Latin-1, UTF-16LE as two-byte text, and other encodings as UTF-8, with invalid sequences replaced by U+FFFD. mini_racer 0.22.
|
|
122
|
+
When an attached Ruby callback raises, JavaScript receives an `Error` whose message is the exception’s `to_s`. mini_racer_rs gives V8 that text using the same rules as `eval` source: ISO-8859-1 as Latin-1, UTF-16LE as two-byte text, and other encodings as UTF-8, with invalid sequences replaced by U+FFFD. mini_racer 0.22.2 treats the string’s bytes as Latin-1 regardless of encoding. With `t` raising `"café"`, `try { t() } catch (e) { e.message }` returns `"café"` from mini_racer_rs and `"café"` from mini_racer 0.22.2. UTF-16LE produces a NUL after each letter in mini_racer. ASCII messages match. If JavaScript does not catch the exception, both gems raise the original Ruby exception from `eval` or `call` with its message unchanged.
|
|
123
123
|
|
|
124
124
|
Approved 2026-10-16.
|
|
125
125
|
|
|
126
126
|
### `behavior:callback-jump@ruby`
|
|
127
127
|
|
|
128
|
-
mini_racer_rs terminates
|
|
128
|
+
mini_racer_rs terminates JavaScript with `Error: terminated` when a callable attached with `Context#attach` exits by `throw`, by `return` from a proc whose method is still running, or by `Thread#kill`. A `throw` or `return` continues after `Context#eval` or `Context#call` returns, and the context remains usable. For example, `catch(:out) { context.eval("thrower(); 'not reached'") }` returns `5` when `thrower` executes `throw :out, 5`, and `proc { return :x }` returns `:x` from its method. After `Thread.current.kill`, the script and thread end. In mini_racer 0.22.2, a callback `throw`, whether JavaScript catches it, leaves it uncaught, or it comes from `Context#call`, and `proc { return }` crash the process with `[BUG] Segmentation fault` and status 139. `Thread.current.kill` instead gives JavaScript a catchable `Error: Ruby exception`; the script continues, and the thread ends after `eval` returns. `break` from a proc raises `LocalJumpError` in both gems.
|
|
129
129
|
|
|
130
|
-
Approved 2026-10-
|
|
130
|
+
Approved 2026-10-23.
|
|
131
131
|
|
|
132
132
|
### `behavior:callback-reentry@ruby`
|
|
133
133
|
|
|
134
|
-
Both gems allow an attached callback to call `eval`, `call`, or `attach` on its own context, running the nested call inside the script that invoked the callback. mini_racer_rs accepts the call only from the fiber running the callback. A call from another fiber on the same thread, such as code inside `Enumerator#next`, raises `ThreadError` (`deadlock; lock already owned by another fiber belonging to the same thread`). mini_racer 0.22.
|
|
134
|
+
Both gems allow an attached callback to call `eval`, `call`, or `attach` on its own context, running the nested call inside the script that invoked the callback. mini_racer_rs accepts the call only from the fiber running the callback. A call from another fiber on the same thread, such as code inside `Enumerator#next`, raises `ThreadError` (`deadlock; lock already owned by another fiber belonging to the same thread`). mini_racer 0.22.2 accepts it: `Enumerator.new { |y| y << context.eval("1") }.next` inside a callback returns `1`. A signal trap that calls the context while a callback waits on a nested `eval` gets `ThreadError` in mini_racer_rs; when rescued, the script completes. With mini_racer 0.22.2, the same program hangs until killed. mini_racer_rs refuses these calls because each nested call must finish before its callback replies, preventing out-of-order replies from being paired with the wrong callback.
|
|
135
135
|
|
|
136
136
|
Approved 2026-10-16.
|
|
137
137
|
|
|
138
138
|
### `behavior:dispose-in-flight@ruby`
|
|
139
139
|
|
|
140
|
-
`MiniRacer::Context#dispose` in mini_racer_rs returns only after the runner
|
|
140
|
+
`MiniRacer::Context#dispose` in mini_racer_rs returns only after the runner finishes any eval or call in flight and drops the isolate, in both platform modes, so the isolate and its memory cannot outlive disposal. On mini_racer 0.22.2's default platform, `dispose` returns once the context's V8 thread takes the work in flight, then that thread finishes it and frees the isolate. This is the behavior of `context_dispose_do` in `mini_racer_extension.c`, unchanged from 0.22.1. With `:single_threaded`, mini_racer joins the runner and waits. When disposal began 10 ms into an eval returning a 64 MiB string, mini_racer 0.22.2 returned at once on the default platform and after 64 to 73 ms with `:single_threaded`, across 5 runs each. mini_racer_rs returned after 46 to 54 ms and 45 to 50 ms. For busy loops, the in-flight eval raised `MiniRacer::ContextDisposedError` in 12 of 12 runs in both gems and both modes. mini_racer_rs's disposal took 0.2 to 0.4 ms.
|
|
141
141
|
|
|
142
|
-
Approved 2026-10-
|
|
142
|
+
Approved 2026-10-23.
|
|
143
143
|
|
|
144
144
|
### `behavior:fast-calls@ruby`
|
|
145
145
|
|
|
146
|
-
Unlike mini_racer 0.22.
|
|
146
|
+
Unlike mini_racer 0.22.2, which compiles every source, mini_racer_rs recognizes ExecJS 2.10.2 `call` sources and react-rails 3.2.1 and 3.3.1 server render sources evaluated without a file name, then runs a template compiled once by the context. The template remains a top-level script and replaces each JSON literal with a native function call stored in a randomly named global `const`; V8's JSON parser reads the values. Results, error classes and messages, `this`, and stack frame line and column numbers remain those of the source. The approved `behavior:fast-calls@ruby` deviation is limited to V8 stack reflection: `CallSite#getScriptHash` reports the template hash, and render `CallSite#getPosition` can report a different raw offset after hoisted literals, such as 260 instead of 185. A reflected render wrapper shows template reads instead of literals, and invoking it again receives no values outside a fast call or the current call's values during one, while mini_racer supplies the literals each time. Heap snapshots expose the hidden `const`. Set `MINI_RACER_RS_FAST_CALLS` to `off` before the first context is created to send every eval down the normal path.
|
|
147
147
|
|
|
148
148
|
Approved 2026-10-18.
|
|
149
149
|
|
|
150
150
|
### `behavior:fiber-scheduler@ruby`
|
|
151
151
|
|
|
152
|
-
mini_racer_rs parks only a non-blocking fiber waiting for a context under a fiber scheduler, so the thread's other fibers keep running during `Context.new`, `eval`, `call`, `attach`, `dispose`, and nested callback calls. mini_racer 0.22.
|
|
152
|
+
mini_racer_rs parks only a non-blocking fiber waiting for a context under a fiber scheduler, so the thread's other fibers keep running during `Context.new`, `eval`, `call`, `attach`, `dispose`, and nested callback calls. mini_racer 0.22.2 releases the GVL and blocks the whole thread until JavaScript returns. Three 100 ms busy loops in separate contexts and fibers inside `Sync` finish in 100 ms with mini_racer_rs, with a 10 ms ticker ticking 9 times; mini_racer takes 300 ms, with 3 ticks. With mini_racer_rs, `task.with_timeout(0.05) { context.call("busy", 300) }` raises `Async::TimeoutError` after 50 ms and terminates JavaScript; mini_racer returns `300` after 300 ms. In both gems the context stays usable afterward. Fibers sharing a context take turns in both gems. Without a scheduler or in a blocking fiber, mini_racer_rs blocks the thread while waiting, as mini_racer does. `Snapshot.new` also blocks the thread.
|
|
153
153
|
|
|
154
154
|
Approved 2026-10-16.
|
|
155
155
|
|
|
156
156
|
### `behavior:fork-from-callback@ruby`
|
|
157
157
|
|
|
158
|
-
With an attached callback that calls `fork` under the `:single_threaded` platform flag, the parent's `eval` returns `"parent"` in both gems, and its later `context.eval("1 + 1")` returns `2`. mini_racer 0.22.
|
|
158
|
+
With an attached callback that calls `fork` under the `:single_threaded` platform flag, the parent's `eval` returns `"parent"` in both gems, and its later `context.eval("1 + 1")` returns `2`. mini_racer 0.22.2's child is still running five seconds later, when the test kills it. In mini_racer_rs's child, the `eval` that invokes the callback raises `MiniRacer::RuntimeError` with `single-threaded runner: Device or resource busy` when the callback returns, because the JavaScript thread stays with the parent. A call on the same context from inside the child callback, and every later call, raises the same error. A new child context works: `MiniRacer::Context.new.eval("6 * 7")` returns `42`.
|
|
159
159
|
|
|
160
160
|
Approved 2026-10-16.
|
|
161
161
|
|
|
162
162
|
### `behavior:fork-quiesce-bound@ruby`
|
|
163
163
|
|
|
164
|
-
With
|
|
164
|
+
With `:single_threaded`, mini_racer_rs waits up to 500 ms inside Ruby's `fork` or `Process.daemon` for every context runner to become idle or parked. If another thread is running an operation V8 does not interrupt, such as `JSON.parse` on a large string, the child refuses every inherited context. Calling an idle inherited context raises `MiniRacer::RuntimeError` with `single-threaded runner: Device or resource busy`; new contexts created in the child work. mini_racer 0.22.2 does not wait for its runners. With another thread parsing the JSON for a 3,000,000-element array, mini_racer 0.22.2 forked in 3 ms and its child's idle context returned `42`. mini_racer_rs forked in 523 ms and refused that inherited context.
|
|
165
165
|
|
|
166
|
-
Approved 2026-10-
|
|
166
|
+
Approved 2026-10-23.
|
|
167
167
|
|
|
168
168
|
### `behavior:fork-wait@ruby`
|
|
169
169
|
|
|
170
|
-
For
|
|
170
|
+
For Ruby `fork`, `IO.popen("-")`, and `Process.daemon`, mini_racer_rs waits for context runners, pauses its worker pool, and waits for running worker tasks in both platform modes. mini_racer 0.22.2 waits for neither; its fork handling is unchanged from 0.22.1. Idle mini_racer_rs pool threads wait on a Rust standard library condition variable that keeps no records on their stacks, so children inherit no records referring to discarded stacks. mini_racer creates `:single_threaded` with `NewSingleThreadedDefaultPlatform`, which has no V8 worker threads. mini_racer_rs creates V8's platform with one worker thread that never receives a task and routes worker tasks to a process-owned pool with one thread under `:single_threaded`. On Ubuntu 24.04 with glibc 2.39, with mini_racer 0.22.1, 20 of 20 children aborted with signal 6 after loading and rendering React, both with and without two parent threads continuing to render. That code is unchanged in mini_racer 0.22.2. mini_racer_rs exited cleanly in 20 of 20 children in both cases. On Fedora, three runs of `test/stress/fork_busy.rb`, each attempting 300 forks while four threads evaluated, aborted with mini_racer 0.22.2 after 5, 14, and 19 forks when an evaluating parent thread raised `TypeError` with `exception class/object expected`. mini_racer_rs completed all 300 forks per run. With four evaluating threads and 50 forks per run, median fork time across three runs was 5.17 to 5.60 ms for mini_racer_rs and 5.22 to 5.47 ms for mini_racer 0.22.2. The waits are best effort: forking proceeds after the 500 ms runner bound or the following 100 ms worker bound expires.
|
|
171
171
|
|
|
172
|
-
Approved 2026-10-
|
|
172
|
+
Approved 2026-10-23.
|
|
173
173
|
|
|
174
174
|
### `behavior:invalid-snapshot@ruby`
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
`Snapshot.load` checks blobs in the same order in both gems and raises `MiniRacer::SnapshotError` with the same messages for a blob that is too short, an invalid context table, version mismatch, invalid header, no contexts, invalid read-only, shared heap or context offsets, and `snapshot checksum mismatch`. The checksum makes both reject truncation, flipped bytes, and trailing bytes. Damage under a recomputed checksum loads in both when V8 can read it. With a valid checksum, mini_racer 0.22.2 aborts with SIGTRAP when a context is made from a blob whose section magic number is not exactly V8's, while mini_racer_rs raises `SnapshotError` with `snapshot startup section is invalid` or the matching section message. mini_racer 0.22.2 also lets V8 read past a section when its recorded payload overruns it, and aborts when a payload length exceeds 2,147,483,647. mini_racer_rs raises `SnapshotError` in both cases. A blob cut in half can name a different section, because the two V8 versions' blobs place their sections at different offsets. An empty blob starts a context without a snapshot in both gems.
|
|
177
177
|
|
|
178
|
-
Approved 2026-10-
|
|
178
|
+
Approved 2026-10-23.
|
|
179
179
|
|
|
180
180
|
### `behavior:multi-threaded-fork@ruby`
|
|
181
181
|
|
|
182
|
-
In a child forked from a process using V8's default multi-threaded platform, mini_racer 0.22.
|
|
182
|
+
In a child forked from a process using V8's default multi-threaded platform, an inherited mini_racer 0.22.2 context hangs on `context.eval("1 + 1")`; the child was still waiting after 3 seconds. mini_racer_rs instead immediately raises `MiniRacer::RuntimeError` with `single-threaded runner: Device or resource busy`, and the parent's contexts remain unaffected. The child inherits none of the context runner or V8 worker threads. A new `MiniRacer::Context` in the mini_racer_rs child evaluates `eval("2")` to `2` and runs V8 worker work on the child's own pool, so an asynchronous `WebAssembly.compile` completes. With mini_racer 0.22.2 on Fedora, that compile was still waiting after 5 seconds. On Ubuntu 24.04, mini_racer 0.22.1 aborted with signal 6 in 2 of 3 runs and hung in 1 of 3; its fork handling is unchanged in 0.22.2. Contexts intended to keep working in a child should use `:single_threaded`.
|
|
183
183
|
|
|
184
|
-
Approved 2026-10-
|
|
184
|
+
Approved 2026-10-23.
|
|
185
185
|
|
|
186
186
|
### `behavior:native-fork@ruby`
|
|
187
187
|
|
|
188
|
-
With the `:single_threaded` platform flag, mini_racer_rs refuses every context inherited by a child of a fork that bypasses Ruby's `fork`, including idle contexts: calls raise `MiniRacer::RuntimeError` with `single-threaded runner: Device or resource busy`. In a libc `fork()` test through Fiddle, mini_racer 0.22.
|
|
188
|
+
With the `:single_threaded` platform flag, mini_racer_rs refuses every context inherited by a child of a fork that bypasses Ruby's `fork`, including idle contexts: calls raise `MiniRacer::RuntimeError` with `single-threaded runner: Device or resource busy`. In a libc `fork()` test through Fiddle, mini_racer 0.22.2's child returned `42` from an inherited idle context holding `var answer = 42`, while mini_racer_rs raised that error. In both gems, new child contexts and the parent's context work. Calling `dispose` on an inherited child context returns `nil`, after which calls raise `MiniRacer::ContextDisposedError`. mini_racer_rs cannot rule out an in-progress V8 state change without the runner wait used by Ruby's `fork`, `IO.popen("-")`, and `Process.daemon`.
|
|
189
189
|
|
|
190
190
|
Approved 2026-10-16.
|
|
191
191
|
|
|
192
192
|
### `behavior:object-ids@ruby`
|
|
193
193
|
|
|
194
|
-
mini_racer_rs preserves repeated-object identity in both directions by numbering every object as V8 does, including dates, regular expressions, typed arrays, ArrayBuffers, wrapper objects, and errors. Serialized repeats refer back by number. From JavaScript to Ruby, `(() => { const d = new Date(0); const o = {}; return [d, d, o, o] })()` returns `[Time, Time, {}, {}]`, with each pair the same Ruby object. mini_racer 0.22.
|
|
194
|
+
mini_racer_rs preserves repeated-object identity in both directions by numbering every object as V8 does, including dates, regular expressions, typed arrays, ArrayBuffers, wrapper objects, and errors. Serialized repeats refer back by number. From JavaScript to Ruby, `(() => { const d = new Date(0); const o = {}; return [d, d, o, o] })()` returns `[Time, Time, {}, {}]`, with each pair the same Ruby object. mini_racer 0.22.2 counts only decoded arrays, objects, maps, sets, and errors, so it returns `[Time, nil, {}, nil]`; a repeated error, including one that is its own cause, becomes `[]` instead of the same `MiniRacer::ScriptError`. From Ruby to JavaScript, mini_racer 0.22.2 counts only Arrays and Hashes, so `context.call("f", time, hash, hash)` gives `f` a Date, an object, and the same Date. mini_racer_rs gives `f` the same object twice. For call arguments and callback results, it also sends a repeated `Time`, `DateTime`, object whose `to_time` returns a `Time`, or `MiniRacer::Binary` as one Date or Uint8Array, calling `to_time` once per object. Thus, with `same = (a, b) => a === b`, `context.call("same", time, time)` returns `true`, while mini_racer returns `false`; distinct equal `Time` objects remain distinct in both.
|
|
195
195
|
|
|
196
196
|
Approved 2026-10-16.
|
|
197
197
|
|
|
198
198
|
### `behavior:padded-two-byte-text@ruby`
|
|
199
199
|
|
|
200
|
-
mini_racer_rs returns a regular expression as its pattern String and a String object as its String, including `[1, new RegExp('東')]`, `new RegExp('東')`, and `[new String('東')]` as `[1, "東"]`, `"東"`, and `["東"]`. It skips V8's optional alignment byte before two-byte text, as V8's own deserializer does. mini_racer 0.22.
|
|
200
|
+
mini_racer_rs returns a regular expression as its pattern String and a String object as its String, including `[1, new RegExp('東')]`, `new RegExp('東')`, and `[new String('東')]` as `[1, "東"]`, `"東"`, and `["東"]`. It skips V8's optional alignment byte before two-byte text, as V8's own deserializer does. mini_racer 0.22.2 does not accept that byte and raises `MiniRacer::RuntimeError` with `bad regexp` or `bad string object` for these examples, although `({ab: new RegExp('東')})` returns `{"ab" => "東"}` because its serialized position requires no alignment byte.
|
|
201
201
|
|
|
202
202
|
Approved 2026-10-16.
|
|
203
203
|
|
|
204
204
|
### `behavior:platforms@ruby`
|
|
205
205
|
|
|
206
|
-
mini_racer_rs ships native gems for the platforms libv8-node publishes gems for, which mini_racer 0.22.
|
|
206
|
+
mini_racer_rs ships native gems for the platforms libv8-node publishes gems for, which mini_racer 0.22.2 uses: glibc and musl Linux on x86_64 and aarch64, and macOS on x86_64 and arm64. Neither supports Windows. On any other platform, mini_racer_rs's source gem stops installation with a message naming the supported platforms, while mini_racer can install libv8-node's source gem.
|
|
207
207
|
|
|
208
208
|
Approved 2026-10-22.
|
|
209
209
|
|
|
210
210
|
### `behavior:shared-source-heap-stats@ruby`
|
|
211
211
|
|
|
212
|
-
`Context#heap_stats` reports shared sources differently from mini_racer 0.22.
|
|
212
|
+
`Context#heap_stats` reports shared sources differently from mini_racer 0.22.2: when a context evaluates a source of 1 MiB or more, mini_racer_rs includes it in `:external_memory` and excludes it from `:used_heap_size`. mini_racer_rs gives V8 one copy held outside V8's heap, shared starting with the first evaluation by every context using the same source, file name, and startup snapshot. The process shares at most 8 such sources and 256 MiB of them. Past that bound, a context evaluating another large source keeps its own copy, and its `heap_stats` count that source as mini_racer's do. V8 counts shared sources in `:external_memory` by character length, so two-byte text reports half its bytes. mini_racer 0.22.2 reports `:external_memory` as 0 and counts each context's own copy in `:used_heap_size`. JavaScript sees the same source text in both gems. Contexts created with `max_memory:` and sources that are not valid UTF-8 keep their own copies. Setting `MINI_RACER_RS_CODE_CACHE=off` before the first context prevents source sharing and makes `heap_stats` count every source as mini_racer does.
|
|
213
213
|
|
|
214
214
|
Approved 2026-10-18.
|
|
215
215
|
|
|
216
216
|
### `behavior:snapshot-filter-context@ruby`
|
|
217
217
|
|
|
218
|
-
mini_racer_rs returns the same filtered results from a snapshot-based context as from a context without a snapshot. In a context made from `MiniRacer::Snapshot.new("Object.getOwnPropertyDescriptors = () => ({})")`, `({a: 1, f() {}})` returns `{"a" => 1}`, and `[1, function() {}]` returns `[1]`. mini_racer 0.22.
|
|
218
|
+
mini_racer_rs returns the same filtered results from a snapshot-based context as from a context without a snapshot. In a context made from `MiniRacer::Snapshot.new("Object.getOwnPropertyDescriptors = () => ({})")`, `({a: 1, f() {}})` returns `{"a" => 1}`, and `[1, function() {}]` returns `[1]`. mini_racer 0.22.2 returns `nil` for both. Both gems copy results that V8 refuses to serialize as is through a filter in a separate safe context. mini_racer_rs keeps an untouched context in each snapshot blob and uses it for that filter, while mini_racer 0.22.2 builds the safe context from the snapshot, exposing the filter's built-ins to snapshot code. User code still sees the replacement in both gems: `Object.getOwnPropertyDescriptors({a: 1})` returns `{}`.
|
|
219
219
|
|
|
220
220
|
Approved 2026-10-16.
|
|
221
221
|
|
|
222
222
|
### `behavior:source-maps@ruby`
|
|
223
223
|
|
|
224
|
-
After a source map is registered with `MiniRacerRs.register_source_map(bundle, map)`, `MiniRacer::RuntimeError` backtraces for contexts that evaluate a UTF-8 source containing the bundle show the mapped original file, line, and column for covered frames inside that bundle, while preserving V8's function name. mini_racer 0.22.
|
|
224
|
+
After a source map is registered with `MiniRacerRs.register_source_map(bundle, map)`, `MiniRacer::RuntimeError` backtraces for contexts that evaluate a UTF-8 source containing the bundle show the mapped original file, line, and column for covered frames inside that bundle, while preserving V8's function name. mini_racer 0.22.2 has no source map support, so its runtime backtraces always show V8 positions. mini_racer_rs keeps V8 positions for async frames, frames after the tenth, `eval` and `new Function` code, frames outside the bundle, uncovered positions, and every frame when the reported frames do not align with V8's stack trace. `MiniRacer::ParseError` and `MiniRacer::ScriptError` messages are unchanged, as are JavaScript-visible values such as `Error.prototype.stack`. Latin-1 and UTF-16 sources and bundles in startup snapshots do not match. With no registered map, behavior is exactly that of mini_racer 0.22.2. Maps are process wide and limited to eight bundles. Affected contexts collect detailed stacks, increasing the measured cost of a 20-frame `new Error` from about 0.8 to 1.5 microseconds and a caught `throw {}` 20 frames deep from about 0.2 to 1.2 microseconds; measured React and MUI server renders were unchanged.
|
|
225
225
|
|
|
226
226
|
Approved 2026-10-18.
|
|
227
227
|
|
|
228
228
|
### `behavior:stack-exhaustion@ruby`
|
|
229
229
|
|
|
230
|
-
mini_racer_rs raises `SystemStackError` with `stack level too deep` when
|
|
230
|
+
mini_racer_rs raises `SystemStackError` with `stack level too deep` when it converts a JavaScript result on a Ruby fiber or thread with too little machine stack left for Ruby to call a C function. For attached callable arguments, it does not call the callable and gives JavaScript an Error with `stack level too deep`; if uncaught, `eval` raises that `SystemStackError`. The context remains usable and can evaluate `1 + 1` to `2` and dispose. Across 960 runs on 128 KiB fiber and thread stacks, covering release and debug builds with and without `GC.stress` and compaction, mini_racer_rs never hung or crashed. In mini_racer 0.22.2, 120 runs per kind without `GC.stress` produced 77 returned results, 30 `SystemStackError`s, and 13 hangs, including 12 for Latin-1 or two-byte strings. Callbacks delivered `stack level too deep` 58 times, returned 46 times, crashed 7 times, hung 3 times, and left 6 contexts unable to dispose with `context dispose: Device or resource busy`. With `GC.stress` and compaction, results aborted 36 times with `[BUG] system stack overflow during GC` and crashed 6 times; callbacks aborted 21 times and crashed 42 times. The tradeoff is stack cost. In release builds, a 95-level object result needed about 24 to 32 KiB beyond Ruby's method-call limit in mini_racer_rs, compared with about 8 to 16 KiB on a fiber and 2 to 4 KiB on a thread in mini_racer 0.22.2. Near the end of a stack, mini_racer_rs therefore refuses some results mini_racer returns. On Ruby 3.4's default 512 KiB fiber and 1 MiB thread stacks, mini_racer_rs converts every kind of value nested 95 levels deep.
|
|
231
231
|
|
|
232
|
-
Approved 2026-10-
|
|
232
|
+
Approved 2026-10-23.
|
|
233
233
|
|
|
234
234
|
### `behavior:timeout-bounds-leftover-microtasks@ruby`
|
|
235
235
|
|
|
236
|
-
mini_racer_rs applies the context’s timeout once more while running microtasks left by a script that reached its own timeout. Both gems run leftover microtasks before returning, but mini_racer 0.22.
|
|
236
|
+
mini_racer_rs applies the context’s timeout once more while running microtasks left by a script that reached its own timeout. Both gems run leftover microtasks before returning, but mini_racer 0.22.2's watchdog has already fired for that call, so it runs them without a time limit. For example, with `timeout: 200`, evaluating `Promise.resolve().then(() => { while (true) {} }); while (true) {}` never returns in mini_racer. In mini_racer_rs it raises `MiniRacer::ScriptTerminatedError` after about 400 ms, and the context remains usable. This also means mini_racer_rs cuts short a finite leftover microtask that needs more than the second 200 ms, while mini_racer finishes it. Microtasks left by a script ended another way, such as by `stop`, a memory limit, or an interrupt, keep the original deadline in both gems. Without `timeout:`, both run leftover microtasks without a limit. mini_racer_rs differs because `timeout:` often bounds untrusted JavaScript, and an endless microtask should not remove that bound.
|
|
237
237
|
|
|
238
238
|
Approved 2026-10-17.
|
|
239
239
|
|
|
240
240
|
### `behavior:timeout-watchdog@ruby`
|
|
241
241
|
|
|
242
|
-
mini_racer_rs raises MiniRacer::InternalError when its single process-wide watchdog thread cannot start, and the timed script does not run. mini_racer 0.22.
|
|
242
|
+
mini_racer_rs raises MiniRacer::InternalError when its single process-wide watchdog thread cannot start, and the timed script does not run. mini_racer 0.22.2 starts a watchdog thread for each eval or call on a context created with timeout:; if creation fails, it prints mini_racer: watchdog: pthread_create: <error> to stderr and runs the script without a time limit. This difference prevents a failed watchdog from silently removing the bound often placed on untrusted JavaScript.
|
|
243
243
|
|
|
244
244
|
Approved 2026-10-16.
|
|
245
245
|
|
|
246
246
|
### `behavior:typed-array-offsets@ruby`
|
|
247
247
|
|
|
248
|
-
mini_racer_rs returns a typed array or DataView at any byte offset as a binary (`ASCII-8BIT`) String containing the view's whole ArrayBuffer, consistent with both gems at offset 0. mini_racer 0.22.
|
|
249
|
-
|
|
250
|
-
Approved 2026-10-16.
|
|
251
|
-
|
|
252
|
-
### `behavior:uncloneable-after-filter@ruby`
|
|
253
|
-
|
|
254
|
-
mini_racer_rs returns an error Hash when a result remains uncloneable after both gems copy it through mini_racer's filter function, which keeps enumerable data and drops functions. For example, `({a: Symbol("s")})` returns `{"error" => "Error: Symbol(s) could not be cloned."}`. A Map with a function key is another such case. mini_racer 0.22.1 aborts the Ruby process with signal 6 (SIGABRT), although its code contains the fallback that returns V8's message in a Hash. mini_racer_rs uses that fallback.
|
|
248
|
+
mini_racer_rs returns a typed array or DataView at any byte offset as a binary (`ASCII-8BIT`) String containing the view's whole ArrayBuffer, consistent with both gems at offset 0. mini_racer 0.22.2 instead raises `MiniRacer::RuntimeError` with `bad typed array` for offsets such as those in `new Uint8Array(new ArrayBuffer(8), 4)` and `new DataView(new ArrayBuffer(4), 1, 2)`. Its decoder checks the byte after the view type, so offsets whose first encoded byte matches a view type letter can pass, including offset 66 for `B`.
|
|
255
249
|
|
|
256
250
|
Approved 2026-10-16.
|
|
257
251
|
|
|
258
252
|
### `behavior:v8-version@ruby`
|
|
259
253
|
|
|
260
|
-
On CRuby,
|
|
261
|
-
|
|
262
|
-
Approved 2026-10-16.
|
|
263
|
-
|
|
264
|
-
### `behavior:warmup-discards-context@ruby`
|
|
254
|
+
On CRuby, mini_racer_rs embeds V8 15.2.124.1 through the `v8` crate 152.2.0, while mini_racer 0.22.2 uses V8 13.6.233.17 through `libv8-node` 24.12.0.1. V8-generated text, including parse and runtime error messages and locale formatting, can therefore differ. In single-threaded mode, after `low_memory_notification` on a new context, `pump_message_loop` returns `true` in mini_racer_rs because V8 15.2 posts a zero-delay foreground task during collection, while it returns `false` in mini_racer 0.22.2. Later pumps return `false` in both, as they do in the default multi-threaded mode. This difference does not apply on TruffleRuby, where both gems use upstream's GraalJS backend.
|
|
265
255
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Approved 2026-10-16.
|
|
256
|
+
Approved 2026-10-23.
|
|
269
257
|
|
|
270
258
|
### `module:MiniRacer::Loader@ruby`
|
|
271
259
|
|
|
272
|
-
`MiniRacer::Loader` and `MiniRacer::Loader.load` do not exist in mini_racer_rs, whose single native extension uses a plain `require`. Its dynamic exports are limited to per-platform allowlists, CI fails if any C++ or Rust symbol is exported, and on Linux it links with `-Bsymbolic` so its references bind to its own definitions. mini_racer 0.22.
|
|
260
|
+
`MiniRacer::Loader` and `MiniRacer::Loader.load` do not exist in mini_racer_rs, whose single native extension uses a plain `require`. Its dynamic exports are limited to per-platform allowlists, CI fails if any C++ or Rust symbol is exported, and on Linux it links with `-Bsymbolic` so its references bind to its own definitions. mini_racer 0.22.2 uses `mini_racer_loader` with `RTLD_LOCAL` and `RTLD_DEEPBIND`, except when `LD_PRELOAD` contains `malloc`; `LD_PRELOAD` does not change mini_racer_rs loading.
|
|
273
261
|
|
|
274
262
|
Approved 2026-10-16.
|
|
275
263
|
|
|
276
264
|
### `smethod:MiniRacer::Loader.load@ruby`
|
|
277
265
|
|
|
278
|
-
`MiniRacer::Loader` and `MiniRacer::Loader.load` do not exist in mini_racer_rs, whose single native extension uses a plain `require`. Its dynamic exports are limited to per-platform allowlists, CI fails if any C++ or Rust symbol is exported, and on Linux it links with `-Bsymbolic` so its references bind to its own definitions. mini_racer 0.22.
|
|
266
|
+
`MiniRacer::Loader` and `MiniRacer::Loader.load` do not exist in mini_racer_rs, whose single native extension uses a plain `require`. Its dynamic exports are limited to per-platform allowlists, CI fails if any C++ or Rust symbol is exported, and on Linux it links with `-Bsymbolic` so its references bind to its own definitions. mini_racer 0.22.2 uses `mini_racer_loader` with `RTLD_LOCAL` and `RTLD_DEEPBIND`, except when `LD_PRELOAD` contains `malloc`; `LD_PRELOAD` does not change mini_racer_rs loading.
|
|
279
267
|
|
|
280
268
|
Approved 2026-10-16.
|
data/Cargo.lock
CHANGED
|
@@ -593,7 +593,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
|
593
593
|
|
|
594
594
|
[[package]]
|
|
595
595
|
name = "mini_racer_engine"
|
|
596
|
-
version = "1.
|
|
596
|
+
version = "1.5.0"
|
|
597
597
|
dependencies = [
|
|
598
598
|
"deno_core_icudata",
|
|
599
599
|
"libc",
|
|
@@ -606,7 +606,7 @@ dependencies = [
|
|
|
606
606
|
|
|
607
607
|
[[package]]
|
|
608
608
|
name = "mini_racer_rs"
|
|
609
|
-
version = "1.
|
|
609
|
+
version = "1.5.0"
|
|
610
610
|
dependencies = [
|
|
611
611
|
"magnus",
|
|
612
612
|
"mini_racer_engine",
|
|
@@ -617,7 +617,7 @@ dependencies = [
|
|
|
617
617
|
|
|
618
618
|
[[package]]
|
|
619
619
|
name = "mini_racer_sourcemap"
|
|
620
|
-
version = "1.
|
|
620
|
+
version = "1.5.0"
|
|
621
621
|
dependencies = [
|
|
622
622
|
"memchr",
|
|
623
623
|
"serde",
|
|
@@ -627,7 +627,7 @@ dependencies = [
|
|
|
627
627
|
|
|
628
628
|
[[package]]
|
|
629
629
|
name = "mini_racer_sync"
|
|
630
|
-
version = "1.
|
|
630
|
+
version = "1.5.0"
|
|
631
631
|
dependencies = [
|
|
632
632
|
"loom",
|
|
633
633
|
"thiserror",
|
|
@@ -635,7 +635,7 @@ dependencies = [
|
|
|
635
635
|
|
|
636
636
|
[[package]]
|
|
637
637
|
name = "mini_racer_wire"
|
|
638
|
-
version = "1.
|
|
638
|
+
version = "1.5.0"
|
|
639
639
|
dependencies = [
|
|
640
640
|
"criterion",
|
|
641
641
|
"proptest",
|
data/Cargo.toml
CHANGED
|
@@ -15,7 +15,7 @@ license = "MIT"
|
|
|
15
15
|
publish = false
|
|
16
16
|
repository = "https://github.com/andymai/mini_racer_rs"
|
|
17
17
|
rust-version = "1.91"
|
|
18
|
-
version = "1.
|
|
18
|
+
version = "1.5.0"
|
|
19
19
|
|
|
20
20
|
[workspace.dependencies]
|
|
21
21
|
criterion = {version = "0.8", default-features = false, features = ["cargo_bench_support"]}
|
data/README.md
CHANGED
|
@@ -9,28 +9,28 @@ A drop-in replacement for mini_racer, implemented in Rust on V8 15.2.
|
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
[](#scope)
|
|
11
11
|
[](#how-it-works)
|
|
12
|
-
[](COMPATIBILITY.md)
|
|
13
13
|
|
|
14
14
|
**[Install](#install)** · **[Quick start](#quick-start)** · **[API](#api-at-a-glance)** · **[Switching](#switching-from-mini_racer)** · **[Benchmarks](#benchmarks)** · **[How it works](#how-it-works)** · **[Compatibility](COMPATIBILITY.md)** · **[Architecture](ARCHITECTURE.md)**
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
mini_racer_rs implements the `MiniRacer` API from mini_racer 0.22.
|
|
18
|
+
mini_racer_rs implements the `MiniRacer` API from mini_racer 0.22.2. It defines `MiniRacer` and ships `lib/mini_racer.rb`, so `require "mini_racer"` and ExecJS keep working.
|
|
19
19
|
|
|
20
20
|
> mini_racer_rs is an independent project and is not affiliated with the Discourse staff who maintain mini_racer.
|
|
21
21
|
|
|
22
22
|
## Highlights
|
|
23
23
|
|
|
24
|
-
- **Round trips:** 5 to 9 times faster (0.
|
|
25
|
-
- **Babel through ExecJS:** 1.
|
|
24
|
+
- **Round trips:** 5 to 9 times faster (0.75 µs vs 6.45 µs per call).
|
|
25
|
+
- **Babel through ExecJS:** 1.97x faster (5.11 ms vs 10.06 ms).
|
|
26
26
|
- **Bundle load:** 4.6x faster for a 44 MB production server rendering bundle (215 ms vs 983 ms).
|
|
27
|
-
- **Memory:** A context holding the MUI bundle uses
|
|
27
|
+
- **Memory:** A context holding the MUI bundle uses 43 MB vs 110 MB.
|
|
28
28
|
- **Forks:** After loading and rendering React: 20 of 20 clean mini_racer_rs exits vs 20 of 20 mini_racer aborts.
|
|
29
|
-
- **V8:** V8 15.2.124.1 vs V8 13.6.233.17 in mini_racer 0.22.
|
|
29
|
+
- **V8:** V8 15.2.124.1 vs V8 13.6.233.17 in mini_racer 0.22.2.
|
|
30
30
|
- **No compiler:** Native gems cover glibc and musl Linux, including Alpine, and macOS, on both architectures, with Ruby 3.3, 3.4 and 4.0 extensions.
|
|
31
31
|
- **Fiber scheduler:** Three 100 ms loops in separate contexts and fibers finish in 100 ms vs 300 ms.
|
|
32
|
-
- **Upstream suites:** mini_racer passes
|
|
33
|
-
- **
|
|
32
|
+
- **Upstream suites:** mini_racer passes 187 of 190 with 3 skipped by itself; ExecJS passes 197 of 198 with 1 skipped.
|
|
33
|
+
- **Callback jumps:** A `throw` out of an attached callback ends the script with `Error: terminated` and continues after `eval`; mini_racer 0.22.2 crashes with a segmentation fault.
|
|
34
34
|
- **Checks:** Script-enforced crate boundaries, four fenced `unsafe` modules, loom, wire-codec fuzzing, nightly sanitizers and mini_racer differential tests.
|
|
35
35
|
|
|
36
36
|
These numbers compare with mini_racer 0.22.1. See [Benchmarks](#benchmarks) for the method.
|
|
@@ -177,7 +177,7 @@ The public API and require path stay the same. Changes include native installati
|
|
|
177
177
|
|
|
178
178
|
- You're affected if an attached callback reenters its context from another fiber, including inside `Enumerator#next`. mini_racer_rs raises `ThreadError`; mini_racer allows it.
|
|
179
179
|
|
|
180
|
-
- You're affected if
|
|
180
|
+
- You're affected if an attached callback exits by `throw`, returns from a proc while its method is still running, or receives `Thread#kill`. mini_racer_rs ends the script with `Error: terminated`, then continues the jump after `eval` or `call` returns. In mini_racer 0.22.2, `throw` and `return` cause a segmentation fault. `Thread#kill` gives JavaScript a catchable `Error: Ruby exception`; the script continues, and the thread ends after `eval` returns.
|
|
181
181
|
|
|
182
182
|
- You're affected if JavaScript reads a callback exception's non-ASCII message. mini_racer_rs passes UTF-8, such as `"café"`; mini_racer passes `"café"`.
|
|
183
183
|
|
|
@@ -197,20 +197,20 @@ See [COMPATIBILITY.md](COMPATIBILITY.md) for every difference.
|
|
|
197
197
|
|
|
198
198
|
### Gems that depend on mini_racer
|
|
199
199
|
|
|
200
|
-
If another gem adds `mini_racer`, point Bundler to the repository's shim. This empty `mini_racer` gem is version 0.22.
|
|
200
|
+
If another gem adds `mini_racer`, point Bundler to the repository's shim. This empty `mini_racer` gem is version 0.22.2. It depends on the `mini_racer_rs` version from the same checkout.
|
|
201
201
|
|
|
202
202
|
```ruby
|
|
203
203
|
gem "mini_racer_rs"
|
|
204
204
|
gem "mini_racer", github: "andymai/mini_racer_rs", tag: "vX.Y.Z", glob: "shim/*.gemspec"
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
The repository tests the `path:` form of the shim with rtlcss in `test/consumers/transitive/`. A dependency excluding `mini_racer` 0.22.
|
|
207
|
+
The repository tests the `path:` form of the shim with rtlcss in `test/consumers/transitive/`. A dependency excluding `mini_racer` 0.22.2 cannot use the shim.
|
|
208
208
|
|
|
209
209
|
### Forking servers such as Puma
|
|
210
210
|
|
|
211
211
|
Before forking, evaluate each bundle of 1 MiB or more twice in the master, then dispose those contexts. Use the renderer's exact source text and file name. The second evaluation builds the process-wide V8 code cache. Matching evaluations compile from it, and forked children inherit it. For Babel's 2.3 MB bundle at commit `5e13c1c`, a forked child's first load took 60.8 ms without a parent load. It took 65.5 ms after one load and 25.0 ms after two. These are medians across 5 trials. Prime a `react-rails` app by building its server renderer twice. Children do not use parent contexts. Only the cache carries over.
|
|
212
212
|
|
|
213
|
-
For Ruby's `fork`, `IO.popen("-")`, or `Process.daemon`, mini_racer_rs waits for context runners, pauses its worker pool and waits for running tasks. An async `WebAssembly.compile` in a new default-mode child completes on the child's own pool. On Ubuntu 24.04 with glibc 2.39, 20 of 20 mini_racer children aborted with signal 6 after React rendering; all mini_racer_rs children exited cleanly.
|
|
213
|
+
For Ruby's `fork`, `IO.popen("-")`, or `Process.daemon`, mini_racer_rs waits for context runners, pauses its worker pool and waits for running tasks. An async `WebAssembly.compile` in a new default-mode child completes on the child's own pool. On Ubuntu 24.04 with glibc 2.39, 20 of 20 mini_racer 0.22.1 children aborted with signal 6 after React rendering; all mini_racer_rs children exited cleanly. mini_racer 0.22.2 has the same fork handling. On Fedora, `test/stress/fork_busy.rb` aborted with mini_racer 0.22.2 in 3 of 3 runs, after 5, 14 and 19 forks, when an evaluating parent thread raised `TypeError`. mini_racer_rs completed 300 forks per run on Fedora and Ubuntu.
|
|
214
214
|
|
|
215
215
|
With `mini_racer` 0.22.1, each worker compiles the bundle from source on its first load because it has no code cache.
|
|
216
216
|
|
|
@@ -218,32 +218,33 @@ With `mini_racer` 0.22.1, each worker compiles the bundle from source on its fir
|
|
|
218
218
|
|
|
219
219
|
| Workload | mini_racer 0.22.1 | mini_racer_rs | Ratio |
|
|
220
220
|
|---|---:|---:|---:|
|
|
221
|
-
| Babel transform of a 3 KB JSX component, through ExecJS | 10.1 ms | 5.
|
|
222
|
-
| Terser minify of a 78 KB library, through ExecJS | 51.
|
|
223
|
-
| React server render of 1,000 items (17 KB of HTML), through ExecJS |
|
|
224
|
-
| React in a new context: load the bundle and render 1,000 items, through ExecJS | 11.
|
|
225
|
-
| Handlebars render of 50 rows, through `Context#call` | 49.
|
|
226
|
-
| Autoprefixer on Bootstrap's 280 KB stylesheet, through ExecJS | 26.
|
|
227
|
-
| MUI dashboard server render of 200 rows and 299 icons (469 KB of HTML), through ExecJS |
|
|
228
|
-
| MUI in a new context: load the 8.2 MB bundle and render once, through ExecJS |
|
|
221
|
+
| Babel transform of a 3 KB JSX component, through ExecJS | 10.1 ms | 5.1 ms | 2.0x |
|
|
222
|
+
| Terser minify of a 78 KB library, through ExecJS | 51.4 ms | 50.9 ms | 1.0x |
|
|
223
|
+
| React server render of 1,000 items (17 KB of HTML), through ExecJS | 192 µs | 182 µs | 1.1x |
|
|
224
|
+
| React in a new context: load the bundle and render 1,000 items, through ExecJS | 11.8 ms | 11.8 ms | 1.0x |
|
|
225
|
+
| Handlebars render of 50 rows, through `Context#call` | 49.0 µs | 34.7 µs | 1.4x |
|
|
226
|
+
| Autoprefixer on Bootstrap's 280 KB stylesheet, through ExecJS | 26.2 ms | 23.8 ms | 1.1x |
|
|
227
|
+
| MUI dashboard server render of 200 rows and 299 icons (469 KB of HTML), through ExecJS | 30.3 ms | 29.2 ms | 1.0x |
|
|
228
|
+
| MUI in a new context: load the 8.2 MB bundle and render once, through ExecJS | 166 ms | 104 ms | 1.6x |
|
|
229
229
|
| Load a 44 MB production server rendering bundle into a new context, through ExecJS | 983 ms | 215 ms | 4.6x |
|
|
230
230
|
|
|
231
|
-
Results are medians of 5 runs. Every workload produced identical output in both gems. The eight library workloads use the
|
|
231
|
+
Results are medians of 5 runs. Every workload produced identical output in both gems. The eight library workloads use one run of the Ruby 3.4 extension from the published mini_racer_rs 1.4.0 `x86_64-linux-gnu` gem. The 44 MB production bundle load uses commit `2513a48`. Benchmarks ran on Ruby 3.4.2 and Linux with an AMD Ryzen 9 7950X3D. The governor was `performance`. Both gems were pinned to CPUs 0 through 7.
|
|
232
232
|
|
|
233
|
-
The per-call and memory figures below
|
|
233
|
+
The per-call and memory figures below come from the same run of that extension on the same machine. One watchdog thread serves the whole process, making a call with `timeout:` fast. Scripts of 1 MiB or more use a process-wide V8 code cache. Contexts loading the same large script share one source copy.
|
|
234
234
|
|
|
235
235
|
| Measure | mini_racer 0.22.1 | mini_racer_rs |
|
|
236
236
|
|---|---:|---:|
|
|
237
|
-
| eval round trip | 6.
|
|
238
|
-
| call round trip | 6.
|
|
239
|
-
| callback round trip | 6.
|
|
240
|
-
| call on a context with `timeout:` | 20.
|
|
237
|
+
| eval round trip | 6.76 µs | 1.14 µs |
|
|
238
|
+
| call round trip | 6.45 µs | 0.75 µs |
|
|
239
|
+
| callback round trip | 6.06 µs | 1.11 µs |
|
|
240
|
+
| call on a context with `timeout:` | 20.50 µs | 0.78 µs |
|
|
241
|
+
| call inside `MiniRacerRs.timeout` (mini_racer: on a context with `timeout:`) | 20.61 µs | 0.85 µs |
|
|
241
242
|
| Babel inside V8 | 10.3 ms | 5.3 ms |
|
|
242
|
-
| startup plus Babel | 44.
|
|
243
|
-
| context holding Babel | 28.5 MB | 15.
|
|
244
|
-
| context holding the 8.2 MB MUI bundle | 110 MB |
|
|
243
|
+
| startup plus Babel | 44.3 ms | 13.2 ms |
|
|
244
|
+
| context holding Babel | 28.5 MB | 15.0 MB |
|
|
245
|
+
| context holding the 8.2 MB MUI bundle | 110 MB | 43 MB |
|
|
245
246
|
| context holding the 44 MB production bundle, at commit `2513a48` before sources were shared | 301 MB | 136 MB |
|
|
246
|
-
| peak resident memory with 20,000 contexts left to Ruby's garbage collector | 2,
|
|
247
|
+
| peak resident memory with 20,000 contexts left to Ruby's garbage collector | 2,910 MB | 106 MB |
|
|
247
248
|
|
|
248
249
|
```sh
|
|
249
250
|
bundle exec ruby bench/run.rb --cpus 0-7
|
|
@@ -256,7 +257,7 @@ bundle exec ruby bench/run.rb --cpus 0-7
|
|
|
256
257
|
|
|
257
258
|
| Engine | Done | Planned | Deviation |
|
|
258
259
|
|---|---|---|---|
|
|
259
|
-
| CRuby | 54 | 0 |
|
|
260
|
+
| CRuby | 54 | 0 | 26 |
|
|
260
261
|
| TruffleRuby | 58 | 0 | 0 |
|
|
261
262
|
|
|
262
263
|
See [COMPATIBILITY.md](COMPATIBILITY.md).
|
|
@@ -282,7 +283,7 @@ mini_racer_rs uses the `v8` crate, rusty_v8 152.2.0, with magnus and rb-sys Ruby
|
|
|
282
283
|
|
|
283
284
|
A waiting Ruby thread spins with the GVL held, then without it. It then parks with the GVL released. After enough consecutive answers arrive beyond the spin budget, that context skips spinning and parks at once until an answer arrives within the budget. Under a fiber scheduler, only the waiting fiber parks. Values use V8's serialization format and decode directly into Ruby objects. There is no intermediate tree. Repeated objects keep their identity.
|
|
284
285
|
|
|
285
|
-
One watchdog thread per process enforces every context's `timeout:`.
|
|
286
|
+
One watchdog thread per process enforces every context's `timeout:`. Fork behavior is covered in [Forking servers such as Puma](#forking-servers-such-as-puma), and the protocol, including the worker pool that runs V8's tasks, is documented in [ARCHITECTURE.md](ARCHITECTURE.md#forks).
|
|
286
287
|
|
|
287
288
|
The implementation has five crates:
|
|
288
289
|
|
|
@@ -300,24 +301,24 @@ The release pipeline runs the full suites for every released extension.
|
|
|
300
301
|
|
|
301
302
|
mini_racer_rs does not:
|
|
302
303
|
|
|
303
|
-
- Run on Windows.
|
|
304
|
+
- Run on Windows. Supported platforms are listed in [STABILITY.md](STABILITY.md#platforms-rubies-and-v8).
|
|
304
305
|
|
|
305
306
|
- Provide Node.js APIs. JavaScript runs in plain V8 without file system, network, or process access. It can reach only Ruby callables you `attach`.
|
|
306
307
|
|
|
307
308
|
- Work reliably without Bundler. RubyGems may activate the original mini_racer first.
|
|
308
309
|
|
|
309
|
-
- Satisfy dependencies pinning `mini_racer` versions other than 0.22.
|
|
310
|
+
- Satisfy dependencies pinning `mini_racer` versions other than 0.22.2. This includes minibars and its `~> 0.6.4` requirement.
|
|
310
311
|
|
|
311
|
-
- Extend the `MiniRacer` API beyond mini_racer 0.22.
|
|
312
|
+
- Extend the `MiniRacer` API beyond mini_racer 0.22.2. [COMPATIBILITY.md](COMPATIBILITY.md) records deliberate differences.
|
|
312
313
|
|
|
313
|
-
Supported
|
|
314
|
+
Supported Rubies include TruffleRuby through mini_racer's unchanged TruffleRuby backend, as listed in [STABILITY.md](STABILITY.md#platforms-rubies-and-v8).
|
|
314
315
|
|
|
315
316
|
## Documentation
|
|
316
317
|
|
|
317
318
|
| Document | Covers |
|
|
318
319
|
|---|---|
|
|
319
320
|
| [ARCHITECTURE.md](ARCHITECTURE.md) | Crates, a call end to end, values, termination and limits, callbacks, promises and V8's tasks, snapshots, code cache, shared sources, fast calls, source maps, forks, fiber schedulers, rules that keep it safe, and how it is checked. |
|
|
320
|
-
| [COMPATIBILITY.md](COMPATIBILITY.md) | Every public API item and deliberate difference from mini_racer 0.22.
|
|
321
|
+
| [COMPATIBILITY.md](COMPATIBILITY.md) | Every public API item and deliberate difference from mini_racer 0.22.2, with its reason. |
|
|
321
322
|
| [BENCHMARKS.md](BENCHMARKS.md) | Benchmark method and full results. |
|
|
322
323
|
| [STABILITY.md](STABILITY.md) | Versioning, the public API, unstable interfaces, and support policy. |
|
|
323
324
|
| [SECURITY.md](SECURITY.md) | Vulnerability reporting, untrusted JavaScript, and supply-chain controls. |
|
|
@@ -18,7 +18,7 @@ use crate::process::platform::Mode;
|
|
|
18
18
|
use crate::process::{self, platform, watchdog};
|
|
19
19
|
use crate::runner::Start;
|
|
20
20
|
use crate::spin::spin_until;
|
|
21
|
-
use crate::{EngineError,
|
|
21
|
+
use crate::{EngineError, SnapshotBlob, runner};
|
|
22
22
|
|
|
23
23
|
const MIN_RUNNER_STACK_BYTES: usize = 2 << 20;
|
|
24
24
|
const STACK_HEADROOM_BYTES: usize = 1 << 20;
|
|
@@ -414,11 +414,6 @@ impl ContextHandle {
|
|
|
414
414
|
base: Option<SnapshotBlob>,
|
|
415
415
|
host: &mut impl Host,
|
|
416
416
|
) -> Result<Vec<u8>, EngineError> {
|
|
417
|
-
// A warmup from no snapshot would build the read-only heap again, which
|
|
418
|
-
// V8 aborts on once the process has one.
|
|
419
|
-
if base.as_ref().is_some_and(SnapshotBlob::is_empty) {
|
|
420
|
-
return Err(InvalidSnapshot::Empty.into());
|
|
421
|
-
}
|
|
422
417
|
let context = Self::spawn(ContextConfig::default(), host)?;
|
|
423
418
|
let built = context.dispatch(
|
|
424
419
|
DispatchKind::Script,
|