@threadedstack/wmd-web 0.1.24 → 0.1.26
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.
- package/README.md +32 -2
- package/RELEASE.json +9 -7
- package/package.json +3 -3
- package/src/boot.js +79 -9
- package/src/build/builder.js +3 -1
- package/src/host/ckpt.js +17 -0
- package/wmdpack.wasm +0 -0
package/README.md
CHANGED
|
@@ -200,6 +200,10 @@ const r2 = await buildImage({ ...builderOptions, context, timeoutMs: 30 * 60_000
|
|
|
200
200
|
- **RAM and vCPUs.** The default is 1536 MiB and 2 vCPUs (`ram`, `cpus`). Small builds and the proxy project in the
|
|
201
201
|
plan fit. A build that compiles a native addon or bundles a large app needed 3072 MiB and 4 vCPUs (plan 10.5); a
|
|
202
202
|
single `RUN` step must finish within `timeoutMs`, since BuildKit resumes from its cache only between steps.
|
|
203
|
+
- Above 1536 MiB the builder boots the flat layout (the guest's RAM in a memory of its own). `ramInMemory0: true`
|
|
204
|
+
(default off; only exactly `true`; also `wb.create` of the test page) keeps a RAM of 1537 to 2048 MiB in memory 0
|
|
205
|
+
instead, with memory 0 at 4 GiB, a heap reserve of 1663 MiB and an IR budget of 831 MiB at 2048 MiB. Above
|
|
206
|
+
2048 MiB it is flat as without the option. Details: "Guests above 1536 MiB" below.
|
|
203
207
|
- **WebKit** builds Go and Node images and the real projects of the plan, but slower: its code space fills and new
|
|
204
208
|
code runs in the interpreter for a while (a `{t:'slow', reason:'webkit-code-space'}` event says so).
|
|
205
209
|
- In WebKit, node in `RUN` steps runs its JavaScript in the interpreter (D-553, `nodeInterpreted`, an
|
|
@@ -2659,8 +2663,34 @@ engines' memory64 limit), passes `WMD_RAM_FLAT=1` to vm.wasm and hands the memor
|
|
|
2659
2663
|
slack (`flatMaxPages`), whatever the guest's RAM. Leave `maxPages` out for such a boot.
|
|
2660
2664
|
- `flatRam: true|false` forces the layout on or off; unset, it is chosen for `--ram` above 1536 when the engine
|
|
2661
2665
|
has memory64 and `allowLargeRam` is not set. Safari has no memory64: the old limit and its message stay.
|
|
2662
|
-
-
|
|
2663
|
-
`
|
|
2666
|
+
- `ramInMemory0: true` (X24, default off): a `--ram` above 1536 MiB and up to the engine's limit
|
|
2667
|
+
(`MEMORY0_RAM_MAX_MIB` in `src/boot.js`: 2048 MiB in Chromium, Firefox and WebKit) keeps its RAM in memory 0,
|
|
2668
|
+
with no `flatRam` or `allowLargeRam`. Above the limit the boot is flat as without the option. `flatRam: true`
|
|
2669
|
+
still wins and `flatRam: false` still means memory 0.
|
|
2670
|
+
- Where to set it. `bootWmd({ ramInMemory0: true })`; the builder's `createBuilder({ ramInMemory0: true })` (see
|
|
2671
|
+
"RAM and vCPUs" in the builder section); the builder test page's `wb.create({ ramInMemory0: true })`; and the
|
|
2672
|
+
page query `?ramInMemory0=1` of `ckpt.html`. In code only the value `true` turns it on (`'false'`, `1`, `'1'`,
|
|
2673
|
+
`0` and `undefined` are off, in `bootWmd`, `createBuilder` and `wb.create` alike). The page query takes only the
|
|
2674
|
+
text `1`.
|
|
2675
|
+
- Memory 0's maximum is the whole 4 GiB (`MEMORY0_SLACK_MIB`). The page option `slack` and a caller's `slackMiB`
|
|
2676
|
+
are ignored for such a boot. A caller that sets `maxPages` itself must ask `memoryMaxPagesFor(args,
|
|
2677
|
+
{ ramInMemory0: true })`; the older `memoryMaxPages(args, slack)` still throws above 1536 MiB.
|
|
2678
|
+
- Memory: memory 0 is a wasm32 shared memory of 4096 MiB after the boot (rows `o1537`, `o2047` and `o2048` of
|
|
2679
|
+
`docs/research/browser-speed-2026-11/x24/check/check.md`, same in three browsers), against 2432 MiB for memory 0
|
|
2680
|
+
of a flat guest (rows `f2048`, `n2048`; its RAM is a second memory of its own).
|
|
2681
|
+
- Heap and translator budget at 2048 MiB with the option: a heap reserve of 1663 MiB (1664 MiB at 2047, 2174 MiB at
|
|
2682
|
+
1537) and an IR budget of 831 MiB (`max_ir_bytes 831 MiB, memory 0 2432 MiB` at start). The flat layout has a
|
|
2683
|
+
reserve of 1535 MiB and an IR budget of 1599 MiB (checked at 3072 MiB). A big build can pass 831 MiB: the native
|
|
2684
|
+
addon build did, once, and the cache reset once and refilled (`docs/research/browser-speed-2026-11/x24-gate2.md`).
|
|
2685
|
+
- A full heap ends the machine with exit 4 and an out-of-memory text. With the option the text says to use a
|
|
2686
|
+
smaller guest RAM or to drop the option, because `slack` cannot give more room.
|
|
2687
|
+
- Real Safari has no memory64 and is told apart by that alone: a WebKit with no memory64 keeps the 1536 MiB limit
|
|
2688
|
+
and its message (proven for Safari 26.5.2: `ram=2048&ramInMemory0=1` is refused, `ram=1536` boots in memory 0). A
|
|
2689
|
+
Safari that gains memory64 would get 2048 MiB with no Safari run to prove it.
|
|
2690
|
+
- The test page `ckpt.html` with no option at 1537 MiB or more and no `flatRam` now boots flat, as `bootWmd` always
|
|
2691
|
+
did for the same call. The old page ended at once with the "more than 1536 MiB" error there.
|
|
2692
|
+
- Checkpoints and restores work as for any guest (proven with the option at 2048 MiB in Chromium, Firefox and WebKit, x24-gate2.md): a checkpoint also holds the RAM memory's written pages (sections
|
|
2693
|
+
`ram-index` and `ram`, header `ramPages`) and restores only into a boot whose RAM memory has the same size. A checkpoint taken in memory 0 is refused by a flat boot and the other way round, with a message that says the RAM layout differs and names the difference (`boot.maxPages`, `WMD_RAM_FLAT`).
|
|
2664
2694
|
- A checkpoint, flat or not, reads only the RAM pages the guest has written (vm.wasm's `vm_touched_map`, a bit per
|
|
2665
2695
|
64 KiB set before the first write): a page never written is not read, so the browser never backs it with memory.
|
|
2666
2696
|
|
package/RELEASE.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmd-web",
|
|
3
3
|
"version": "0.5.1",
|
|
4
|
-
"commit": "
|
|
4
|
+
"commit": "604e733e21a100f0adc1b37b8ae888fa05c297fb",
|
|
5
5
|
"previous": null,
|
|
6
6
|
"decisions": [
|
|
7
7
|
"D-388",
|
|
@@ -59,9 +59,11 @@
|
|
|
59
59
|
"D-554",
|
|
60
60
|
"D-563",
|
|
61
61
|
"D-566",
|
|
62
|
-
"D-567"
|
|
62
|
+
"D-567",
|
|
63
|
+
"D-620",
|
|
64
|
+
"D-627"
|
|
63
65
|
],
|
|
64
|
-
"vmSources": "
|
|
66
|
+
"vmSources": "b08e3d39cdac7fc74c24f9079869672ab01837f9",
|
|
65
67
|
"guest": {
|
|
66
68
|
"arch": "arm64",
|
|
67
69
|
"files": {
|
|
@@ -84,7 +86,7 @@
|
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
"files": {
|
|
87
|
-
"README.md": "
|
|
89
|
+
"README.md": "632db9bd2b8584f6c0df22d00a8eeea6409c0786e9d1633e0cd50e64c16821b9",
|
|
88
90
|
"export-page/coi-sw.js": "0300e670b413cb2e0aae35843fc583546bbf6687df971ab6df41cfa3b0d494d7",
|
|
89
91
|
"export-page/index.html": "f5450c89e63601bbbbffef421f03491b231d1f143070012c1c5315d4b0059f43",
|
|
90
92
|
"export-page/run.css": "b57adf1e76553549c1f89ff157b7973409dedc21889cd3932948cd05b51adc6f",
|
|
@@ -96,8 +98,8 @@
|
|
|
96
98
|
"package.json": "7d43c05047d0a3ea56b4a7709f48a60de32e15c3bdf328d55435c46637981b40",
|
|
97
99
|
"src/base.js": "982f8e46dbb727ec542a494ebdb884ccd19a31ff4e091425b2d1fc01b0d4754a",
|
|
98
100
|
"src/blob.js": "bb2a2f0d87ce236280a7be2f246c926010dfe07f649c27da5e70d8eb5eaf7061",
|
|
99
|
-
"src/boot.js": "
|
|
100
|
-
"src/build/builder.js": "
|
|
101
|
+
"src/boot.js": "65b0e49f4375bdb90d158f392a42bd3983477949551e4635a5eab081345d28d3",
|
|
102
|
+
"src/build/builder.js": "408ea6d0d540b682ff42bae318772b3b1b4dc620a9956c9ab626e490935fb546",
|
|
101
103
|
"src/build/context.js": "d38097c61dbdadc4d41290c010425a4422f499aba473fa2b83f2a5c41e543571",
|
|
102
104
|
"src/build/dockerfile.js": "5957fe3d4ac8ff8b312f980ee04bd1d98ad4373a61f9a33e02f1ff1108b6ea53",
|
|
103
105
|
"src/build/dockerignore.js": "8fc03d09da020f43ea483979b1183891b71d76f012379ab7813838ea0e53c546",
|
|
@@ -127,7 +129,7 @@
|
|
|
127
129
|
"src/host/ckpt-io.js": "3fbe74f0254c597f10d088c85e8ba72725502d86ae4dd8c6d2bf0821a93c873f",
|
|
128
130
|
"src/host/ckpt-point.js": "42bc16b3f754de3cd4e39f37a0feca2ffd8b4231cd72ec32bd6e1ea734c3c8c7",
|
|
129
131
|
"src/host/ckpt-save.js": "e222571033ae74a4439596c5e90e03b2aa9a5516665dd290f8dd243712294523",
|
|
130
|
-
"src/host/ckpt.js": "
|
|
132
|
+
"src/host/ckpt.js": "78471ab78cda37f745cef8df88fabd10361e46bc22545090dbfca84306becc50",
|
|
131
133
|
"src/host/clock.js": "aba6af3a8b1a985ae340892222e4b482d33afe20f5c8b3a4c7403ce87d1e247c",
|
|
132
134
|
"src/host/ctl.js": "ca2ebbb940c9668cb0573c959cd2ff8982f96d58dfdb8dce39d304b89e033dd7",
|
|
133
135
|
"src/host/disk-map.js": "3d7e0d7d488ce25fc6a0e4dc0a9b1c8fc2af96bac1c03491a1d30be392af268b",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadedstack/wmd-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/threadedstack/wmd-releases",
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
|
|
11
11
|
"wmd": {
|
|
12
|
-
"tag": "v0.1.
|
|
13
|
-
"commit": "
|
|
12
|
+
"tag": "v0.1.26",
|
|
13
|
+
"commit": "604e733e21a100f0adc1b37b8ae888fa05c297fb",
|
|
14
14
|
"web": "0.5.1"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
package/src/boot.js
CHANGED
|
@@ -217,6 +217,23 @@ export function upperCapDefault(nav = globalThis.navigator) {
|
|
|
217
217
|
|
|
218
218
|
const fmtMiB = n => (Number.isFinite(n) ? `${Math.round((n / MiB) * 10) / 10} MiB` : 'no cap')
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* The page text of an out-of-memory end. `ramInMemory0` is true when the RAM is in memory 0 with the option of that name and memory 0's
|
|
222
|
+
* maximum is the whole 4 GiB (MEMORY0_SLACK_MIB): `slack` and maxPages cannot give more room there, so the text says a smaller guest RAM or
|
|
223
|
+
* dropping the option (X24). Every other layout gets the one text it always had.
|
|
224
|
+
*/
|
|
225
|
+
export function outOfMemoryText({ memoryBytes, memoryMaxBytes, reason, ramInMemory0 = false }) {
|
|
226
|
+
const head = `out of memory: the emulator used ${fmtMiB(memoryBytes)} of its ${fmtMiB(memoryMaxBytes)} memory maximum and stopped (${reason}); `
|
|
227
|
+
if (ramInMemory0) {
|
|
228
|
+
return (
|
|
229
|
+
head +
|
|
230
|
+
"the option ramInMemory0 keeps the guest's RAM in memory 0 and fixes its maximum at the whole 4 GiB, so there is no more room to give: " +
|
|
231
|
+
'use a smaller guest RAM (--ram), or drop the option ramInMemory0 (the flat layout)'
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
return head + "give it more room above the guest's RAM (bootWmd maxPages, memoryMaxPages(args, slackMiB))"
|
|
235
|
+
}
|
|
236
|
+
|
|
220
237
|
// Host-side endings (vm.exited code < 0; guest exit codes are >= 0).
|
|
221
238
|
export const EXIT_STOPPED = -1 // reason 'stopped' (vm.stop()) or 'aborted' (the AbortSignal)
|
|
222
239
|
export const EXIT_NO_PROGRESS = -2 // the progress watchdog fired
|
|
@@ -254,14 +271,50 @@ export function ramMiB(args, allowLargeRam = false) {
|
|
|
254
271
|
return mib
|
|
255
272
|
}
|
|
256
273
|
|
|
274
|
+
/**
|
|
275
|
+
* X24: the most --ram (MiB) that the option `ramInMemory0` keeps in memory 0, per engine. Above it the boot is what it is
|
|
276
|
+
* today (flat above MAX_BROWSER_RAM_MIB). 'safari' is a WebKit with no memory64 (real Safari, which has no second memory
|
|
277
|
+
* either): its limit stays MAX_BROWSER_RAM_MIB until a real Safari run shows a bigger guest boots (x24-gate2.md, item 8).
|
|
278
|
+
* Numbers: docs/research/browser-speed-2026-11/x24-gate2.md.
|
|
279
|
+
*/
|
|
280
|
+
export const MEMORY0_RAM_MAX_MIB = { blink: 2048, gecko: 2048, webkit: 2048, safari: MAX_BROWSER_RAM_MIB }
|
|
281
|
+
/** memory 0's maximum, in MiB of slack above vm.wasm's minimum and the RAM, when the option is on: the whole 4 GiB. */
|
|
282
|
+
export const MEMORY0_SLACK_MIB = 4096
|
|
283
|
+
/** The most pages memory 0 can have (4 GiB): memory 0's maximum when the option is on. */
|
|
284
|
+
const MEMORY0_MAX_PAGES = 65536
|
|
285
|
+
|
|
286
|
+
/** The limit of MEMORY0_RAM_MAX_MIB for this browser. */
|
|
287
|
+
export function memory0RamLimit(nav = globalThis.navigator, mem64 = haveMemory64()) {
|
|
288
|
+
const e = engineOf(nav)
|
|
289
|
+
return e === 'webkit' && !mem64 ? MEMORY0_RAM_MAX_MIB.safari : MEMORY0_RAM_MAX_MIB[e]
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* X24: whether the option `o.ramInMemory0` (default off) puts this boot's RAM in memory 0 although it is above
|
|
294
|
+
* MAX_BROWSER_RAM_MIB: true only when the option is true, flatRam is not forced on and --ram is above
|
|
295
|
+
* MAX_BROWSER_RAM_MIB and at most the engine's limit. With the option absent it is always false.
|
|
296
|
+
*/
|
|
297
|
+
export function wantsRamInMemory0(args, o = {}, nav = globalThis.navigator, mem64 = haveMemory64()) {
|
|
298
|
+
if (o.ramInMemory0 !== true || o.flatRam === true) return false
|
|
299
|
+
let mib = 0
|
|
300
|
+
try {
|
|
301
|
+
mib = ramMiB(args, true)
|
|
302
|
+
} catch {
|
|
303
|
+
return false // ramMiB reports the bad value
|
|
304
|
+
}
|
|
305
|
+
return mib > MAX_BROWSER_RAM_MIB && mib <= memory0RamLimit(nav, mem64)
|
|
306
|
+
}
|
|
307
|
+
|
|
257
308
|
/** Memory 0 of a flat guest besides vm.wasm's own minimum: the boot stand-in for the start of RAM (vm/ram.h VM_RAM_LOW_FLAT). */
|
|
258
309
|
export const FLAT_STAGE_MIB = 512
|
|
259
310
|
|
|
260
311
|
/**
|
|
261
312
|
* Whether a boot with these args keeps guest RAM in a memory64 of its own (host/ram-mem.js): o.flatRam when it
|
|
262
|
-
* is a boolean, else when --ram is above MAX_BROWSER_RAM_MIB, allowLargeRam is not set and the engine has memory64
|
|
313
|
+
* is a boolean, else when --ram is above MAX_BROWSER_RAM_MIB, allowLargeRam is not set and the engine has memory64 and
|
|
314
|
+
* (X24) o.ramInMemory0 does not keep it in memory 0. `nav` and `mem64` are the browser and its memory64 support
|
|
315
|
+
* (defaults: this one); tests pass others.
|
|
263
316
|
*/
|
|
264
|
-
export function wantsFlatRam(args, o = {}) {
|
|
317
|
+
export function wantsFlatRam(args, o = {}, nav = globalThis.navigator, mem64 = haveMemory64()) {
|
|
265
318
|
if (o.flatRam === false) return false
|
|
266
319
|
let mib = 0
|
|
267
320
|
try {
|
|
@@ -271,10 +324,11 @@ export function wantsFlatRam(args, o = {}) {
|
|
|
271
324
|
}
|
|
272
325
|
if (!mib) return false
|
|
273
326
|
if (o.flatRam === true) {
|
|
274
|
-
if (!
|
|
327
|
+
if (!mem64) throw new Error('flatRam: this browser has no shared 64-bit memory (WebAssembly memory64)')
|
|
275
328
|
return true
|
|
276
329
|
}
|
|
277
|
-
return
|
|
330
|
+
if (wantsRamInMemory0(args, o, nav, mem64)) return false // X24: the option, up to the engine's limit
|
|
331
|
+
return mib > MAX_BROWSER_RAM_MIB && o.allowLargeRam !== true && mem64
|
|
278
332
|
}
|
|
279
333
|
|
|
280
334
|
/** The memory 0 maximum, in pages, of a flat guest: vm.wasm's minimum, the boot stand-in and heap slack. */
|
|
@@ -370,6 +424,17 @@ export function browserEnv(env, nav = globalThis.navigator, fused = fmaFuses())
|
|
|
370
424
|
return add.length ? [...env, ...add] : env
|
|
371
425
|
}
|
|
372
426
|
|
|
427
|
+
/**
|
|
428
|
+
* The memory 0 maximum (pages) of a boot that keeps its RAM in memory 0, as bootWmd chooses it: memoryMaxPages with
|
|
429
|
+
* `slackMiB` (default 1024), and with the option `o.ramInMemory0` on for this --ram, the whole 4 GiB and RAM above
|
|
430
|
+
* MAX_BROWSER_RAM_MIB accepted. Option absent: exactly memoryMaxPages(args, slackMiB, o.allowLargeRam).
|
|
431
|
+
*/
|
|
432
|
+
export function memoryMaxPagesFor(args, o = {}, slackMiB = 1024, nav = globalThis.navigator, mem64 = haveMemory64()) {
|
|
433
|
+
return wantsRamInMemory0(args, o, nav, mem64)
|
|
434
|
+
? memoryMaxPages(args, MEMORY0_SLACK_MIB, true)
|
|
435
|
+
: memoryMaxPages(args, slackMiB, o.allowLargeRam)
|
|
436
|
+
}
|
|
437
|
+
|
|
373
438
|
/** Pages the shared memory must be able to grow to for a given --ram (MiB). */
|
|
374
439
|
export function memoryMaxPages(args, slackMiB = 1024, allowLargeRam = false) {
|
|
375
440
|
const ramMiB_ = ramMiB(args, allowLargeRam)
|
|
@@ -456,6 +521,8 @@ export function diskArgs(args, disk) {
|
|
|
456
521
|
* @param {number} [o.pool] Workers started up front (default 4)
|
|
457
522
|
* @param {number} [o.spare] idle Workers kept in reserve (default 2)
|
|
458
523
|
* @param {boolean} [o.allowLargeRam] accept --ram above MAX_BROWSER_RAM_MIB (1536; W28)
|
|
524
|
+
* @param {boolean} [o.ramInMemory0] X24 (default off): --ram above 1536 MiB and up to MEMORY0_RAM_MAX_MIB of the engine keeps its RAM in memory 0
|
|
525
|
+
* (memory 0's maximum is 4 GiB), with no flatRam or allowLargeRam; above the limit the boot is as without it
|
|
459
526
|
* @param {number} [o.maxPages] shared memory maximum, in 64 KiB pages
|
|
460
527
|
* @param {URL|string} [o.workerUrl]
|
|
461
528
|
* @param {(text:string)=>void} [o.onStdout]
|
|
@@ -561,8 +628,8 @@ export async function bootWmd(o) {
|
|
|
561
628
|
// own. Chosen when --ram is above MAX_BROWSER_RAM_MIB and the engine has memory64 (o.flatRam forces it on or off);
|
|
562
629
|
// without it such a --ram is the error it was.
|
|
563
630
|
const flatRam = wantsFlatRam(o.args, o)
|
|
564
|
-
if (!flatRam) ramMiB(o.args, o.allowLargeRam) // a bad or too big --ram is a clear error before anything is downloaded
|
|
565
|
-
const maximum = o.maxPages || (flatRam ? flatMaxPages(o.args) :
|
|
631
|
+
if (!flatRam) ramMiB(o.args, o.allowLargeRam || wantsRamInMemory0(o.args, o)) // a bad or too big --ram is a clear error before anything is downloaded
|
|
632
|
+
const maximum = o.maxPages || (flatRam ? flatMaxPages(o.args) : memoryMaxPagesFor(o.args, o))
|
|
566
633
|
if (flatRam) env.push('WMD_RAM_FLAT=1')
|
|
567
634
|
const ramMem = flatRam ? createRamMemory(ramMiB(o.args, true)) : null
|
|
568
635
|
/** The RAM memory's pages (0: the RAM is in memory 0). A checkpoint of a flat guest also holds its RAM memory's pages (sections ram-index, ram). */
|
|
@@ -1302,9 +1369,12 @@ export async function bootWmd(o) {
|
|
|
1302
1369
|
if (!trapped) for (const w of workers) w.terminate()
|
|
1303
1370
|
timings.oom = oom
|
|
1304
1371
|
timings.trap = reason
|
|
1305
|
-
reason =
|
|
1306
|
-
|
|
1307
|
-
|
|
1372
|
+
reason = outOfMemoryText({
|
|
1373
|
+
memoryBytes: timings.memoryBytes,
|
|
1374
|
+
memoryMaxBytes: timings.memoryMaxBytes,
|
|
1375
|
+
reason,
|
|
1376
|
+
ramInMemory0: !flatRam && wantsRamInMemory0(o.args, o) && maximum === MEMORY0_MAX_PAGES, // X24: the whole 4 GiB, no room to give
|
|
1377
|
+
})
|
|
1308
1378
|
emitErr(`\n[wmd-web] ${reason}\n`)
|
|
1309
1379
|
}
|
|
1310
1380
|
}
|
package/src/build/builder.js
CHANGED
|
@@ -396,6 +396,7 @@ function aborted(signal) {
|
|
|
396
396
|
* the packs of an {index, packs} or a store hit must match the index's layer digests
|
|
397
397
|
* @param {{url: string, protocol?: 'wisp'}} o.relay the guest's network
|
|
398
398
|
* @param {number} [o.ram] MiB (default 1536)
|
|
399
|
+
* @param {boolean} [o.ramInMemory0] X24 (default off; only exactly true turns it on): a RAM above 1536 MiB up to the engine's limit (boot.js MEMORY0_RAM_MAX_MIB) stays in memory 0, not flat; above it, flat as today
|
|
399
400
|
* @param {number} [o.cpus] default 2
|
|
400
401
|
* @param {{namespace: string, mib?: number}|false} o.disk BuildKit's storage in OPFS (default 10240 MiB); false: memory
|
|
401
402
|
* @param {string|Uint8Array} o.converter wmdpack.wasm
|
|
@@ -568,7 +569,8 @@ export async function createBuilder(o) {
|
|
|
568
569
|
vmUrl: o.vmUrl,
|
|
569
570
|
files: o.files,
|
|
570
571
|
args,
|
|
571
|
-
|
|
572
|
+
// X24: with o.ramInMemory0 === true (boot.js's rule: only exactly true) a RAM above 1536 MiB up to the engine's limit stays in memory 0 (boot.js decides); above it, flat
|
|
573
|
+
...(o.ramInMemory0 === true ? { ramInMemory0: true } : ram > 1536 ? { flatRam: true } : {}),
|
|
572
574
|
...(disk ? { disk } : {}),
|
|
573
575
|
onStderr: s => {
|
|
574
576
|
stderr = (stderr + s).slice(-16384)
|
package/src/host/ckpt.js
CHANGED
|
@@ -287,6 +287,19 @@ export function bootDescDiff(a, b) {
|
|
|
287
287
|
return out.slice(0, 6).join('; ')
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
/**
|
|
291
|
+
* X24: whether two boot descriptions differ only in the RAM layout: the environment entry WMD_RAM_FLAT=1 (RAM in a memory of its own) and
|
|
292
|
+
* the memory maximum (maxPages) are the whole difference. False when they are equal, when either is missing, or when anything else differs.
|
|
293
|
+
*/
|
|
294
|
+
export function bootDescLayoutOnly(a, b) {
|
|
295
|
+
if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false
|
|
296
|
+
const rest = d => {
|
|
297
|
+
const { maxPages, ...o } = d
|
|
298
|
+
return JSON.stringify({ ...o, env: Array.isArray(d.env) ? d.env.filter(e => e !== 'WMD_RAM_FLAT=1') : d.env })
|
|
299
|
+
}
|
|
300
|
+
return JSON.stringify(a) !== JSON.stringify(b) && rest(a) === rest(b)
|
|
301
|
+
}
|
|
302
|
+
|
|
290
303
|
/** The part of the fit check that needs only vm.wasm's key: a snapshot from another vm.wasm is refused before anything else is read of it. */
|
|
291
304
|
export function checkVmKeyFits(h, vmKey) {
|
|
292
305
|
if (h.format !== FORMAT_VERSION) throw new CheckpointError('version', `checkpoint format ${h.format}; this build restores format ${FORMAT_VERSION}`)
|
|
@@ -302,6 +315,10 @@ export function checkCheckpointFits(h, { vmKey, bootKey, bootDesc, maxPages, ram
|
|
|
302
315
|
}
|
|
303
316
|
if (h.bootKey !== bootKey) {
|
|
304
317
|
const diff = bootDescDiff(h.bootDesc, bootDesc)
|
|
318
|
+
// X24: only the RAM layout differs (memory 0 or a memory of its own, or the memory maximum): say so, not "a different kernel ..."
|
|
319
|
+
if (diff && bootDescLayoutOnly(h.bootDesc, bootDesc)) {
|
|
320
|
+
throw new CheckpointError('stale', `this checkpoint was taken with a different RAM layout than this boot (the guest's RAM in memory 0 or in a memory of its own, or another memory maximum); restore it only with the same layout: the same ramInMemory0, flatRam and allowLargeRam settings as when it was taken (differs: ${diff})`)
|
|
321
|
+
}
|
|
305
322
|
throw new CheckpointError('stale', `this checkpoint was taken by a boot with a different kernel, initramfs, command line, environment, image layers or bundle files than this one; restore it only into the same configuration${diff ? ` (differs: ${diff})` : ''}`)
|
|
306
323
|
}
|
|
307
324
|
if (h.memPages > maxPages) throw new CheckpointError('stale', `this checkpoint's memory is ${h.memPages} pages and this boot's maximum is ${maxPages}`)
|
package/wmdpack.wasm
CHANGED
|
Binary file
|