Skip to content

Real-world migration validation

Before freezing the ayaml 1.0.0 API, we migrated five widely used, open-source Rust projects from five different YAML stacks (yaml-rust2, serde-saphyr, yaml_serde / libyaml-rs, serde-saphyr + granit-parser, and serde_yaml + marked-yaml) to ayaml following our public migration guides. Every project was checked out at a pinned upstream commit, tested end-to-end against its own test suite and a canonical semantic-equivalence oracle, audited for transitive dependencies and unsafe code, and benchmarked with 3-round pinned-CPU A/B runs.

Across all five projects (3,380 real-world tests and hundreds of real-world YAML files), zero ayaml correctness bugs were discovered, every migrated parse workload ran 1.52x to 4.76x faster (with 2.29x to 41.1x fewer heap allocations on single-document DOM, Serde, and tape workloads), and the migrations surfaced four concrete pre-1.0 API improvements plus migration-guide refinements that are now shipped in ayaml.

Project Pinned upstream commit (license) Replaced YAML stack Parse speedup (3-round median) Heap / alloc reduction Dependency & unsafe delta Test & equivalence outcome
trishume/syntect v5.3.0 @ 4efbec1 (MIT) yaml-rust2 0.10.4 2.03x (Value) / 2.67x (Tape); 1.15x e2e Criterion 2.48x peak / 4.70x allocs (Value) -4 deps (4 unsafe crates removed) 222/222 tests + make syntest; bit-for-bit identical 1,678,255 B SyntaxSet dump
ast-grep/ast-grep v0.51.3 @ 57c4bef (MIT) serde-saphyr 2.2.0 1.95x rule parse; 1.78x to 1.85x e2e outline CLI LTO binary -653.7 KiB (-1.19%) -7 CLI deps (-12 on config/outline); -2/-3 unsafe crates 822/822 pure-Rust tests + clippy; bit-for-bit identical canonical JSON across 216 rules
zizmorcore/zizmor v1.33.1 @ 15caca4 (MIT) yaml_serde 0.10.7 (libyaml-rs 0.3.0) 1.79x typed / 2.18x Value / 3.58x Tape 4.20x peak (typed), 5.76x peak (Value), 41.1x fewer allocs (Tape) 295 unsafe blocks/items eliminated (2 YAML crates removed) 595/595 offline tests; bit-for-bit identical 358 findings (770,515 B JSON) across 56 files
j178/prek v0.5.12 @ f637c38 (MIT) serde-saphyr 2.1.1 + granit-parser 2.1.0 4.71x to 4.76x (Tape) / 2.29x --unsafe; 1.44x to 1.46x e2e CLI 6.68x to 10.54x less total alloc; LTO binary -596.7 KiB (-4.20%) -6 deps; 337 unsafe blocks/items eliminated (3 crates) 741/743 pass (17 insta format diffs + 2 YAML 1.2/display policy diffs logged); 3/3 CLI hooks exit 0
prefix-dev/rattler-build v0.81.0 @ 52ec398 (BSD-3-Clause) serde_yaml 0.9.34 + marked-yaml 0.8.0 1.53x to 1.78x Criterion; 1.91x DOM / 1.52x Stage0 / 1.90x Serde 3.80x peak & 8.91x total (serde); 1.68x peak (Stage0) -4 CLI / -10 parser deps; 153 unsafe removed workspace-wide (417+ in parser) 998/998 offline tests + clippy; bit-for-bit identical 149-recipe Stage0 JSON (179,815 B) & --render-only

All measurements follow the comparative disclosure principles in Benchmark methodology and D105 in Design decisions:

  • Dedicated pinned-CPU environment: Every timing and RSS run executed on a quiet Linux x86_64 host (Intel Skylake-class quad-core @ 2.60 GHz, performance CPU frequency governor) pinned to a single core with taskset -c 2.
  • 3-round interleaved A/B protocol: Each benchmark runs three independent rounds alternating baseline and ayaml execution order to cancel thermal or page-cache drift, reporting the median of the three round medians plus cross-round coefficient of variation (CV).
  • Separated timing and allocation measurement: Timing binaries use the stock system allocator with zero instrumentation. Exact peak heap, total allocated bytes, and allocation counts are measured in separate binaries using a counting #[global_allocator] wrapping std::alloc::System. Process peak RSS is measured via ru_maxrss (wait4).
  • Exact semantic oracles: Beyond running each project’s test suite, we verified deterministic semantic equivalence between baseline and ayaml outputs (binary SyntaxSet dumps, canonical sorted JSON digests, and CLI command outputs).
  • Upstream: trishume/syntect v5.3.0 at 4efbec173db6ea83caaf7a34994cb7e4d038a13e (MIT)
  • Diff scope: Cargo.toml and src/parsing/yaml_load.rs; zero third-party YAML crates left in cargo tree / Cargo.lock (-4 normal crates, 4 unsafe-using crates removed).
  • Correctness: 222/222 --all-features tests plus make syntest and make syntest-fancy pass; serialized SyntaxSet binary dump across all 191 .sublime-syntax files (3.08 MiB) matches bit-for-bit (1,678,255 bytes).
  • Performance, memory & size (3-round pinned CPU):
    • End-to-end Criterion add_from_folder (includes regex compilation and linking): -67.12 ms (-12.71%, 1.15x faster, CV 0.17% -> 0.05%) on default-onig, -80.19 ms (-3.13%, CV 0.64% -> 0.32%) on default-fancy.
    • Isolated 191-file YAML parse: 2.03x faster (Value, 102.97 ms -> 50.73 ms, CV 0.10% -> 1.97%) / 2.67x faster (Tape, 38.55 ms, CV 0.42%), 2.48x lower max peak heap, 4.70x fewer allocations (Value) / 108.6x fewer (Tape).
    • Process peak RSS (ru_maxrss): 28,340 -> 28,720 KiB (+1.34%, load) and 61,872 -> 62,316 KiB (+0.72%, load + build); non-LTO stripped examples/syntest binary: +500.2 KiB (+8.68%).
  • Guide takeaways: Replacing hash.get(&Yaml::String(k.to_owned())) with zero-allocation Mapping::get(k) saved an additional ~15 to 28 ms end-to-end beyond YAML parsing alone.

2. ast-grep/ast-grep (serde-saphyr to ayaml)

Section titled “2. ast-grep/ast-grep (serde-saphyr to ayaml)”
  • Upstream: ast-grep/ast-grep v0.51.3 at 57c4bef6ade910580e43caf04979def503bb4dde (MIT)
  • Diff scope: 18 files (+42/-53 lines); zero third-party YAML crates left in cargo tree / Cargo.lock (-7 CLI crates, -12 on ast-grep-config/ast-grep-outline, -2/-3 unsafe-using crates).
  • Correctness: 822/822 pure-Rust tests and clippy -D clippy::all pass; canonical JSON across all 216 bundled DEFAULT_OUTLINE_RULES (91,096 bytes) matches bit-for-bit.
  • Performance, memory & size (3-round pinned CPU):
    • parse_outline_rules: 1.95x faster (12.605 ms -> 6.455 ms, -48.79%, CV 0.71% -> 0.17%).
    • End-to-end ast-grep outline CLI startup: 1.78x faster on Rust (13.993 ms -> 7.882 ms, CV 0.48% -> 0.20%) / 1.85x faster on TypeScript (13.431 ms -> 7.276 ms, CV 0.53% -> 0.07%).
    • YAML emission: ~parity (1.714 ms -> 1.747 ms, +1.93%, CV 0.19% -> 0.12%).
    • Heap, RSS & binary size: process Peak RSS 11,388 -> 11,388 KiB (0.00%); multi-doc Deserializer allocated +2.1% peak / +9.2% allocs across 216 small documents (logged for post-1.0 cross-document scratch reuse) and to_string materialized an intermediate Value (8.9 KiB vs 2.1 KiB peak); stripped LTO ast-grep CLI binary shrank by -653.7 KiB (-1.19%).
  • Guide takeaways: ayaml’s out-of-the-box YAML 1.2.2 defaults replaced serde-saphyr’s explicit options boilerplate (strict_booleans, literal <<, .inf/.nan pass-through), while Deserializer::next_borrowed::<Option<T>>() and DocumentDeserializer mapped multi-doc null skipping and middleware cleanly.

3. zizmorcore/zizmor (yaml_serde / libyaml-rs to ayaml)

Section titled “3. zizmorcore/zizmor (yaml_serde / libyaml-rs to ayaml)”
  • Upstream: zizmorcore/zizmor v1.33.1 at 15caca4fdcfee377c25b101b6c6ad3ec68962159 (MIT)
  • Diff scope: 36 files (+268/-268 lines); zero third-party YAML crates left in cargo tree / Cargo.lock, eliminating 295 non-comment unsafe blocks/items across yaml_serde and libyaml-rs with zero new transitive dependencies (zizmor CLI 299 -> 298, github-actions-models 22 -> 19, yamlpatch 41 -> 39).
  • Correctness: 595/595 offline assertions pass (578 byte-for-byte unchanged, 17 expected diagnostic/quote-style insta snapshot diffs including 10 with richer field paths); end-to-end zizmor --offline --format=json across 56 staged files produces 358 security findings / 770,515 canonical JSON bytes bit-for-bit identical to baseline.
  • Performance, memory & size (73-file real-world workflow corpus, 218.2 KiB):
    • Typed models: 1.79x faster (10.138 ms -> 5.650 ms, CV 0.05% -> 1.01%), 4.20x lower peak heap, 3.49x fewer allocations.
    • Value DOM: 2.18x faster (9.243 ms -> 4.235 ms, CV 0.03% -> 1.27%), 5.76x lower peak heap, 8.79x less total allocated bytes.
    • Tape: 3.58x faster (2.580 ms, CV 0.99%), 41.1x fewer allocations.
    • End-to-end LTO CLI: -2.13 ms (396.550 ms -> 394.418 ms, -0.54%, CV 0.10% -> 0.14%); Peak RSS 65,220 -> 66,292 KiB (+1.64%); stripped LTO binary +934.2 KiB (+2.67%).
  • Guide & API takeaways: Error::kind() directly replaced zizmor’s double-parse syntax-vs-schema workaround, #[serde(with = "...::singleton_map")] was deleted outright on Deserialize enums, and this migration motivated adding complete primitive From impls on Number plus a cleaner Error Debug format.

4. j178/prek (serde-saphyr + granit-parser to ayaml)

Section titled “4. j178/prek (serde-saphyr + granit-parser to ayaml)”
  • Upstream: j178/prek v0.5.12 at f637c380d18dcbde297c7b5cd0adc73f54ddefcd (MIT)
  • Diff scope: 11 files (+202/-171 lines); removed both serde-saphyr 2.1.1 and granit-parser 2.1.0 (-6 normal crates, 337 non-comment unsafe blocks/items eliminated across encoding_rs, arraydeque, and num-traits). clippy -D warnings clean (0 warnings).
  • Correctness: 741/743 unit and YAML integration assertions pass (17 expected insta diagnostic-format diffs, plus 2 documented policy differences: Prometheus-style under-indented flow sequences under strict YAML 1.2.2 vs compat, and raw \t display in custom Serde error strings); all 3 Fat-LTO check-yaml-* hooks exit 0. Switching --unsafe syntax checks to ayaml::parse_events also resolved an upstream TODO around undefined anchors.
  • Performance, memory & size (21 to 22 files, 113.2 to 115.5 KiB, Fat-LTO CLI):
    • Isolated check-yaml: single-doc parse_tape 4.71x faster (6.223 ms -> 1.322 ms, CV 0.23% -> 1.13%, 6.68x less total alloc, 6.08x fewer allocs); from_str::<IgnoredAny> 4.13x faster (1.507 ms, CV 0.04%, 10.54x less total alloc, -11.3% max peak); --multi 4.76x faster (6.566 ms -> 1.380 ms, CV 0.27% -> 0.26%); --unsafe (parse_events vs granit-parser) 2.29x faster (2.781 ms -> 1.217 ms, CV 1.21% -> 0.13%, trading +30 KiB eager token buffer peak for scanning speed).
    • End-to-end Fat-LTO prek run check-yaml-* --all-files: 1.44x faster (single, 16.438 -> 11.421 ms, -30.5%, CV 1.66% -> 0.61%, Peak RSS -776 KiB / -6.21%), 1.46x faster (multi, 16.770 -> 11.481 ms, -31.5%, CV 0.58% -> 0.43%), 1.14x faster (unsafe, 12.856 -> 11.246 ms, -12.5%, CV 0.44% -> 0.74%, Peak RSS -512 KiB / -4.19%).
    • Stripped Fat-LTO prek binary: -596.7 KiB (-4.20%) smaller (14,559,760 B -> 13,948,752 B).
  • API takeaway: Motivated adding compat::ParseOptions::with_allow_duplicates(false) so linters can accept libyaml-style under-indented flow continuations while keeping strict duplicate-key rejection.

5. prefix-dev/rattler-build (serde_yaml + marked-yaml to ayaml)

Section titled “5. prefix-dev/rattler-build (serde_yaml + marked-yaml to ayaml)”
  • Upstream: prefix-dev/rattler-build v0.81.0 at 52ec3988ee57213b039091f98d4d503148a9e417 (BSD-3-Clause)
  • Diff scope: 74 files across all 9 workspace crates + benches/parse_file.rs (+1,024/-398 lines). Removed all direct serde_yaml 0.9.34 and marked-yaml 0.8.0 dependencies; completely eliminated marked-yaml, yaml-rust2, hashlink (81 unsafe), arraydeque (72 unsafe), and doc-comment from Cargo.lock (-4 CLI crates, -10 normal crates on rattler_build_yaml_parser, 153 unsafe blocks/items eliminated workspace-wide and 417+ inside rattler_build_yaml_parser).
  • Correctness: 998/998 offline workspace tests pass (clippy -D clippy::all clean; 983 unchanged, 15 insta snapshot diffs: 9 objectively improved miette source spans fixing marked-yaml’s colon-offset mapping starts and single-word truncation + 6 quote-style diffs). Canonical JSON across all 149 valid recipe.yaml files (179,815 bytes) and end-to-end rattler-build --no-config build --render-only match bit-for-bit.
  • Performance, memory & size (3-round pinned CPU):
    • Built-in unmodified Criterion benches/parse_file.rs (5,000 samples, incl. file open/read/mmap syscalls): from_reader 1.78x faster (26.377 us -> 14.835 us, CV 0.50% -> 0.62%), from_string 1.73x faster (27.016 us -> 15.653 us, CV 1.81% -> 0.97%), from_mmap 1.53x faster (32.285 us -> 21.077 us, CV 1.50% -> 0.41%).
    • 149-recipe pinned corpus (93,153 B): spanned DOM (parse_yaml) 1.91x faster (3.2577 ms -> 1.7028 ms, CV 0.27% -> 0.60%, 3.64x fewer allocs); full Stage0 recipe parser 1.52x faster (5.6376 ms -> 3.7105 ms, CV 0.84% -> 0.36%, 1.68x lower max peak, 2.29x fewer allocs); typed Serde (minijinja::Value) 1.90x faster (4.1965 ms -> 2.2145 ms, CV 0.26% -> 1.48%, 3.80x lower max peak, 8.91x less total alloc, 5.49x fewer allocs). Reference zero-copy Tape::parse reached 2.21x faster (CV 0.09%, 23.6x fewer allocs, 3.30x lower max peak) and SpannedTree::parse reached 1.68x faster (CV 0.22%, 6.22x fewer allocs, 2.34x lower max peak).
    • End-to-end single-recipe --render-only: 11.584 ms -> 11.613 ms (1.00x, CV 0.26% -> 0.41%, startup-bound on one 2.2 KiB file); corpus Peak RSS 13,268 -> 13,268 KiB (0.00%); CLI Peak RSS 27,680 -> 29,124 KiB (+5.22%) and stripped non-LTO binary +2.01 MiB (+2.85%) while external rattler_* crates still link serde_yaml.
  • API takeaway: Directly motivated exposing full read-only AST traversal and decoded-scalar metadata on SpannedNode (as_mapping, as_sequence, get, lookup, scalar_value, scalar_style, scalar_tag), eliminating the need for a custom event-stack tree wrapper when replacing marked-yaml.

Pre-1.0 improvements driven by these migrations

Section titled “Pre-1.0 improvements driven by these migrations”

Every API gap uncovered across the five migrations was small, additive, and landed before 1.0.0:

  1. Full read-only traversal on SpannedNode (as_mapping() -> Option<SpannedMapIter>, as_sequence() -> Option<&[SpannedNode]>, get(&str), lookup(&[PathSegment]), scalar_value(), scalar_style(), and scalar_tag()), closing the marked-yaml migration gap found in rattler-build.
  2. Complete primitive From impls on ayaml::Number (i8, u8, i16, u16, isize, usize, and f32 alongside existing 32/64/128-bit and f64 impls), closing the ergonomic gap found in zizmor.
  3. Cleaner Debug formatting on ayaml::Error, omitting internal bookkeeping counters (reserved_after_bom, path_len, context_len) so diagnostic snapshots stay focused on public fields (kind, code, span, location, message, limit, source).
  4. Configurable duplicate-key rejection in libyaml-compat via compat::ParseOptions::with_allow_duplicates(false), letting linters such as prek accept libyaml-style under-indented flow continuations while keeping ErrorCode::DuplicateKey enforcement.
use ayaml::{Number, ScalarStyle, SpannedTree};
let yaml = "package:\n name: \"demo\"\n version: 3.10\nitems:\n - a\n - b\n";
let tree = SpannedTree::parse(yaml)?;
let root = tree.document(0).expect("root document");
let pkg = root.get("package").expect("package mapping");
let version = pkg.get("version").expect("version scalar");
assert_eq!(version.scalar_value(), Some("3.10"));
assert_eq!(version.scalar_style(), Some(ScalarStyle::Plain));
assert_eq!(version.span().slice(yaml), Some("3.10"));
let name = pkg.get("name").expect("name scalar");
assert_eq!(name.scalar_value(), Some("demo"));
assert_eq!(name.scalar_style(), Some(ScalarStyle::DoubleQuoted));
let items = root.get("items").and_then(|n| n.as_sequence()).expect("items seq");
assert_eq!(items.len(), 2);
assert_eq!(Number::from(42_u16), Number::from(42_u64));
assert_eq!(Number::from(-7_i8).as_i64(), Some(-7));

Honest caveats and migration considerations

Section titled “Honest caveats and migration considerations”
  • Binary size depends on build profile and transitive YAML crates: In LTO CLI builds where ayaml replaces serde-saphyr completely, stripped binaries shrank by -596.7 KiB (prek) to -653.7 KiB (ast-grep). In non-LTO builds replacing a parse-only library (syntect, +500.2 KiB), large monomorphized Serde enums (zizmor, +934.2 KiB), or workspaces where external published dependencies still unconditionally pull serde_yaml (rattler-build: rattler_conda_types, rattler_upload, and text-stub-library, +2.01 MiB while both YAML engines coexist), binaries grow modestly until LTO is enabled or upstream transitive dependencies migrate.
  • YAML 1.2.2 vs YAML 1.1 policy differences: Projects relying on <<: merge keys (prek) opt in explicitly with ParseOptions::new().with_merge_keys(true). Tools whose emitted YAML must also be consumed by YAML 1.1 parsers (such as PyYAML) should explicitly quote YAML 1.1 booleans (yes/no/on/off) and ISO dates. Linters accepting libyaml-style under-indented flow continuations can enable libyaml-compat with compat::ParseOptions::new().with_allow_duplicates(false).
  • Expected test-snapshot updates: Suites asserting exact diagnostic or serialized YAML strings (insta) typically see two benign changes: richer field-path error prefixes and exact start..end spans, and canonical double-quoted scalars ("3.11" rather than '3.11').