A high-performance parser for Yarn v3/v4 lockfiles, built with Rust and nom. This parser focuses on performance, with minimal allocation and future use in WASM or with napi-rs.
The parser is designed for high performance with minimal memory usage:
- Small files (~1KB): ~6-7 microseconds
- Medium files (~2KB): ~2-3 microseconds
- Large files (~40KB): ~5 microseconds
- Memory usage: Typically 0-20KB heap usage depending on fixture complexity
crates/
├── berry-core/ # Main parser library
├── berry-test/ # Integration tests
├── berry-bench/ # Criterion microbenchmarks
├── berry-bench-bin/ # CLI benchmarking tool
└── node-bindings/ # Node.js bindings (WIP)
The project includes basic benchmarking infrastructure for performance monitoring and regression detection. Claude wrote that part, apologies.
# Test a specific fixture
cargo run --bin berry-bench-bin -- -f minimal-berry.lock -v
# Test all working fixtures
cargo run --bin berry-bench-bin -- --all -r 10
# Get JSON output for CI integration
cargo run --bin berry-bench-bin -- --all --format json# Run comprehensive Criterion benchmarks
cargo bench --package berry-bench
# Quick benchmark run
cargo bench --package berry-bench --bench parser_benchmarks -- --quick- Fixture Parsing: Different file sizes and complexities
- Memory Usage: Heap usage tracking and analysis
- Zero-Allocation Validation: Memory allocation verification
- Input Characteristics: Various lockfile formats and features
- Rust 1.70+ (2021 edition)
- Cargo with workspace support
# Build all crates
cargo build --workspace
# Build with optimizations
cargo build --release --workspace# Run all testss
cargo test --workspace
# Run integration tests
cargo test --package berry-test
# Run benchmarks
cargo bench --workspace# Check code quality
cargo clippy --workspace
# Format code
cargo fmt --workspacesrc/parse.rs- Main parsing logic with zero-allocation optimizationssrc/package.rs- Package struct with dependency storagesrc/ident.rs- Ident and Descriptor structs for dependenciessrc/lockfile.rs- Lockfile struct and metadata parsingsrc/metadata.rs- Metadata struct for lockfile version info
- Integration tests with real Yarn lockfile fixtures
- Automatic fixture discovery and validation
- End-to-end parsing verification
- Criterion-based microbenchmarks for statistical analysis
- CLI tool for quick performance testing
- Memory usage tracking and heap analysis
- Performance regression detection
-
Production Ready
-
All tests passing (23/23)
-
Zero clippy warnings
-
Zero compilation errors
-
Zero-allocation parsing pipeline
-
Modern nom API usage
-
Comprehensive test coverage
-
In Development
-
Advanced lockfile features (multi-descriptors, meta fields)
-
WASM compilation support
-
Node.js bindings with napi-rs
-
CI/CD benchmarking pipeline
The benchmarking infrastructure automatically detects:
- Performance regressions (>50% slower than baseline)
- Statistical significance in benchmark results
- Memory usage patterns and allocation tracking
- Zero-allocation violations during parsing
See CONTRIBUTING.md for development guidelines and benchmarking information.
MIT OR Apache-2.0
- Task List - Detailed development progress
- Benchmarking Plan - Comprehensive benchmarking strategy
- Dev Documentation - Development guides and documentation