gmux - v0.1.0
    Preparing search index...

    Interface MachineOptions

    interface MachineOptions {
        asyncify?: boolean;
        cmdline: string;
        consoleRing?: boolean;
        countSyscalls?: boolean | ((call: SyscallCall) => void);
        digest?: (
            algorithm:
                | "md5"
                | "sha1"
                | "sha256"
                | "sha512"
                | "sha224"
                | "sha384"
                | "blake2b512",
        ) => HostDigest;
        directFill?: boolean;
        dlMisses?: DlMisses;
        execCache?: boolean
        | "verify";
        fileSync?: (file: SyncedFile) => Promise<void>;
        fuelBudget?: number;
        guarded?: Map<string, Module>;
        inflate?: () => HostInflater;
        initrd: Uint8Array;
        interpret?: (exe: string, libs: string[]) => Module | undefined;
        log?: (line: string) => void;
        maximumInflateBytes?: number;
        maximumPages?: number;
        memory?: Memory;
        now?: () => bigint;
        outbound?: Outbound;
        pageIn?: (page: number, canWait: boolean) => Promise<void> | undefined;
        phase?: (name: string, entering: boolean) => void;
        prefillInstances?: number;
        recycleInstances?: number;
        reenterAfterRestore?: number;
        registry: Map<string, Module>;
        restoreFiles?: SyncedFile[];
        runtime?: HostRuntime;
        sha256: (bytes: Uint8Array) => string;
        sharedKernel?: boolean;
        shareInstances?: boolean;
        stepNs?: bigint;
        syscallCache?: boolean | "verify";
        trace?: boolean;
        vmlinux: Module;
        write?: (text: string) => void;
        yieldEvery?: number;
    }
    Index
    asyncify?: boolean

    the kernel and user modules are asyncified at their park imports (scripts/build-async.sh), so checkpoint() can turn every parked stack into bytes and Machine.restore() can rewind it

    cmdline: string

    the kernel command line; boot without nohz_full (see the technical report)

    consoleRing?: boolean

    whether the kernel queues console output in a ring the host drains (kernel patch 0038): one write for everything queued since the last pump step instead of one per kernel put. Default true; a kernel without the ring puts directly

    countSyscalls?: boolean | ((call: SyscallCall) => void)

    routes every syscall through the host hook, which counts it by number in stats.syscalls; a function is also called for each (before it for the calls that may not return, else after). Exact counts, but every call pays a host crossing, so a run under it is not timed

    digest?: (
        algorithm:
            | "md5"
            | "sha1"
            | "sha256"
            | "sha512"
            | "sha224"
            | "sha384"
            | "blake2b512",
    ) => HostDigest

    a host digest for a program's whole md5, sha1, sha224, sha256, sha384, sha512 or blake2b512 stream (katybug's digest recognizer, __gmux_digest): node:crypto's createHash fits. Without it a program hashes with its own code. A machine with a digest open cannot checkpoint: a host digest has no state to save

    directFill?: boolean

    with syscallCache, fills the cache from a plain import after the kernel's answer instead of routing a miss through the Suspending hook. The router then calls the kernel without a tail call, so a machine that unwinds its stacks cannot use it: combined with asyncify it throws

    dlMisses?: DlMisses

    wasm side modules a process asked for that the registry did not hold, by executable hash. Pass the same map to the next machine to carry the record across runs

    execCache?: boolean | "verify"

    keeps what an exec's stub bytes alone decide, its registry key and the data size it maps, so a repeat exec of the same stub neither hashes nor parses it again. The registry, the caller's euid and the recorded dlopen misses are read on every exec. 'verify' also computes everything each time and counts memo answers it contradicts in stats.execMismatches

    fileSync?: (file: SyncedFile) => Promise<void>

    called when a program fsyncs or fdatasyncs a regular file, with the file as the kernel reads it; the program's call returns once this resolves, so resolve once the bytes are durable. Without it (and without restoreFiles) programs call the kernel directly

    fuelBudget?: number

    loop iterations a user program runs between host yields

    guarded?: Map<string, Module>

    builds of the registry's programs that check every load and store against the kernel's page owner table (scripts/wasm/guard-pass.ts), by the same hash. A task whose effective uid is not 0 runs these, and one with no guarded build for its program cannot run it

    inflate?: () => HostInflater

    a host decoder for the whole raw deflate stream of a program's gzip member (katybug's inflate recognizer, __gmux_digest ops 8 to 13). Without it a program decodes with its own code. The machine keeps the decoded bytes (at most MAX_INFLATE_BYTES a task, and maximumInflateBytes in all) until the program has taken them, and a machine with a stream open cannot checkpoint

    initrd: Uint8Array

    the initramfs the kernel unpacks as its root filesystem (kernel/initramfs.bin)

    interpret?: (exe: string, libs: string[]) => Module | undefined

    the interpreted tier: the module that runs exe with its recorded libs interpreted, or undefined when it cannot take them. Absent, a recorded miss is refused again

    log?: (line: string) => void

    host diagnostics: faults, crashes, and with trace every switch

    maximumInflateBytes?: number

    the most host bytes all open inflate streams of every task may hold together (default 64 MiB, a Free isolate's half). A stream holds whole 1 MiB pieces, so one that has decoded 40 bytes counts 1 MiB; the decoded length is never more than what the streams hold

    maximumPages?: number

    the most 64 KiB pages the machine's memory may grow to (default 2048); the kernel takes it all as RAM

    memory?: Memory

    a memory to boot or restore into instead of a new one, zeroed first; its maximum must equal maximumPages. An evicted machine's memory stays charged to its isolate, so a successor in the same isolate reuses it rather than allocating a second. A memory larger than the machine starts with is declined: the kernel takes everything past its start size as RAM, so this serves restores (a snapshot is full size) and not boots after one

    now?: () => bigint

    the host clock in nanoseconds since the Unix epoch (default Date.now())

    outbound?: Outbound

    the host's end of the machine's outbound connects (kernel patch 0047); without it every connect to an address outside the machine is refused, and a checkpoint resets every stream it holds

    pageIn?: (page: number, canWait: boolean) => Promise<void> | undefined

    called on a software-TLB miss for a page of a program built with scripts/wasm/mmu-pass.ts; a promise parks the task until the page is in place (a lazy restore faulting pages in). With canWait false the program runs outside WebAssembly.promising (its start function, relocations and constructors), so the page must be in place before this returns

    phase?: (name: string, entering: boolean) => void

    a phase's entry and exit (interrupt, unwind, parked), for a host that times them

    prefillInstances?: number

    instances of each recyclable share build made ahead while the pump has nothing to run, up to this many idle per build (and no more than recycleInstances), so an exec after a pause finds one ready. Default 0 (off). Costs about 120 KiB of JS heap per idle instance and, before _start, a region of the machine's memory the size of the largest share build's data. A restored machine makes none, and a checkpoint saves none

    recycleInstances?: number

    the most idle instances kept for each share build (scripts/wasm/share.ts) that no process is using: a finished process's instance goes back and is reset for the next exec of its program (globals, relocations, TLS base, pristine data). 0 turns it off; the default is 8. Needs sharedKernel; nothing pooled is saved by a checkpoint. An asyncified or evacuable share build is pooled too, once its process has ended with no asyncify state or unwinding flag left

    reenterAfterRestore?: number

    milliseconds after Machine.restore at which each restored evacuable program, at its next fuel yield, spills its frames and resumes them in its own instance. A running wasm frame keeps the code it was entered with, so frames a restore rebuilt in freshly compiled code continue in what V8 has optimized since. Once per program; nothing is copied

    registry: Map<string, Module>

    precompiled user programs keyed by the hex SHA-256 of their bytes

    restoreFiles?: SyncedFile[]

    for Machine.restore: files synced after the snapshot was taken, written into the machine at the first syscall any program makes, before that syscall runs

    runtime?: HostRuntime

    the host runtime modules, compiled (scripts/build-router.sh): the syscall router and the statx hit path, required with fileSync, restoreFiles, syscallCache or countSyscalls, and the scheduler core, whose idle table and deadline minimum then run in C over the machine's memory in pages reserved before the kernel boots (without it the same decisions run in TypeScript). A snapshot taken without the core's region restores on the TypeScript scheduler, which picks the same task

    sha256: (bytes: Uint8Array) => string

    the hex SHA-256 of an executable without an exec stub, to find it in registry

    sharedKernel?: boolean

    one vmlinux instance for every task, switching the task's mutable globals at each park and resume; needs a vmlinux that exports them (scripts/export-globals.ts)

    shareInstances?: boolean

    a program made shareable by scripts/wasm/share.ts runs every process on one instance, its bases, stack pointer and globals swapped at each switch (needs sharedKernel; no checkpoints)

    stepNs?: bigint

    how far the kernel's clock moves per scheduling decision when the host clock does not

    syscallCache?: boolean | "verify"

    answers a repeated statx of an absolute path from the host while the kernel's path-query generation (kernel patch 0022) and the task's view are what they were, without entering the kernel. 'verify' asks the kernel every time and counts answers the cache would have got wrong

    trace?: boolean

    log every task switch and release through log

    vmlinux: Module

    the kernel, compiled (kernel/vmlinux.wasm)

    write?: (text: string) => void

    console output, as the kernel writes it

    yieldEvery?: number

    pump steps between macrotask yields, so a frozen host clock can advance