@ai-ecoverse/slicc-kernel 1.189.1 → 1.189.2

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 CHANGED
@@ -317,7 +317,7 @@ The Worker needs a Worker Loader binding (`worker_loaders`) and a SQLite-backed
317
317
  - **Not supported:** `dlopen` and anything else that compiles wasm at run time, JS programs (`"abi": "js"`), and an imports module without `createAsyncImports` (126, `the imports module exports no createAsyncImports function, which the async process host calls`). Each fails with an errno or a message, never a hang.
318
318
  - **Imports modules:** a WASI command's [imports module](#program-imports) is one of its Dynamic Worker's modules, beside the wasm, so it is loaded without `import()` and without the embedder. The Dynamic Worker is the program's and that module's: a command whose module differs (another package, or the file changed) gets a Dynamic Worker of its own. The module is evaluated when the Dynamic Worker starts and shared by the processes in it, so it must be one self-contained file (no `import`), and state at its top level is seen by all of them. Its HTTP and its commands go through the process's system calls, so through the kernel's transport; a Dynamic Worker has no network of its own (`globalOutbound: null`). The kernel calls `createAsyncImports(ctx)`, not `createImports`: see [Program imports](#program-imports).
319
319
  - **Program size:** a Dynamic Worker's code (the program's wasm, its imports module, and the 0.5 MB process host) must be under 64 MiB. A larger program fails with status 70 and `Dynamic Worker code size (78982007 bytes) exceeds the maximum allowed size of 67108864 bytes.`, as `gh.wasm` of `@ai-ecoverse/wasi-gh` 2.102.0-2 (78 MB) does, in `wrangler dev` and deployed alike.
320
- - **What the Durable Object keeps of a program:** not its wasm. To start a process, the kernel reads the whole wasm once to compile it, and `kernel.images` then keeps only the program's digest, its initial memory and size, and the paths it was read from (`kernel.images.held`, the bytes it keeps, stays 0). The bytes are needed again only when the Worker Loader starts the program's Dynamic Worker from scratch: the first process of a program, one that spills into another Dynamic Worker, or one after Cloudflare evicted it. That cold start reads the program again through the kernel's file system, from where it was compiled (a mount, the SQLite root, `/node_modules`), and checks it against the digest, so it costs one more read of the program (one more R2 `get` behind a mount whose driver doesn't cache it); a warm start reads nothing. A program whose file is gone by then fails to start with status 127 and `ENOENT: <path> is gone since the kernel compiled it`, and one whose file changed with 126 and `ESTALE: <path> changed since the kernel compiled it`; the next spawn compiles the file again, under a new Dynamic Worker. While a program is read, the object holds it once, plus one chunk of the mount's `maxIo` (8 MiB) while a mount's reads are gathered, plus whatever copy the driver keeps, and only until the Dynamic Worker has its code. Measured on a deployed Durable Object with 128 MB: eight programs of 20 MiB, one after another, all run; before, the object kept every one, and the sixth ended the object (Cloudflare error 1101), which came back cold with none of them. What the object does keep for the kernel's life is small: the TLS engine (320 KB of wasm, compiled with the Worker, and one instance with 4 MiB of memory to start), the process host's source (0.5 MB), and the imports module of each running process. A fork's memory snapshot stays in the parent's Dynamic Worker, and the object only passes it to the child in pieces.
320
+ - **What the Durable Object keeps of a program:** not its wasm. To start a process, the kernel reads the whole wasm once to compile it, and `kernel.images` then keeps only the program's digest, its initial memory and size, and the paths it was read from (`kernel.images.held`, the bytes it keeps, stays 0). The bytes are needed again only when the Worker Loader starts the program's Dynamic Worker from scratch: the first process of a program, one that spills into another Dynamic Worker, or one after Cloudflare evicted it. That cold start reads the program again through the kernel's file system, from where it was compiled (a mount, the SQLite root, `/node_modules`), and checks it against the digest, so it costs one more read of the program (one more R2 `get` behind a mount whose driver doesn't cache it); a warm start reads nothing. While a process of a program runs, the kernel holds the program's file as an open file is held, so a fork (bash's subshells and pipelines) that needs a cold Dynamic Worker still gets the program it is a copy of, as on Linux: after an `rm` or `unlink` of the file, or a `mv` of another file over it, the kernel keeps the old file aside under the root's (or the mount's) hidden `.slicc-unlinked` until the last process of that program ends, and reads it from there; after a `mv` of the file elsewhere, it reads it at its new name. A new exec of the path compiles whatever is there now. The Durable Object keeps no bytes for this, only the file. The bytes cannot come from the parent's Dynamic Worker instead: a Dynamic Worker has its program only as a compiled module, which can be neither read back as bytes nor handed to another isolate, and Workers refuses to compile wasm at run time. So a cold fork costs what any cold start costs, one read of the program, from the kept file. A few changes can't be held: a write into the file itself (`cp` or `cat >` over it, `kernel.writeFile`), where Linux refuses the write with `ETXTBSY`, and a change underneath a read-only mount, an `fsa` or `hostfs` folder, or an in-process mount whose driver serves other bytes. Programs on a read-only mount aren't held at all, since the kernel can't change them. After such a change, a start that needs a cold Dynamic Worker fails, never hangs: with status 127 and `ENOENT: <path> is gone since the kernel compiled it` when the file is gone, or 126 and `ESTALE: <path> changed since the kernel compiled it` when it changed. A warm Dynamic Worker still runs the old program. The next spawn of the path compiles the file again, under a new Dynamic Worker. Cloudflare evicting a Dynamic Worker changes none of this, since the program is never read back from one. While a program is read, the object holds it once, plus one chunk of the mount's `maxIo` (8 MiB) while a mount's reads are gathered, plus whatever copy the driver keeps, and only until the Dynamic Worker has its code. Measured on a deployed Durable Object with 128 MB: eight programs of 20 MiB, one after another, all run; before, the object kept every one, and the sixth ended the object (Cloudflare error 1101), which came back cold with none of them. What the object does keep for the kernel's life is small: the TLS engine (320 KB of wasm, compiled with the Worker, and one instance with 4 MiB of memory to start), the process host's source (0.5 MB), and the imports module of each running process. A fork's memory snapshot stays in the parent's Dynamic Worker, and the object only passes it to the child in pieces.
321
321
  - **Memory:** a Dynamic Worker has 128 MB. A program whose wasm memory starts above that cannot run (`python.wasm` declares 160 MiB). Processes of one program share a Dynamic Worker up to the budget and then spill into another; at most 8 Dynamic Workers run at once, and a spawn beyond that waits, then fails with `EAGAIN`, which bash retries. A Dynamic Worker that outgrows its limit is ended by Cloudflare: its processes exit with status 70 and the kernel carries on.
322
322
  - **CPU and signals:** a process that computes for 30 s without a system call is ended by Cloudflare. Nothing can interrupt it sooner: a signal, `SIGKILL` included, is seen at the process's next system call.
323
323
  - **Clocks:** inside a Workers request the clock stands still while code computes. `time` and CPU accounting are wrong, and a timed wait that follows a long computation in the same process can end early by that computation's length.
@@ -1358,7 +1358,7 @@ function createParentRefreshCount() {
1358
1358
  }
1359
1359
 
1360
1360
  // src/version.ts
1361
- var KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
1361
+ var KERNEL_VERSION = true ? "1.189.2" : "0.0.0-dev";
1362
1362
  var OS_RELEASE = "6.0.0-slicc";
1363
1363
  function procVersion() {
1364
1364
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC