Files
ziran/bench/json_document.md
T
waoziandClaude Opus 5.5 931fed4c86 Run ZX natively by default and integrate the finished assembly lanes
One commit, because the parts below only build together.

Allocator: an interval needed at the current instruction is never
evicted, and the allocated-program verifier checks that every operand sits
where the allocation says.

AArch64 encoder: compiler_aarch64.zi encodes allocated machine IR with the
shared ARM byte helpers, maps the function-address relocation,
sign-extends signed 8- and 16-bit loads and rejects what it cannot encode
with a named diagnostic. It has no AOT ELF writer yet.

Native default with checked pointers and no fallback: on linux-x86_64,
`ziran run app.zx`, `zi2zx run`, the embedding API's Auto and the Kryon
players run a bundle's verified program as native code in W^X memory.
Stray and freed pointers, double free, bounds and read-only stores trap. A
native gap is a named preflight error, nothing falls back to the engine,
and `--backend engine` picks it explicitly. zx2native uses the same
preflight. Native code exchanges module state for hot reload, checks the
stack, zeroes fresh locals, spends fuel at the engine's checkpoints and
returns records, arrays and strings from host calls. `zi2zx --debug` source
origins name lines in native traps and `zx2native --emit map`. The host
value API drops its VM prefix (HostValue, HOST_*). A call with a record
result loads the hidden result address into rax only after its stack
arguments are stored, and an indirect target stays in r10: rax could hold
a stack argument (Kryon's text-field clip guard arrived as an address) or
the target (indirect calls returning records crashed).

Self-hosting ports: compiler_backend_process, compiler_backend_cache,
compiler_native_names and compiler_runtime_emit replace the zir_c_build,
zir_c_cache and zir_c_process C, with checked bootstrap C and Makefile
rules. zir_c.toolchain again reports "compiling OUT failed:" with the head
of the compiler output and a truncation marker. The parallel scheduler no
longer stalls on a held compiler after reaping a finished job, and poll or
read errors now fail the build. A fresh BUILD_DIR (Kryon's runtime build)
builds: generated files have pattern rules, objects wait for the headers
they include, and engine flags are per object instead of leaking into zi2c.

Legacy removals F1-F10 and N1-N4: the duplicate LirX64 encoder and its
spec test, zir_c_*, zir_runtime and zir_native, nine zero-reference spec
tests, vec_capacity, the zx_metadata and native_cache_names benchmarks,
build-android-host.sh and two shell wrappers are deleted; zx2native is
machine-only; `zi2zx` rejects `--opt` on ZX input; the bootstrap is
regenerated. ASSEMBLY docs, the legacy-removal plan, the milestones and the
remaining-work plan record the current position.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 14:04:48 -03:00

2.1 KiB
Raw Blame History

JSON string scanning and parsing

The 0.4.2 JSON readers share an allocation-free scanner that examines complete 16-byte blocks through portable SIMD operations. Unescaped text remains a borrowed view. Escape decoding, error positions, duplicate member behavior and secure cleanup retain their existing policies. Short strings use the scalar tail. Simd.Load and Simd.LoadLow accept immutable strings for u8 vector lanes; whole-load bounds checks apply on C, Go and the portable engine.

Run sh bench/json_document.sh. It builds through Zi2c with the normal native executable defaults, constructs a 1 MiB ASCII string outside the timer and checks every parse. Eleven batches of 64 parses report raw nanoseconds per parse and symmetric inclusive-quartile 1.5×IQR exclusions. Process startup, compilation, input construction and transport are excluded. The scanner-only comparison is bench/json_string_scan.zi; it checks byte semantics before timing alternating reference and vector scans. Repeated scans use an opaque start and a compiler memory barrier to prevent loop hoisting.

The retained reports name the CPU, compiler inputs and exact runtime binaries. These are warm-cache local measurements on a busy Ryzen 9 9950X Linux machine; they do not establish performance on other architectures. Go and the portable VM use the same lane semantics; native vector instructions depend on the target.

The corresponding Xcoder diagnostic also measures the original preserved Codex V8 host. It times repeated JSON.parse inside that actual host and JsonRead inside the sandboxed Zi2c cell, separately from the complete cell round trip. The JavaScript timer has 1 ms resolution, amortized across 512 parses per batch. Both validate payload length and its first and last bytes on every parse.

A parser improvement does not remove native sandbox creation and executable startup. The original single-cell JSON benchmark must remain visible alongside the direct parser result. Cold custom compilation is reported separately from warm execution. Ordinary precompiled tool plans are a different workload and do not invoke the custom-cell compiler or sandboxed executable.