fast-yaml-parallel
Multi-threaded YAML processing with work-stealing parallelism.
Installation
Add to your Cargo.toml:
[]
= "0.1"
Or with cargo-add:
[!IMPORTANT] Requires Rust 1.88 or later.
Usage
Basic Usage
use parse_parallel;
let yaml = "---\nfoo: 1\n---\nbar: 2\n---\nbaz: 3";
let docs = parse_parallel?;
assert_eq!;
# Ok::
Custom Configuration
use ;
let config = new
.with_thread_count
.with_min_chunk_size;
let yaml = "---\nfoo: 1\n---\nbar: 2";
let docs = parse_parallel_with_config?;
# Ok::
Performance
Expected speedup on multi-document YAML files:
| Cores | Speedup |
|---|---|
| 4 | 3-3.5x |
| 8 | 6-6.5x |
| 16 | 10-12x |
[!TIP] Run benchmarks with
cargo bench -p fast-yaml-parallelto measure performance on your hardware.
When to Use
Use parallel processing when:
- Processing multi-document YAML streams (logs, configs, data dumps)
- Input size > 1MB with multiple documents
- Running on multi-core hardware (4+ cores recommended)
Use sequential processing when:
- Single document files
- Small files (<100KB)
- Memory constrained environments
Configuration Options
| Option | Default | Description |
|---|---|---|
thread_count |
Auto (CPU cores) | Number of worker threads |
min_chunk_size |
4KB | Minimum bytes per chunk |
max_chunk_size |
10MB | Maximum bytes per chunk |
max_input_size |
100MB | Maximum total input size |
max_documents |
100,000 | Maximum documents to parse |
Related Crates
This crate is part of the fast-yaml workspace:
fast-yaml-core— Core YAML 1.2.2 parser and emitterfast-yaml-linter— YAML linting with rich diagnosticsfast-yaml-ffi— FFI utilities for language bindings
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.