cujson
Parse JSON and JSON Lines on an NVIDIA GPU from Rust, using the
cuJSON parser (ASPLOS '26). Part of
cuJSON-rs, which also ships a CLI and a Python package
(pip install cujson).
[]
= { = "0.1", = ["cuda"] }
Requirements
Building with the cuda feature needs the CUDA toolkit (12.1 or newer): nvcc on PATH, or
CUDA_HOME set. The kernels are compiled in cujson-sys's build script into a fat binary for
compute capability 7.5 onwards plus a PTX fallback, and the CUDA runtime is linked statically,
so the resulting binary needs only the NVIDIA driver. Set CUJSON_CUDA_ARCHS=86 (for example)
to build for a single GPU generation.
Without the cuda feature the crate still compiles (for docs.rs, or dependents that make the GPU
optional), and every parse returns Error::CudaNotCompiled.
Usage
Node also has kind, index, iter_array, iter_object, raw, as_f64, as_bool and
is_null; with the serde feature, to_value converts to a serde_json::Value.
Features
| Feature | Effect |
|---|---|
cuda |
Compile the GPU kernels (needs nvcc) |
serde |
Node::to_value into serde_json::Value |
cpu-reference |
A CPU implementation of the same output format (cujson::cpu::parse), for testing |
Limitations
- cuJSON checks UTF-8 validity and bracket balance, not the full JSON grammar: malformed scalars
such as
1.2.3are not rejected.parsedoes reject input that is not exactly one value. - Inputs are limited to just under 2 GiB (cuJSON uses 32-bit sizes).
- Parses are serialised within a process: cuJSON uses the default CUDA stream.
Credits
cuJSON is by Ashkan Vedadi Gargary, Soroosh Safari Loaliyan and Zhijia Zhao (MIT licensed); cite CuJSON: A Highly Parallel JSON Parser for GPUs (ASPLOS '26) if you use it in research. cuJSON-rs is MIT licensed.