perf(kernel): cache filesystem usage for quota checks; fix WASI hot paths#208
Merged
NathanFlurry merged 1 commit intoJul 2, 2026
Conversation
…aths The WASI syscall dispatch tax (3.1, the biggest known optimization) was dominated by the KERNEL, not the shim: every fd_open/fd_write ran a full filesystem usage scan for quota accounting (~10ms each on a populated VFS), plus redundant WASI post-open stats and per-op fixture churn. - Kernel: filesystem usage is cached and maintained incrementally — old/new size deltas for file writes/pwrite/truncate (path and fd paths), inode deltas for create/remove/symlink; rename and mount/import/snapshot/host-dir events invalidate (overlay copy-up topology is not locally delta-able; invariants documented per mutation path). The cache populates lazily via the RAW filesystem so quota bookkeeping never fires guest-attributable permission checks. - WASI shim: removed redundant path_open create/truncate stat round-trips; per-syscall metrics kept (sub-phase timings) for future attribution. - native-baseline: readdir fixtures marker-cached (setup out of timing); fs_stat_x32 measures identical work on every lane (batching one lane harder than the others distorts the differential — comment documents the quantized sub-ms wasm reading). - Stale DEFAULT_WASM_EXECUTION_TIMEOUT_MS limits-inventory entry removed (constant retired earlier for typed max_fuel + V8 CPU watchdog). Release results (guest = JS lane, wasm lane): - fs_write_small 0.24 -> 0.10ms guest, 25 -> 4ms wasm - fs_write_big 20.5 -> 4.4ms guest, 15 -> 14ms wasm - stat_storm 0.24 -> 0.07ms guest, 12 -> 5ms wasm - readdir_big 10.9 -> 6.1ms guest, 165 -> 14ms wasm (documented floor: the op stats all 1000 entries; fd_readdir itself is ~1ms) - ecosystem: ls_100 vmCmd 918 -> 490ms, git_init_commit 8.9s -> 1.4s Kernel/limits/limits_audit/tls/http2 suites green; git + shell-redirect semantics oracle 20/20; baseline regenerated; bench gate passes.
Member
Author
|
Stack for rivet-dev/secure-exec
Get stack: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The WASI syscall dispatch tax (3.1, the biggest known optimization) was
dominated by the KERNEL, not the shim: every fd_open/fd_write ran a full
filesystem usage scan for quota accounting (~10ms each on a populated VFS),
plus redundant WASI post-open stats and per-op fixture churn.
size deltas for file writes/pwrite/truncate (path and fd paths), inode
deltas for create/remove/symlink; rename and mount/import/snapshot/host-dir
events invalidate (overlay copy-up topology is not locally delta-able;
invariants documented per mutation path). The cache populates lazily via
the RAW filesystem so quota bookkeeping never fires guest-attributable
permission checks.
per-syscall metrics kept (sub-phase timings) for future attribution.
fs_stat_x32 measures identical work on every lane (batching one lane
harder than the others distorts the differential — comment documents the
quantized sub-ms wasm reading).
(constant retired earlier for typed max_fuel + V8 CPU watchdog).
Release results (guest = JS lane, wasm lane):
the op stats all 1000 entries; fd_readdir itself is ~1ms)
Kernel/limits/limits_audit/tls/http2 suites green; git + shell-redirect
semantics oracle 20/20; baseline regenerated; bench gate passes.