Repository navigation
jit: accelerate Bun JSON and gzip with NEON integer lowering - #10
Merged
Merged
Conversation
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.
Bun 1.4.4's JSON parser and zlib compression loop were repeatedly entering the kernel instruction interpreter. Lower their hot NEON operations in T1: CMTST, UMINV, SSHLL/USHLL (including UXTL), byte/halfword UQSUB, and 32/64-bit USHL.
UQSUB preserves sticky FPSR.QC and uses recovery metadata to commit the vector result and FPSR together when interrupted, including aliased operands. USHL implements ARM's signed low-byte shift counts. Add differential coverage, a saturation recovery regression, and a reproducible Bun benchmark.
Measured inside QEMU/KVM on an x86_64 i7-13700H host (nested virtualization), 2 vCPUs, 4 GiB,
-cpu host, pinned to host CPUs 2 and 4. Both architectures use Bun 1.4.4 revision38afee6c84fcf48c0edb2466aa4b27d287a59c30and glibc 2.41. Baseline is7e8de37.Medians of 14 samples per workload/architecture/kernel: two processes, each with three untimed warmups and seven measured samples. Boot order was baseline/patched/patched/baseline; architecture order was reversed in the second pair. Profiling was disabled for timings. JSON performs 20 parse/stringify round trips over 10,000 objects; gzip performs eight level-6 compressions of a deterministic 1 MiB buffer, then decompresses and verifies SHA-256. Startup is excluded. All checksums match. Patched kemu is 3.22× native for JSON and 2.04× for gzip.
Separate diagnostic helper profiles (one warmup plus three batches, including process setup) confirm the identified hot instruction sites disappear:
The profiling instrumentation is confined to the local diagnostic kernel and is not part of this change. Remaining gzip helpers are mostly FP conversions outside the zlib saturation loop.
Validation:
INTR=10 RELOC=1 jit-test 30000 14 12, with and withoutNO_VCACHE=1: 60,000 cases, zero failures, exact FPCR/FPSR/NZCV, only the terminating BRK uses a helper; 2,887 asynchronous interruptions recovered.scripts/vm-smoke.sh: all passed, including vector state, syscall state, FP status, ABI, TBI and multithread stress.Reproduction:
tests/bench/bun.mjsand the commands in README.