使用计算着色器在GPU上进行并行JSON解析
摘要
slurpjson是一个Rust库,它完全在GPU上使用wgpu计算着色器解析JSON,将解析过程分解为并行前缀扫描,用于研究目的。
查看缓存全文
缓存时间: 2026/07/28 16:27
friendlymatthew/slurpjson 源码:https://github.com/friendlymatthew/slurpjson
slurpjson
本项目通过 wgpu 计算着色器在 GPU 上完整解析 JSON。解析器将 JSON 解析分解为一系列并行前缀扫描的流水线,生成扁平的结构字符磁带。
此项目纯属研究性质,旨在探索如何将 JSON 解析归约为 Raph Levien 所称的“易于并行的难题”。
用法
fn main() {
let json = r#"
{
"foo": "bar",
"baz": {
"wef": [1, 2, 3],
"yearn": {
"1": 2,
"2": 3.0
}
}
}
"#;
let parser = slurpjson::Parser::try_new()?;
let tape = parser.parse_str(&json)?;
let document = slurpjson::Document::new(json.as_bytes(), &tape);
dbg!(document);
}
参考资料
https://raphlinus.github.io/gpu/2020/09/05/stack-monoid.html
https://raphlinus.github.io/personal/2018/05/10/toward-gpu-json-parsing.html
相似文章
@shubh6200: 要了解如何处理海量文件,请阅读 @geofflangdale 和 @lemir 的《Parsing Gigabytes of JSON per Second》…
该论文介绍了 simdjson,这是第一个能够在单核上使用 SIMD 指令每秒处理数 GB 数据的验证性 JSON 解析器,相比 RapidJSON 等现有解析器实现了显著的加速。
在 Python 中以每秒数十 GB 的速度解析 JSON
Daniel Lemire 演示了如何在无 GIL 的 Python 3.14 中,使用 fastsimdjson 的 map_many 多线程与惰性解析,在数秒内解析 7.6 GB 的 GH Archive JSON 数据,性能远超标准库 json、orjson 与 msgspec。
Rust 中的 GPU 卸载:可移植、安全且快速
本文介绍了一种零开销、多厂商的 GPU 编译框架,该框架内置于 Rust 编译器中,利用 Rust 的所有权模型确保内存安全,并实现与原生 CUDA 和 HIP 基准相媲美的性能。
GPU上的无畏并发:在Rust中进行安全的GPU推理,与vLLM/SGLang竞争 [R]
cuTile Rust 引入了一种基于块(tile)的编程模型,利用 Rust 的所有权机制来保证 GPU 内核的内存安全和无数据竞争,基于该模型构建的 Grout 推理引擎在 Qwen3 模型上实现了与 vLLM/SGLang 相当的吞吐量。
Rust SIMD on the GPU
VectorWare announces that Rust's portable SIMD (core::simd) now works on the GPU, mapping SIMD vectors to warp lanes and enabling familiar Rust abstractions for GPU programming.