From bc57efbe0414e2b2150f7bdeb741243a8a2c3b15 Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 17:30:07 +0200 Subject: [PATCH 1/4] Port bounded/http to exact Zig 0.17.0 with byte-layout audits --- .github/workflows/native.yml | 13 +-- .github/workflows/windows-runtime-verify.yml | 14 +-- .github/zig-release.json | 32 ++++++ .zig-version | 2 +- AGENTS.md | 2 +- README.md | 10 +- build.zig | 21 ++-- build.zig.zon | 2 +- docs/ARCHITECTURE.md | 2 +- docs/INTERFACES.md | 2 +- docs/OWNERSHIP.md | 2 +- docs/README.md | 2 +- docs/USING.md | 16 +-- docs/read.html | 2 +- examples/embedding/build.zig | 6 +- examples/embedding/build.zig.zon | 2 +- src/api.zig | 4 +- src/http.zig | 101 ++++++++++++++++++- src/server.zig | 19 ++-- src/sys.zig | 2 +- src/transport.zig | 14 +-- src/transport_linux.zig | 2 +- src/transport_macos.zig | 10 +- src/transport_windows.zig | 8 +- tools/compare.py | 2 +- tools/smoke.py | 6 +- tools/verify_linux_ssh.sh | 4 +- tools/verify_windows.py | 12 +-- 28 files changed, 218 insertions(+), 96 deletions(-) create mode 100644 .github/zig-release.json diff --git a/.github/workflows/native.yml b/.github/workflows/native.yml index df8c11a..4325aaf 100644 --- a/.github/workflows/native.yml +++ b/.github/workflows/native.yml @@ -32,11 +32,12 @@ jobs: python3 - <<'PYTHON' import hashlib, json, os, pathlib, platform, tarfile, urllib.request version = pathlib.Path('.zig-version').read_text().strip() - assert version == '0.16.0', 'Expected exact Zig 0.16.0' + assert version == '0.17.0', 'Expected exact Zig 0.17.0' architecture = {'x86_64': 'x86_64', 'arm64': 'aarch64', 'aarch64': 'aarch64'}[platform.machine()] system = {'Linux': 'linux', 'Darwin': 'macos'}[platform.system()] - with urllib.request.urlopen('https://ziglang.org/download/index.json', timeout=30) as response: - artifact = json.load(response)[version][f'{architecture}-{system}'] + metadata = json.loads(pathlib.Path('.github/zig-release.json').read_text()) + assert metadata['version'] == version + artifact = metadata['artifacts'][f'{architecture}-{system}'] assert artifact['tarball'].startswith('https://ziglang.org/') directory = pathlib.Path(os.environ['RUNNER_TEMP']) / 'bounded-http-zig' directory.mkdir() @@ -58,9 +59,9 @@ jobs: packet="$RUNNER_TEMP/bounded-http-native" mkdir -p "$packet" { git rev-parse HEAD; uname -a; zig version; python3 --version; } > "$packet/environment.log" - zig build verify -Doptimize=Debug -j2 --summary all 2>&1 | tee "$packet/debug.log" - zig build verify -Doptimize=ReleaseSafe -j2 --summary all 2>&1 | tee "$packet/release-safe.log" - zig build -Doptimize=ReleaseSafe -j2 2>&1 | tee "$packet/install.log" + zig build verify -Doptimize=debug -j2 --summary all 2>&1 | tee "$packet/debug.log" + zig build verify -Doptimize=safe -j2 --summary all 2>&1 | tee "$packet/release-safe.log" + zig build -Doptimize=safe -j2 2>&1 | tee "$packet/install.log" python3 tests/test_compare.py -v 2>&1 | tee "$packet/comparator.log" for suite in integration inline_integration gather_integration batch_integration arena_lifecycle_integration; do python3 "tests/$suite.py" --timeout 120 --json "$packet/$suite.json" 2>&1 | tee "$packet/$suite.log" diff --git a/.github/workflows/windows-runtime-verify.yml b/.github/workflows/windows-runtime-verify.yml index 681d35a..e600a8f 100644 --- a/.github/workflows/windows-runtime-verify.yml +++ b/.github/workflows/windows-runtime-verify.yml @@ -29,20 +29,16 @@ jobs: - name: Check out the selected revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Install checksum-verified exact Zig 0.16.0 + - name: Install checksum-verified exact Zig 0.17.0 shell: pwsh run: | $ErrorActionPreference = "Stop" $baseline = (Get-Content -Raw ".zig-version").Trim() - if ($baseline -cne "0.16.0") { throw "This gate requires the exact repository 0.16.0 baseline" } - $indexUrl = "https://ziglang.org/download/index.json" + if ($baseline -cne "0.17.0") { throw "This gate requires the exact repository 0.17.0 baseline" } $headers = @{ "User-Agent" = "bounded-http-windows-verification/1" } - $index = Invoke-RestMethod -Uri $indexUrl -Headers $headers -TimeoutSec 30 - $release = $index.PSObject.Properties[$baseline] - if ($null -eq $release) { throw "Official index lacks the requested release" } - $entry = $release.Value.PSObject.Properties["x86_64-windows"] - if ($null -eq $entry) { throw "Official index lacks the native x64 compiler" } - $artifact = $entry.Value + $metadata = Get-Content -Raw .github/zig-release.json | ConvertFrom-Json + if ($metadata.version -cne $baseline) { throw "Compiler metadata version mismatch" } + $artifact = $metadata.artifacts.PSObject.Properties["x86_64-windows"].Value $url = [string] $artifact.tarball $expected = ([string] $artifact.shasum).ToLowerInvariant() if ($url -notmatch '^https://ziglang\.org/' -or $expected -notmatch '^[0-9a-f]{64}$') { diff --git a/.github/zig-release.json b/.github/zig-release.json new file mode 100644 index 0000000..917433a --- /dev/null +++ b/.github/zig-release.json @@ -0,0 +1,32 @@ +{ + "artifacts": { + "aarch64-linux": { + "shasum": "9e8d11661d4ae3bd57702a3832781e23ad151dde5798e16a5ccd503f65234ff8", + "size": "52877280", + "tarball": "https://ziglang.org/download/0.17.0/zig-aarch64-linux-0.17.0.tar.xz" + }, + "aarch64-macos": { + "shasum": "b607e9b9234790a008116ae5bdb71c6243b84b9fb42a53a9e70fde41c06c536a", + "size": "53985220", + "tarball": "https://ziglang.org/download/0.17.0/zig-aarch64-macos-0.17.0.tar.xz" + }, + "x86_64-linux": { + "shasum": "1cbe9df9f27e6b78d14ccbca43b6703a404ef79ef1c463de901d7f088d4e2026", + "size": "57332648", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-linux-0.17.0.tar.xz" + }, + "x86_64-macos": { + "shasum": "4f9a1c5269aa17ebda5e6d3c2b89d6cbf36f7d2b22a0306e9ab98f25f95529c6", + "size": "59317572", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-macos-0.17.0.tar.xz" + }, + "x86_64-windows": { + "shasum": "b5663f69581dcf391293fbf16c06cb80d81d806545ce618b4d0bab7f0eb8c428", + "size": "100268137", + "tarball": "https://ziglang.org/download/0.17.0/zig-x86_64-windows-0.17.0.zip" + } + }, + "signature_verification": "Ed25519 prehashed minisign archive and trusted-comment signatures verified against the official download-page public key", + "signing_key": "RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U", + "version": "0.17.0" +} diff --git a/.zig-version b/.zig-version index 04a373e..c5523bd 100644 --- a/.zig-version +++ b/.zig-version @@ -1 +1 @@ -0.16.0 +0.17.0 diff --git a/AGENTS.md b/AGENTS.md index 69dc1c2..fb4854e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,7 +5,7 @@ Use `bounded-http` for the repository, directory, executable, and HTTP Server to Use `bounded_http` for the Zig package, dependency key, and module. Preserve historical evidence names and the shared `/tmp/zig-http-measurement.lock` path. -Use exact Zig 0.16.0 from `.zig-version`. This standalone M4 implementation is +Use exact Zig 0.17.0 from `.zig-version`. This standalone M4 implementation is informed by `../zigllmwiki`; runnable server code belongs here under `src/` and tests, not copied into wiki pages. Preserve the wiki's source/evidence hierarchy. diff --git a/README.md b/README.md index f98b408..6260387 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Fast by design. Explicit about limits.** -An experimental HTTP/1.1 framework and reference server for **Zig 0.16.0**, built on **native event-driven networking**. +An experimental HTTP/1.1 framework and reference server for **Zig 0.17.0**, built on **native event-driven networking**. | Platform | Native backend | Network progress | | --- | --- | --- | @@ -61,8 +61,8 @@ ReleaseSafe is the preferred experiment mode; assertions remain enabled. ```sh zig version -zig build verify -Doptimize=ReleaseSafe -zig build -Doptimize=ReleaseSafe +zig build verify -Doptimize=safe +zig build -Doptimize=safe ./zig-out/bin/bounded-http --port 8080 --connections 128 ``` @@ -85,7 +85,7 @@ Linux shard listeners and the Windows acceptor receive the same configured addre See the [architecture guide](docs/ARCHITECTURE.md#windows-socket-handoff) and [native shard receipt](reports/2026-09-06-windows-shards.md). -The version must print `0.16.0`. The server prints `READY` to stderr after +The version must print `0.17.0`. The server prints `READY` to stderr after startup. Linux and macOS accept SIGINT or SIGTERM; Windows consoles accept Ctrl-C or Ctrl-Break. `--duration-ms 30000` requests shutdown after a finite run. `--port 0` asks the OS for an available @@ -114,7 +114,7 @@ Debug as well: ```sh python3 tests/integration.py --server zig-out/bin/bounded-http --json .zig-cache/integration.json -zig build verify -Doptimize=Debug +zig build verify -Doptimize=debug ``` For Linux Debug, `build.zig` explicitly selects bundled LLVM/LLD after the native diff --git a/build.zig b/build.zig index 40ae5fe..077c550 100644 --- a/build.zig +++ b/build.zig @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void { @panic("Use exactly the Zig release in .zig-version"); const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - if (optimize == .ReleaseFast or optimize == .ReleaseSmall) { + if (optimize == .fast or optimize == .small) { @panic("This MVP requires Debug or ReleaseSafe so its invariants remain enabled"); } const module = b.addModule("bounded_http", .{ @@ -19,8 +19,8 @@ pub fn build(b: *std.Build) void { // Zig 0.16's native ELF linker rejects. Use the bundled LLVM/LLD path // for Linux Debug only; it matters only when an application links glibc. const exe = b.addExecutable(.{ - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .name = "bounded-http", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), @@ -31,27 +31,28 @@ pub fn build(b: *std.Build) void { }); b.installArtifact(exe); const run = b.addRunArtifact(exe); - if (b.args) |args| run.addArgs(args); + run.addPassthruArgs(); b.step("run", "Run the bounded HTTP experiment").dependOn(&run.step); const compile_only = b.step("check", "Compile the selected target without executing its binaries"); compile_only.dependOn(&exe.step); const verify = b.step("verify", "Compile and test the exact-version MVP"); verify.dependOn(&exe.step); - const format = b.addFmt(.{ .paths = &.{ "build.zig", "build.zig.zon", "src", "examples" }, .check = true }); + const format = b.addFmt(.{ .paths = b.pathList(&.{ "build.zig", "build.zig.zon", "src", "examples" }), .check = true }); verify.dependOn(&format.step); const version = b.addSystemCommand(&.{ "python3", "tools/check_version.py" }); verify.dependOn(&version.step); - const embedding_prefix = b.pathFromRoot(b.fmt(".zig-cache/embedding-{s}", .{@tagName(optimize)})); - const embedding_build = b.addSystemCommand(&.{ b.graph.zig_exe, "build", b.fmt("-Doptimize={s}", .{@tagName(optimize)}), "--prefix", embedding_prefix }); + const embedding_build = b.addSystemCommand(&.{ b.graph.zig_exe, "build", b.fmt("-Doptimize={s}", .{@tagName(optimize)}) }); + embedding_build.addArg("--prefix"); + const embedding_prefix = embedding_build.addOutputDirectoryArg2("embedding", .{ .make_absolute = true }); embedding_build.setCwd(b.path("examples/embedding")); const embedding_name = if (target.result.os.tag == .windows) "embedded-http.exe" else "embedded-http"; - const embedding_check = b.addSystemCommand(&.{ "python3", "tools/check_embedding.py", "--binary", b.pathJoin(&.{ embedding_prefix, "bin", embedding_name }) }); - embedding_check.step.dependOn(&embedding_build.step); + const embedding_check = b.addSystemCommand(&.{ "python3", "tools/check_embedding.py", "--binary" }); + embedding_check.addFileArg2(embedding_prefix.path(b, b.pathJoin(&.{ "bin", embedding_name })), .{ .make_absolute = true }); b.step("example-check", "Compile and exercise the independent embedding project").dependOn(&embedding_check.step); verify.dependOn(&embedding_check.step); const test_step = b.step("test", "Run unit and transport tests"); for ([_][]const u8{ "src/http.zig", "src/api.zig", "src/budget.zig", "src/transport.zig", "src/server.zig", "src/sys.zig" }) |path| { - const tests = b.addTest(.{ .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, .root_module = b.createModule(.{ + const tests = b.addTest(.{ .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .root_module = b.createModule(.{ .root_source_file = b.path(path), .target = target, .optimize = optimize, diff --git a/build.zig.zon b/build.zig.zon index 133bc93..cf0f7d0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,6 +2,6 @@ .name = .bounded_http, .version = "0.1.0", .fingerprint = 0xea644817b8357037, - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .paths = .{ "build.zig", "build.zig.zon", ".zig-version", "src", "tests", "tools", "assets", "docs", "examples", "README.md", "AGENTS.md" }, } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index d2ae92f..a169f23 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -1,7 +1,7 @@ # bounded/http architecture The server provides bounded HTTP/1.1 processing with explicit ownership of memory and network operations. -The current implementation targets exact Zig 0.16.0. +The current implementation targets exact Zig 0.17.0. Linux uses `io_uring`. macOS uses nonblocking sockets and `kqueue`. Windows uses overlapped sockets and an I/O completion port (IOCP), which delivers operation results to the owner. diff --git a/docs/INTERFACES.md b/docs/INTERFACES.md index c896f1e..44ba106 100644 --- a/docs/INTERFACES.md +++ b/docs/INTERFACES.md @@ -1,6 +1,6 @@ # Module contracts -Exact Zig 0.16.0. The maintained parser, server, writer and platform adapters +Exact Zig 0.17.0. The maintained parser, server, writer and platform adapters share the ownership contract in [OWNERSHIP.md](OWNERSHIP.md). ## HTTP parser diff --git a/docs/OWNERSHIP.md b/docs/OWNERSHIP.md index f2ef371..b45437b 100644 --- a/docs/OWNERSHIP.md +++ b/docs/OWNERSHIP.md @@ -2,7 +2,7 @@ This describes the current [server](../src/server.zig), [application API](../src/api.zig), [parser](../src/http.zig) and -[transport selection](../src/transport.zig), using exact Zig 0.16.0. It is an +[transport selection](../src/transport.zig), using exact Zig 0.17.0. It is an experimental execution contract, informed by the [evidence inputs](EVIDENCE.md). The [module contracts](INTERFACES.md) describe the low-level interfaces. diff --git a/docs/README.md b/docs/README.md index 2d8b2a3..40d23a1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -75,7 +75,7 @@ The reader vendors Marked, DOMPurify, and Highlight.js. [The vendor manifest](vendor/manifest.json) pins package versions, archive integrity, and extracted file hashes. Adjacent license files preserve each dependency's license terms. The site uses no external script or stylesheet service. -The Zig highlighting rules follow the exact 0.16.0 tokenizer keywords. +The Zig highlighting rules follow the exact 0.17.0 tokenizer keywords. ## Project names diff --git a/docs/USING.md b/docs/USING.md index 04af22e..d84e96b 100644 --- a/docs/USING.md +++ b/docs/USING.md @@ -1,7 +1,7 @@ # Using bounded/http Use the exported `bounded_http` module to embed the framework in a Zig application. -Use exact Zig 0.16.0, as specified by [.zig-version](../.zig-version). +Use exact Zig 0.17.0, as specified by [.zig-version](../.zig-version). The framework has Linux, macOS, and Windows transport adapters. The [Windows receipt](../reports/2026-09-06-windows-iocp.md) records native verification and its exclusions. @@ -20,12 +20,12 @@ Run these commands from the repository root: ```sh zig version -zig build verify -Doptimize=ReleaseSafe -zig build -Doptimize=ReleaseSafe +zig build verify -Doptimize=safe +zig build -Doptimize=safe ./zig-out/bin/bounded-http --port 8080 --connections 128 --shards 1 ``` -The version command must print `0.16.0`. +The version command must print `0.17.0`. ReleaseSafe preserves assertions and runtime safety checks. The project also supports Debug. The build rejects ReleaseFast and ReleaseSmall. @@ -40,7 +40,7 @@ Windows defaults to one shard. Use `--shards 3` to select three independent IOCP owners with one bounded socket distributor. Only inline execution supports multiple shards. The [handoff guide](ARCHITECTURE.md#windows-socket-handoff) explains ownership, resource bounds, and shutdown. -Use native x64 Zig 0.16.0 for the maintained Windows gate. +Use native x64 Zig 0.17.0 for the maintained Windows gate. The server prints `READY` to stderr after preparing its resources. Request `/plaintext` for the fixed 13-byte `Hello, World!` response. @@ -85,8 +85,8 @@ Run the independent example from its directory: ```sh cd examples/embedding -zig build -Doptimize=ReleaseSafe -zig build run -Doptimize=ReleaseSafe -- --port 8081 --duration-ms 30000 +zig build -Doptimize=safe +zig build run -Doptimize=safe -- --port 8081 --duration-ms 30000 ``` The example replies to GET and HEAD requests on any path. @@ -517,7 +517,7 @@ CPU accounting fields remain `null` where the Windows client cannot measure them | Tool or suite | Purpose | | --- | --- | | `zig build verify` | Check the compiler version, formatting, executable, and registered Zig tests. | -| `zig build check -Dtarget=x86_64-windows -Doptimize=ReleaseSafe` | Cross-compile the Windows executable and Zig tests without running them. | +| `zig build check -Dtarget=x86_64-windows -Doptimize=safe` | Cross-compile the Windows executable and Zig tests without running them. | | [integration suites](../tests) | Exercise framing, bounds, partial progress, batches, cancellation, and shutdown. | | [smoke.py](../tools/smoke.py) | Run a finite verified request smoke experiment. | | [benchmark.py](../tools/benchmark.py) | Check response bodies while measuring a supplied endpoint. | diff --git a/docs/read.html b/docs/read.html index 9b3f6b8..43da31a 100644 --- a/docs/read.html +++ b/docs/read.html @@ -18,7 +18,7 @@ bounded/httpENGINEERING DOCUMENTATION -

ZIG 0.16.0
LINUX + MACOS + WINDOWS

+

ZIG 0.17.0
LINUX + MACOS + WINDOWS

DOCUMENTATION
diff --git a/examples/embedding/build.zig b/examples/embedding/build.zig index 97d7d2f..7f0c849 100644 --- a/examples/embedding/build.zig +++ b/examples/embedding/build.zig @@ -12,13 +12,13 @@ pub fn build(b: *std.Build) void { }); const executable = b.addExecutable(.{ // Linux Debug needs LLVM/LLD for the installed GCC CRT relocations. - .use_llvm = if (target.result.os.tag == .linux and optimize == .Debug) true else null, - .use_lld = if (target.result.os.tag == .linux and optimize == .Debug) true else null, + .use_llvm = if (target.result.os.tag == .linux and optimize == .debug) true else null, + .use_lld = if (target.result.os.tag == .linux and optimize == .debug) true else null, .name = "embedded-http", .root_module = module, }); b.installArtifact(executable); const run = b.addRunArtifact(executable); - if (b.args) |args| run.addArgs(args); + run.addPassthruArgs(); b.step("run", "Run the bounded embedding example").dependOn(&run.step); } diff --git a/examples/embedding/build.zig.zon b/examples/embedding/build.zig.zon index 2fcae91..7f74c7d 100644 --- a/examples/embedding/build.zig.zon +++ b/examples/embedding/build.zig.zon @@ -2,7 +2,7 @@ .name = .http_embedding, .version = "0.1.0", .fingerprint = 0x2b518a77c650986d, - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .dependencies = .{ .bounded_http = .{ .path = "../.." }, }, diff --git a/src/api.zig b/src/api.zig index 1b06e7d..d7d9ec9 100644 --- a/src/api.zig +++ b/src/api.zig @@ -757,7 +757,7 @@ test "extra header validation is transactional and bounded before begin" { try std.testing.expect(!writer.began and writer.buffered == 0); try writer.beginWithHeaders(303, "text/plain", 0, "Location: /next\r\nSet-Cookie: a=1\r\nSet-Cookie: b=2\r\n"); _ = writer.finish(); - try std.testing.expect(std.mem.indexOf(u8, arena[0..writer.buffered], "HTTP/1.1 303 See Other\r\n") != null); + try std.testing.expect(std.mem.find(u8, arena[0..writer.buffered], "HTTP/1.1 303 See Other\r\n") != null); try std.testing.expect(std.mem.endsWith(u8, arena[0..writer.buffered], "Location: /next\r\nSet-Cookie: a=1\r\nSet-Cookie: b=2\r\n\r\n")); writer.release(); writer.open(arena.len - header_reserve_bytes, true, false); @@ -860,7 +860,7 @@ test "draft header aliases copy before storage is reused and preserve repeated f @memset(scratch[fields_at..][0..fields.len], 'x'); try std.testing.expectEqualStrings(content_type, writer.content_type); _ = writer.finish(); - try std.testing.expect(std.mem.indexOf(u8, arena[0..writer.body_start], "Content-Type: application/example\r\n") != null); + try std.testing.expect(std.mem.find(u8, arena[0..writer.body_start], "Content-Type: application/example\r\n") != null); try std.testing.expect(std.mem.endsWith(u8, arena[0..writer.body_start], fields ++ "\r\n")); } diff --git a/src/http.zig b/src/http.zig index 51f5421..9d5987e 100644 --- a/src/http.zig +++ b/src/http.zig @@ -460,7 +460,7 @@ const Lane = @Vector(16, u8); /// is cheaper than the generic slice comparison for these tiny fixed names. pub inline fn fixedEqual(bytes: []const u8, comptime expected: []const u8) bool { if (bytes.len != expected.len) return false; - const Int = std.meta.Int(.unsigned, 8 * expected.len); + const Int = @Int(.unsigned, 8 * expected.len); const actual: Int = @bitCast(bytes[0..expected.len].*); const wanted: Int = @bitCast(expected[0..expected.len].*); return actual == wanted; @@ -476,8 +476,9 @@ inline fn fixedEqualCase(bytes: []const u8, comptime expected: []const u8) bool std.debug.assert(std.ascii.isLower(c) or std.ascii.isDigit(c) or c == '-'); }; if (bytes.len != expected.len) return false; - const Int = std.meta.Int(.unsigned, 8 * expected.len); - const fold: Int = @bitCast([_]u8{0x20} ** expected.len); + const Int = @Int(.unsigned, 8 * expected.len); + const fold_bytes: [expected.len]u8 = @splat(0x20); + const fold: Int = @bitCast(fold_bytes); const actual: Int = @bitCast(bytes[0..expected.len].*); const wanted: Int = @bitCast(expected[0..expected.len].*); return (actual | fold) == wanted; @@ -491,6 +492,7 @@ fn findLineControl(bytes: []const u8, start: usize) ?usize { const lf: Lane = @splat('\n'); while (at + 16 <= bytes.len) : (at += 16) { const lane: Lane = bytes[at..][0..16].*; + // Logical bit order maps lane zero to the least-significant bit. const hits: u16 = @bitCast((lane == cr) | (lane == lf)); if (hits != 0) return at + @ctz(hits); } @@ -878,6 +880,96 @@ test "byte class tables agree with the slow classifiers for every octet" { } } +test "fixed name bit casts agree with scalar byte equality and ASCII folding" { + const Oracle = struct { + fn same(bytes: []const u8, expected: []const u8, fold_case: bool) bool { + if (bytes.len != expected.len) return false; + for (bytes, expected) |actual, wanted| { + if ((if (fold_case) std.ascii.toLower(actual) else actual) != wanted) return false; + } + return true; + } + }; + inline for (.{ "", "a", "get", "host", "close", "http/1.1", "connection", "content-length", "proxy-connection", "transfer-encoding" }) |name| { + var bytes: [name.len]u8 = undefined; + @memcpy(&bytes, name); + try testing.expect(fixedEqual(&bytes, name)); + try testing.expect(!fixedEqual(name ++ "x", name)); + for (0..bytes.len) |at| { + for (0..256) |number| { + bytes[at] = @intCast(number); + try testing.expectEqual(Oracle.same(&bytes, name, false), fixedEqual(&bytes, name)); + } + bytes[at] = name[at]; + } + } + inline for (.{ "", "a", "get", "host", "close", "connection", "content-length", "proxy-connection", "transfer-encoding", "100-continue" }) |name| { + var bytes: [name.len]u8 = undefined; + @memcpy(&bytes, name); + try testing.expect(fixedEqualCase(&bytes, name)); + try testing.expect(!fixedEqualCase(name ++ "x", name)); + for (0..bytes.len) |at| { + for (0..256) |number| { + const byte: u8 = @intCast(number); + // The parser validates field octets before using the folding helper. + if ((byte < 0x20 and byte != '\t') or byte == 0x7f) continue; + bytes[at] = byte; + try testing.expectEqual(Oracle.same(&bytes, name, true), fixedEqualCase(&bytes, name)); + } + bytes[at] = name[at]; + } + } +} + +test "vector delimiter scans agree with scalar indices across lanes starts and tails" { + const Oracle = struct { + fn lineControl(bytes: []const u8, start: usize) ?usize { + for (bytes[start..], start..) |byte, at| { + if (byte == '\r' or byte == '\n') return at; + } + return null; + } + + fn byteIndex(bytes: []const u8, needle: u8) ?usize { + for (bytes, 0..) |byte, at| { + if (byte == needle) return at; + } + return null; + } + + fn compare(bytes: []const u8, start: usize, needle: u8) !void { + try testing.expectEqual(lineControl(bytes, start), findLineControl(bytes, start)); + try testing.expectEqual(byteIndex(bytes[start..], needle), findByte(bytes[start..], needle)); + } + }; + var bytes: [65]u8 = @splat('x'); + const lengths = [_]usize{ 0, 1, 15, 16, 17, 31, 32, 33, 47, 48, 49, 63, 64, 65 }; + for (lengths) |length| { + const prefix = bytes[0..length]; + for (0..length + 1) |start| try Oracle.compare(prefix, start, ':'); + for (0..length) |position| { + for ([_]u8{ '\r', '\n', ':', ' ' }) |needle| { + bytes[position] = needle; + for (0..length + 1) |start| try Oracle.compare(prefix, start, needle); + } + bytes[position] = 'x'; + } + } + for (0..bytes.len) |first| { + for (first + 1..bytes.len) |second| { + bytes[first] = '\r'; + bytes[second] = '\n'; + const starts = [_]usize{ 0, first, first + 1, second, second + 1, bytes.len }; + for (starts) |start| try Oracle.compare(&bytes, start, '\n'); + bytes[first] = ':'; + bytes[second] = ':'; + for (starts) |start| try Oracle.compare(&bytes, start, ':'); + bytes[first] = 'x'; + bytes[second] = 'x'; + } + } +} + test "vectorised line scanning rejects bare CR/LF at every fragment boundary" { // Every CR position and every split must produce the same verdict as the // whole-buffer parse, and a CR must never be rescanned into acceptance. @@ -1042,7 +1134,8 @@ test "transfer coding order and parameters distinguish invalid from unsupported" test "chunk extension line budget bounds incremental scanning" { const head = "POST / HTTP/1.1\r\nHost: x\r\nTransfer-Encoding: chunked\r\n\r\n"; - const wire = head ++ "1;" ++ "a" ** 64 ++ "=x\r\na\r\n0\r\n\r\n"; + const extension: [64]u8 = @splat('a'); + const wire = head ++ "1;" ++ extension ++ "=x\r\na\r\n0\r\n\r\n"; var parser = Parser.init(.{ .max_header_bytes = 64 }); for (0..head.len + 64) |length| try testing.expectEqual(null, try parser.parse(wire[0..length])); try testing.expectError(error.BodyTooLarge, parser.parse(wire[0 .. head.len + 64])); diff --git a/src/server.zig b/src/server.zig index 9d04b2b..d3c5a8d 100644 --- a/src/server.zig +++ b/src/server.zig @@ -244,8 +244,7 @@ pub const Stats = struct { /// Sum counters and take maxima; used when several shards report together. pub fn merge(self: *Stats, other: Stats) void { - inline for (@typeInfo(Stats).@"struct".fields) |field| { - const name = field.name; + inline for (@typeInfo(Stats).@"struct".field_names) |name| { if (comptime std.mem.startsWith(u8, name, "max_")) { @field(self, name) = @max(@field(self, name), @field(other, name)); } else if (comptime std.mem.eql(u8, name, "execution") or std.mem.eql(u8, name, "gather_send") or @@ -265,8 +264,8 @@ pub const Stats = struct { const Phase = enum(u8) { io, ready, running, stream_ready, stream_wait, result }; const SendMode = enum { response, interim, reject }; const Kind = enum(u8) { accept = 1, recv, send, cancel_recv, cancel_send, cancel_accept }; -const accept_token: u64 = @intFromEnum(Kind.accept); -const cancel_accept_token: u64 = @intFromEnum(Kind.cancel_accept); +const accept_token: u64 = @backingInt(Kind.accept); +const cancel_accept_token: u64 = @backingInt(Kind.cancel_accept); const BatchNext = enum { parse, resume_flush, resume_timer, close }; @@ -907,7 +906,7 @@ pub const Server = struct { } fn tokenFor(slot: *const Slot, index: usize, kind: Kind) u64 { - return (@as(u64, slot.generation) << 32) | (@as(u64, index) << 8) | @intFromEnum(kind); + return (@as(u64, slot.generation) << 32) | (@as(u64, index) << 8) | @backingInt(kind); } fn distributeAccepted(self: *Server, socket: transport.Socket) !void { @@ -1047,7 +1046,7 @@ pub const Server = struct { fn onCompletion(self: *Server, completion: transport.Completion) !void { assert(self.stats.live_operations > 0); self.stats.live_operations -= 1; - const kind: Kind = @enumFromInt(@as(u8, @truncate(completion.token))); + const kind: Kind = @fromBackingInt(@as(u8, @truncate(completion.token))); if (kind == .cancel_accept) { assert(self.accept_cancel_pending); self.accept_cancel_pending = false; @@ -1105,7 +1104,7 @@ pub const Server = struct { assert(@as(usize, @intCast(completion.result)) <= slot.send_submitted_bytes); if (@as(usize, @intCast(completion.result)) < slot.send_submitted_bytes) self.stats.short_send_completions += 1; - } else if (slot.send_is_gather and completion.result == -@as(i32, @intFromEnum(c.E.CANCELED))) { + } else if (slot.send_is_gather and completion.result == -@as(i32, @backingInt(c.E.CANCELED))) { self.stats.gather_canceled_completions += 1; } } @@ -1688,13 +1687,13 @@ pub const Server = struct { slot.cancelled.store(true, .release); if (slot.fd >= 0) self.backend.shutdown(slot.fd); if (slot.recv_pending and !slot.recv_cancel_pending) { - const token = (slot.recv_token & ~@as(u64, 255)) | @intFromEnum(Kind.cancel_recv); + const token = (slot.recv_token & ~@as(u64, 255)) | @backingInt(Kind.cancel_recv); try self.backend.cancel(self.recvCancelCell(index), token, self.recvCell(index)); slot.recv_cancel_pending = true; self.operationAdded(); } if (slot.send_pending and !slot.send_cancel_pending) { - const token = (slot.send_token & ~@as(u64, 255)) | @intFromEnum(Kind.cancel_send); + const token = (slot.send_token & ~@as(u64, 255)) | @backingInt(Kind.cancel_send); try self.backend.cancel(self.sendCancelCell(index), token, self.sendCell(index)); if (slot.send_is_gather) { self.stats.gather_cancel_requests += 1; @@ -2442,7 +2441,7 @@ pub const Server = struct { const time = epoch.getDaySeconds(); const weekdays = [_][]const u8{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; const months = [_][]const u8{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - _ = std.fmt.bufPrint(&self.date, "{s}, {d:0>2} {s} {d:0>4} {d:0>2}:{d:0>2}:{d:0>2} GMT", .{ weekdays[(day.day + 4) % 7], @as(u8, month_day.day_index) + 1, months[@intFromEnum(month_day.month) - 1], year_day.year, time.getHoursIntoDay(), time.getMinutesIntoHour(), time.getSecondsIntoMinute() }) catch unreachable; + _ = std.fmt.bufPrint(&self.date, "{s}, {d:0>2} {s} {d:0>4} {d:0>2}:{d:0>2}:{d:0>2} GMT", .{ weekdays[(day.day + 4) % 7], @as(u8, month_day.day_index) + 1, months[@backingInt(month_day.month) - 1], year_day.year, time.getHoursIntoDay(), time.getMinutesIntoHour(), time.getSecondsIntoMinute() }) catch unreachable; self.header_cache.refresh(&self.date); } }; diff --git a/src/sys.zig b/src/sys.zig index c9c6d7f..758ce48 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -40,7 +40,7 @@ fn size(rc: usize) isize { /// The error of a failed call (`rc == -1`), else `.SUCCESS`. pub fn errno(rc: anytype) E { if (!direct) return c.errno(rc); - return if (rc == -1) @enumFromInt(@intFromEnum(last_errno)) else .SUCCESS; + return if (rc == -1) @fromBackingInt(@backingInt(last_errno)) else .SUCCESS; } pub fn socket(domain: c_uint, socket_type: c_uint, protocol: c_uint) c_int { diff --git a/src/transport.zig b/src/transport.zig index dca2d3b..eff5ffa 100644 --- a/src/transport.zig +++ b/src/transport.zig @@ -72,7 +72,7 @@ pub fn listenBound(bind_address: [4]u8, port_number: u16, max_connections: u16, } var address: c.sockaddr.in = .{ .port = std.mem.nativeToBig(u16, port_number), - .addr = @bitCast(bind_address), + .addr = std.mem.readInt(u32, &bind_address, std.lang.Endian.native), }; if (sys.bind(fd, @ptrCast(&address), @sizeOf(@TypeOf(address))) != 0) return error.BindFailed; if (sys.listen(fd, @intCast(max_connections)) != 0) return error.ListenFailed; @@ -86,7 +86,7 @@ pub fn setFlags(fd: Socket, nonblocking: bool) !void { if (nonblocking) { const flags = sys.fcntl(fd, c.F.GETFL, 0); if (flags < 0) return error.SocketFlagsFailed; - const nonblock: u32 = @bitCast(c.O{ .NONBLOCK = true }); + const nonblock: u32 = @backingInt(c.O{ .NONBLOCK = true }); if (sys.fcntl(fd, c.F.SETFL, @intCast(flags | @as(c_int, @intCast(nonblock)))) < 0) return error.SocketFlagsFailed; } } @@ -142,7 +142,7 @@ test "accept cancellation drains target and cancellation acknowledgement separat 11 => { try std.testing.expect(!target); target = true; - try std.testing.expectEqual(-@as(i32, @intFromEnum(c.E.CANCELED)), completion.result); + try std.testing.expectEqual(-@as(i32, @backingInt(c.E.CANCELED)), completion.result); }, 12 => { try std.testing.expect(!cancellation); @@ -212,7 +212,7 @@ test "transport borrows receive and send buffers and accounts for EOF" { 25 => { try std.testing.expect(!canceled_receive); canceled_receive = true; - try std.testing.expectEqual(-@as(i32, @intFromEnum(c.E.CANCELED)), completion.result); + try std.testing.expectEqual(-@as(i32, @backingInt(c.E.CANCELED)), completion.result); }, 26 => { try std.testing.expect(!cancel_acknowledged); @@ -241,7 +241,7 @@ test "wake is coalesced and does not consume a caller completion token" { try backend.cancel(2, 31, 0); const missing = try waitCompletion(&backend); try std.testing.expectEqual(@as(u64, 31), missing.token); - try std.testing.expectEqual(-@as(i32, @intFromEnum(c.E.NOENT)), missing.result); + try std.testing.expectEqual(-@as(i32, @backingInt(c.E.NOENT)), missing.result); } test "cancellation cells are finite and returned completions replenish them" { @@ -301,7 +301,7 @@ test "listener binds the configured IPv4 address and preserves loopback default" defer closeFd(configured.socket); var length: c.socklen_t = @sizeOf(@TypeOf(address)); try std.testing.expectEqual(@as(c_int, 0), sys.getsockname(configured.socket, @ptrCast(&address), &length)); - try std.testing.expectEqual(expected, @as([4]u8, @bitCast(address.addr))); + try std.testing.expectEqualSlices(u8, &expected, std.mem.asBytes(&address.addr)); try std.testing.expect(configured.port != 0); } @@ -309,5 +309,5 @@ test "listener binds the configured IPv4 address and preserves loopback default" defer closeFd(default.socket); var length: c.socklen_t = @sizeOf(@TypeOf(address)); try std.testing.expectEqual(@as(c_int, 0), sys.getsockname(default.socket, @ptrCast(&address), &length)); - try std.testing.expectEqual(std.mem.nativeToBig(u32, 0x7f000001), address.addr); + try std.testing.expectEqualSlices(u8, &.{ 127, 0, 0, 1 }, std.mem.asBytes(&address.addr)); } diff --git a/src/transport_linux.zig b/src/transport_linux.zig index d719707..8ac36d8 100644 --- a/src/transport_linux.zig +++ b/src/transport_linux.zig @@ -197,7 +197,7 @@ pub const Backend = struct { if (op.kind == .accept and result >= 0) { common.configureAccepted(result, false) catch { common.closeFd(result); - result = -@as(i32, @intFromEnum(c.E.IO)); + result = -@as(i32, @backingInt(c.E.IO)); }; } completion.* = .{ .token = op.token, .result = result }; diff --git a/src/transport_macos.zig b/src/transport_macos.zig index 4eae302..d70c536 100644 --- a/src/transport_macos.zig +++ b/src/transport_macos.zig @@ -154,13 +154,13 @@ pub const Backend = struct { if (op.kind == .accept) { common.configureAccepted(value, true) catch { common.closeFd(value); - value = -@as(i32, @intFromEnum(c.E.IO)); + value = -@as(i32, @backingInt(c.E.IO)); }; } self.finish(op, value); } else switch (c.errno(result)) { .AGAIN, .INTR => try self.arm(op), - else => |err| self.finish(op, -@as(i32, @intFromEnum(err))), + else => |err| self.finish(op, -@as(i32, @backingInt(err))), } } @@ -208,7 +208,7 @@ pub const Backend = struct { pub fn cancel(self: *Backend, cell: u32, token: u64, target_cell: u32) !void { assert(cell != target_cell and target_cell < self.operations.len); const cancellation = try self.claim(cell); - var result: i32 = -@as(i32, @intFromEnum(c.E.NOENT)); + var result: i32 = -@as(i32, @backingInt(c.E.NOENT)); const target = &self.operations[target_cell]; if (target.kind != .free and target.result == null) { assert(target.kind != .cancel and target.registered); @@ -221,7 +221,7 @@ pub const Backend = struct { .udata = 0, }); target.registered = false; - self.finish(target, -@as(i32, @intFromEnum(c.E.CANCELED))); + self.finish(target, -@as(i32, @backingInt(c.E.CANCELED))); result = 0; } cancellation.* = .{ .kind = .cancel, .token = token }; @@ -277,7 +277,7 @@ pub const Backend = struct { self.finish(op, -@as(i32, @intCast(event.data))); } else self.attempt(op) catch { // Once admitted, every operation must produce a terminal result. - self.finish(op, -@as(i32, @intFromEnum(c.E.IO))); + self.finish(op, -@as(i32, @backingInt(c.E.IO))); }; } return collected + if (collected < out.len) self.collect(out[collected..]) else @as(usize, 0); diff --git a/src/transport_windows.zig b/src/transport_windows.zig index c2866d5..5757e18 100644 --- a/src/transport_windows.zig +++ b/src/transport_windows.zig @@ -103,7 +103,7 @@ fn negative(code: u32) i32 { 10060 => .TIMEDOUT, else => .IO, }; - return -@as(i32, @intFromEnum(err)); + return -@as(i32, @backingInt(err)); } /// One unassociated socket, after its AcceptEx completion was collected. @@ -222,7 +222,7 @@ pub const Backend = struct { const one: i32 = 1; // No SO_REUSEADDR: Windows interprets that option differently from POSIX. if (win32.setsockopt(listener, ws.SOL.SOCKET, ~@as(i32, ws.SO.REUSEADDR), &one, @sizeOf(i32)) != 0) return error.SocketOptionFailed; - var address: ws.sockaddr.in = .{ .port = std.mem.nativeToBig(u16, port_number), .addr = @bitCast(bind_address) }; + var address: ws.sockaddr.in = .{ .port = std.mem.nativeToBig(u16, port_number), .addr = std.mem.readInt(u32, &bind_address, std.lang.Endian.native) }; if (win32.bind(listener, @ptrCast(&address), @sizeOf(@TypeOf(address))) != 0) return error.BindFailed; if (win32.listen(listener, @intCast(max_connections)) != 0) return error.ListenFailed; var length: i32 = @sizeOf(@TypeOf(address)); @@ -955,7 +955,7 @@ test "IOCP direct and acceptor listeners bind the configured IPv4 address" { var address: ws.sockaddr.in = undefined; var length: i32 = @sizeOf(@TypeOf(address)); try std.testing.expectEqual(@as(i32, 0), win32.getsockname(backend.listener, @ptrCast(&address), &length)); - try std.testing.expectEqual(expected, @as([4]u8, @bitCast(address.addr))); + try std.testing.expectEqualSlices(u8, &expected, std.mem.asBytes(&address.addr)); try std.testing.expect(backend.port() != 0); } var default = if (acceptor) @@ -966,6 +966,6 @@ test "IOCP direct and acceptor listeners bind the configured IPv4 address" { var address: ws.sockaddr.in = undefined; var length: i32 = @sizeOf(@TypeOf(address)); try std.testing.expectEqual(@as(i32, 0), win32.getsockname(default.listener, @ptrCast(&address), &length)); - try std.testing.expectEqual([4]u8{ 127, 0, 0, 1 }, @as([4]u8, @bitCast(address.addr))); + try std.testing.expectEqualSlices(u8, &.{ 127, 0, 0, 1 }, std.mem.asBytes(&address.addr)); } } diff --git a/tools/compare.py b/tools/compare.py index f199ca0..137880a 100644 --- a/tools/compare.py +++ b/tools/compare.py @@ -47,7 +47,7 @@ def validate_framework_ready(server, log): if not is_framework(server): return require('READY ' in log, 'framework READY missing') - require('optimize=ReleaseSafe' in log, 'benchmark requires ReleaseSafe') + require(any(marker in log for marker in ('optimize=safe', 'optimize=ReleaseSafe')), 'benchmark requires ReleaseSafe') def parse_framework_stats(server, exit_code, log): diff --git a/tools/smoke.py b/tools/smoke.py index 645d034..dd9a57c 100644 --- a/tools/smoke.py +++ b/tools/smoke.py @@ -121,7 +121,7 @@ def watchdog(signum, frame): if hasattr(signal, "SIGALRM"): signal.alarm(args.timeout) try: - WIRE.require(binary.is_file(), "build the ReleaseSafe server first: zig build -Doptimize=ReleaseSafe") + WIRE.require(binary.is_file(), "build the ReleaseSafe server first: zig build -Doptimize=safe") receipt["environment"] = environment() receipt["build"].update(binary_sha256=digest(binary), zig_target=(ROOT / ".zig-version").read_text().strip(), @@ -135,8 +135,8 @@ def watchdog(signum, frame): marker = re.search(r"(?:^|\s)optimize=(\S+)", ready) mode = marker.group(1) if marker else None receipt["build"]["optimize"] = mode - WIRE.require(mode == "ReleaseSafe", - "server READY must report optimize=ReleaseSafe; got %r. Rebuild with -Doptimize=ReleaseSafe" % mode) + WIRE.require(mode == "safe", + "server READY must report optimize=safe; got %r. Rebuild with -Doptimize=safe" % mode) for name, route, pipeline in WORKLOADS: remaining = deadline - time.monotonic() - 10 WIRE.require(remaining > 1, "not enough watchdog budget for workload and safe shutdown") diff --git a/tools/verify_linux_ssh.sh b/tools/verify_linux_ssh.sh index 5f72ab2..0d93a88 100755 --- a/tools/verify_linux_ssh.sh +++ b/tools/verify_linux_ssh.sh @@ -27,8 +27,8 @@ COPYFILE_DISABLE=1 tar --no-xattrs --exclude=.git --exclude=.zig-cache \ "$(cat /proc/sys/kernel/io_uring_disabled)" cat /etc/os-release timeout 180 zig build verify --summary all - timeout 180 zig build verify -Doptimize=ReleaseSafe --summary all - timeout 180 zig build -Doptimize=ReleaseSafe + timeout 180 zig build verify -Doptimize=safe --summary all + timeout 180 zig build -Doptimize=safe PYTHONDONTWRITEBYTECODE=1 python3 tests/test_compare.py -v PYTHONDONTWRITEBYTECODE=1 python3 tests/arena_lifecycle_integration.py PYTHONDONTWRITEBYTECODE=1 python3 tests/batch_integration.py diff --git a/tools/verify_windows.py b/tools/verify_windows.py index 6d14f7e..89cb8a6 100644 --- a/tools/verify_windows.py +++ b/tools/verify_windows.py @@ -89,8 +89,8 @@ def run(name, arguments, timeout): try: expected = (ROOT / '.zig-version').read_text().strip() - require(expected == '0.16.0' and capture(['zig', 'version']) == expected, - 'Use exactly the repository Zig 0.16.0 release') + require(expected == '0.17.0' and capture(['zig', 'version']) == expected, + 'Use exactly the repository Zig 0.17.0 release') receipt['zig_version'] = expected receipt['repository_commit'] = capture(['git', 'rev-parse', 'HEAD']) receipt['input_status'] = capture(['git', 'status', '--porcelain=v1', '--untracked-files=all']) @@ -104,8 +104,8 @@ def run(name, arguments, timeout): 'tools/verify_windows.py', 'tools/check_embedding.py', 'tools/smoke.py', 'tools/benchmark.py', 'tools/compare.py')} run('verify-debug', ['zig', 'build', 'verify', '--summary', 'all'], 300) - run('verify-release-safe', ['zig', 'build', 'verify', '-Doptimize=ReleaseSafe', '--summary', 'all'], 300) - run('build-release-safe', ['zig', 'build', '-Doptimize=ReleaseSafe'], 300) + run('verify-release-safe', ['zig', 'build', 'verify', '-Doptimize=safe', '--summary', 'all'], 300) + run('build-release-safe', ['zig', 'build', '-Doptimize=safe'], 300) binary = ROOT / 'zig-out/bin/bounded-http.exe' data = binary.read_bytes() require(data[:2] == b'MZ' and len(data) >= 64, 'HTTP output is not a PE executable') @@ -114,7 +114,7 @@ def run(name, arguments, timeout): struct.unpack_from(' Date: Sun, 4 Oct 2026 17:43:48 +0200 Subject: [PATCH 2/4] Separate idle budget in request-deadline integration fixture --- tests/continuation_integration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/continuation_integration.py b/tests/continuation_integration.py index 77e934d..9096c78 100644 --- a/tests/continuation_integration.py +++ b/tests/continuation_integration.py @@ -173,6 +173,9 @@ def idle_keep_alive_then_request(mode): options = shared_options(mode) options['timeout_ms'] = 500 options['max_timeout_ms'] = 1000 + # This fixture checks request deadlines, not idle expiry. Keep a separate + # idle budget so hosted scheduling cannot consume the 100 ms idle margin. + options['idle_timeout_ms'] = 3000 options['deadline_sweep_ms'] = 5 with Server(**options, stall_ms=350) as server: with server.connect(timeout=5) as client: From 65d584bf1a00451577235281a290303b10d0ae3b Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 18:04:35 +0200 Subject: [PATCH 3/4] docs: align pthread compiler reference with Zig 0.17 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6260387..1467c83 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ capacity, so heap usage multiplies with shard count even though admission is a shared process-wide ceiling. This is not an RSS limit: allocator metadata, libc/pthread metadata and actual stack mappings, mapped kernel rings, socket queues, loaded assets and arbitrary application allocations require -separate accounting. Zig 0.16's pthread implementation uses its C allocator for +separate accounting. Zig 0.17's pthread implementation uses its C allocator for thread bookkeeping despite the supplied spawn allocator. The demo seals its framework allocator after startup and counts/refuses subsequent allocation attempts through it. See [Budget](src/budget.zig) for the implementation. From 19223caff116de440207a161969d88c60cdccfb8 Mon Sep 17 00:00:00 2001 From: renerocksai Date: Sun, 4 Oct 2026 19:15:20 +0200 Subject: [PATCH 4/4] Scope the preserved benchmark reproducer to Zig 0.16 history --- benchmarks/prepare/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/benchmarks/prepare/README.md b/benchmarks/prepare/README.md index 53a125a..5bfe699 100644 --- a/benchmarks/prepare/README.md +++ b/benchmarks/prepare/README.md @@ -1,4 +1,9 @@ -# Reproduce the Linux comparison preparation +# Reproduce the historical Zig 0.16 Linux comparison preparation + +This reproducer preserves the September 2026 Zig 0.16.0 comparison pins. +Use an archived engine commit whose `.zig-version` matches `pins.json`. +The current engine targets Zig 0.17.0; these historical preparation inputs +do not qualify its performance and must be ported separately before a new comparison. `prepare.py` downloads pinned primary sources and package artifacts, verifies their hashes, builds the three contenders and wrk, and generates the input for