Crate fast_yaml_parallel

Crate fast_yaml_parallel 

Source
Expand description

fast-yaml-parallel: Multi-threaded YAML processing.

Provides parallel processing for:

  • Multi-document YAML streams (document-level parallelism)
  • Multiple YAML files (file-level parallelism)

§Performance

Expected speedup on multi-document files:

  • 4 cores: 3-3.5x faster
  • 8 cores: 6-6.5x faster
  • 16 cores: 10-12x faster

§When to Use

Use parallel processing when:

  • Processing multi-document YAML streams (logs, configs, data dumps)
  • Batch processing multiple YAML files
  • 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

§Examples

Document-level parallelism:

use fast_yaml_parallel::parse_parallel;

let yaml = "---\nfoo: 1\n---\nbar: 2\n---\nbaz: 3";
let docs = parse_parallel(yaml)?;
assert_eq!(docs.len(), 3);

File-level parallelism:

use fast_yaml_parallel::{FileProcessor, Config};
use std::path::PathBuf;

let processor = FileProcessor::new();
let paths = vec![PathBuf::from("file1.yaml"), PathBuf::from("file2.yaml")];
let result = processor.parse_files(&paths);

println!("Processed {} files, {} successful, {} failed",
         result.total, result.success, result.failed);

Custom configuration:

use fast_yaml_parallel::{parse_parallel_with_config, Config};

let config = Config::new()
    .with_workers(Some(8))
    .with_sequential_threshold(2048);

let yaml = "---\nfoo: 1\n---\nbar: 2";
let docs = parse_parallel_with_config(yaml, &config)?;

Structs§

BatchResult
Aggregated results from batch processing.
Config
Configuration for parallel processing behavior.
FileProcessor
Parallel file processor for batch YAML operations.
FileResult
Result for a single file with path context.
SmartReader
Smart file reader that chooses optimal reading strategy based on file size.

Enums§

Error
Unified error type for all parallel operations.
FileContent
File content holder that abstracts over in-memory strings and memory-mapped files.
FileOutcome
Outcome of processing a single file.
Value
A YAML node is stored as this Yaml enumeration, which provides an easy way to access your YAML document.

Functions§

parse_parallel
Parse multi-document YAML stream in parallel.
parse_parallel_with_config
Parse multi-document YAML with custom configuration.
process_files
Process multiple YAML files in parallel.

Type Aliases§

Result
Result type for parallel operations.