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.
Cohort summary
Section titled “Cohort summary”| 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 |
Methodology
Section titled “Methodology”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_64host (Intel Skylake-class quad-core @ 2.60 GHz,performanceCPU frequency governor) pinned to a single core withtaskset -c 2. - 3-round interleaved A/B protocol: Each benchmark runs three independent
rounds alternating baseline and
ayamlexecution 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]wrappingstd::alloc::System. Process peak RSS is measured viaru_maxrss(wait4). - Exact semantic oracles: Beyond running each project’s test suite, we
verified deterministic semantic equivalence between baseline and
ayamloutputs (binarySyntaxSetdumps, canonical sorted JSON digests, and CLI command outputs).
Per-project findings
Section titled “Per-project findings”1. trishume/syntect (yaml-rust2 to ayaml)
Section titled “1. trishume/syntect (yaml-rust2 to ayaml)”- Upstream:
trishume/syntectv5.3.0 at4efbec173db6ea83caaf7a34994cb7e4d038a13e(MIT) - Diff scope:
Cargo.tomlandsrc/parsing/yaml_load.rs; zero third-party YAML crates left incargo tree/Cargo.lock(-4normal crates, 4unsafe-using crates removed). - Correctness: 222/222
--all-featurestests plusmake syntestandmake syntest-fancypass; serializedSyntaxSetbinary dump across all 191.sublime-syntaxfiles (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, CV0.17% -> 0.05%) ondefault-onig,-80.19 ms(-3.13%, CV0.64% -> 0.32%) ondefault-fancy. - Isolated 191-file YAML parse: 2.03x faster (
Value,102.97 ms -> 50.73 ms, CV0.10% -> 1.97%) / 2.67x faster (Tape,38.55 ms, CV0.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) and61,872 -> 62,316 KiB(+0.72%, load + build); non-LTO strippedexamples/syntestbinary:+500.2 KiB(+8.68%).
- End-to-end Criterion
- Guide takeaways: Replacing
hash.get(&Yaml::String(k.to_owned()))with zero-allocationMapping::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-grepv0.51.3 at57c4bef6ade910580e43caf04979def503bb4dde(MIT) - Diff scope: 18 files (
+42/-53lines); zero third-party YAML crates left incargo tree/Cargo.lock(-7CLI crates,-12onast-grep-config/ast-grep-outline,-2/-3unsafe-using crates). - Correctness: 822/822 pure-Rust tests and
clippy -D clippy::allpass; canonical JSON across all 216 bundledDEFAULT_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%, CV0.71% -> 0.17%).- End-to-end
ast-grep outlineCLI startup: 1.78x faster on Rust (13.993 ms -> 7.882 ms, CV0.48% -> 0.20%) / 1.85x faster on TypeScript (13.431 ms -> 7.276 ms, CV0.53% -> 0.07%). - YAML emission: ~parity (
1.714 ms -> 1.747 ms,+1.93%, CV0.19% -> 0.12%). - Heap, RSS & binary size: process Peak RSS
11,388 -> 11,388 KiB(0.00%); multi-docDeserializerallocated+2.1%peak /+9.2%allocs across 216 small documents (logged for post-1.0 cross-document scratch reuse) andto_stringmaterialized an intermediateValue(8.9 KiBvs2.1 KiBpeak); stripped LTOast-grepCLI binary shrank by -653.7 KiB (-1.19%).
- Guide takeaways:
ayaml’s out-of-the-box YAML 1.2.2 defaults replacedserde-saphyr’s explicit options boilerplate (strict_booleans, literal<<,.inf/.nanpass-through), whileDeserializer::next_borrowed::<Option<T>>()andDocumentDeserializermapped 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/zizmorv1.33.1 at15caca4fdcfee377c25b101b6c6ad3ec68962159(MIT) - Diff scope: 36 files (
+268/-268lines); zero third-party YAML crates left incargo tree/Cargo.lock, eliminating 295 non-commentunsafeblocks/items acrossyaml_serdeandlibyaml-rswith zero new transitive dependencies (zizmorCLI299 -> 298,github-actions-models22 -> 19,yamlpatch41 -> 39). - Correctness: 595/595 offline assertions pass (578 byte-for-byte unchanged,
17 expected diagnostic/quote-style
instasnapshot diffs including 10 with richer field paths); end-to-endzizmor --offline --format=jsonacross 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, CV0.05% -> 1.01%), 4.20x lower peak heap, 3.49x fewer allocations. ValueDOM: 2.18x faster (9.243 ms -> 4.235 ms, CV0.03% -> 1.27%), 5.76x lower peak heap, 8.79x less total allocated bytes.Tape: 3.58x faster (2.580 ms, CV0.99%), 41.1x fewer allocations.- End-to-end LTO CLI:
-2.13 ms(396.550 ms -> 394.418 ms,-0.54%, CV0.10% -> 0.14%); Peak RSS65,220 -> 66,292 KiB(+1.64%); stripped LTO binary+934.2 KiB(+2.67%).
- Typed models: 1.79x faster (
- Guide & API takeaways:
Error::kind()directly replacedzizmor’s double-parse syntax-vs-schema workaround,#[serde(with = "...::singleton_map")]was deleted outright onDeserializeenums, and this migration motivated adding complete primitiveFromimpls onNumberplus a cleanerErrorDebugformat.
4. j178/prek (serde-saphyr + granit-parser to ayaml)
Section titled “4. j178/prek (serde-saphyr + granit-parser to ayaml)”- Upstream:
j178/prekv0.5.12 atf637c380d18dcbde297c7b5cd0adc73f54ddefcd(MIT) - Diff scope: 11 files (
+202/-171lines); removed bothserde-saphyr 2.1.1andgranit-parser 2.1.0(-6normal crates, 337 non-commentunsafeblocks/items eliminated acrossencoding_rs,arraydeque, andnum-traits).clippy -D warningsclean (0 warnings). - Correctness: 741/743 unit and YAML integration assertions pass (17
expected
instadiagnostic-format diffs, plus 2 documented policy differences: Prometheus-style under-indented flow sequences under strict YAML 1.2.2 vscompat, and raw\tdisplay in custom Serde error strings); all 3 Fat-LTOcheck-yaml-*hooks exit 0. Switching--unsafesyntax checks toayaml::parse_eventsalso resolved an upstreamTODOaround undefined anchors. - Performance, memory & size (21 to 22 files, 113.2 to 115.5 KiB, Fat-LTO CLI):
- Isolated
check-yaml: single-docparse_tape4.71x faster (6.223 ms -> 1.322 ms, CV0.23% -> 1.13%, 6.68x less total alloc, 6.08x fewer allocs);from_str::<IgnoredAny>4.13x faster (1.507 ms, CV0.04%, 10.54x less total alloc,-11.3%max peak);--multi4.76x faster (6.566 ms -> 1.380 ms, CV0.27% -> 0.26%);--unsafe(parse_eventsvsgranit-parser) 2.29x faster (2.781 ms -> 1.217 ms, CV1.21% -> 0.13%, trading+30 KiBeager 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%, CV1.66% -> 0.61%, Peak RSS-776 KiB/ -6.21%), 1.46x faster (multi,16.770 -> 11.481 ms,-31.5%, CV0.58% -> 0.43%), 1.14x faster (unsafe,12.856 -> 11.246 ms,-12.5%, CV0.44% -> 0.74%, Peak RSS-512 KiB/ -4.19%). - Stripped Fat-LTO
prekbinary: -596.7 KiB (-4.20%) smaller (14,559,760 B -> 13,948,752 B).
- Isolated
- 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-buildv0.81.0 at52ec3988ee57213b039091f98d4d503148a9e417(BSD-3-Clause) - Diff scope: 74 files across all 9 workspace crates +
benches/parse_file.rs(+1,024/-398lines). Removed all directserde_yaml 0.9.34andmarked-yaml 0.8.0dependencies; completely eliminatedmarked-yaml,yaml-rust2,hashlink(81unsafe),arraydeque(72unsafe), anddoc-commentfromCargo.lock(-4CLI crates,-10normal crates onrattler_build_yaml_parser, 153unsafeblocks/items eliminated workspace-wide and 417+ insiderattler_build_yaml_parser). - Correctness: 998/998 offline workspace tests pass (
clippy -D clippy::allclean; 983 unchanged, 15instasnapshot diffs: 9 objectively improvedmiettesource spans fixingmarked-yaml’s colon-offset mapping starts and single-word truncation + 6 quote-style diffs). Canonical JSON across all 149 validrecipe.yamlfiles (179,815bytes) and end-to-endrattler-build --no-config build --render-onlymatch bit-for-bit. - Performance, memory & size (3-round pinned CPU):
- Built-in unmodified Criterion
benches/parse_file.rs(5,000 samples, incl. fileopen/read/mmapsyscalls):from_reader1.78x faster (26.377 us -> 14.835 us, CV0.50% -> 0.62%),from_string1.73x faster (27.016 us -> 15.653 us, CV1.81% -> 0.97%),from_mmap1.53x faster (32.285 us -> 21.077 us, CV1.50% -> 0.41%). - 149-recipe pinned corpus (93,153 B): spanned DOM (
parse_yaml) 1.91x faster (3.2577 ms -> 1.7028 ms, CV0.27% -> 0.60%, 3.64x fewer allocs); full Stage0 recipe parser 1.52x faster (5.6376 ms -> 3.7105 ms, CV0.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, CV0.26% -> 1.48%, 3.80x lower max peak, 8.91x less total alloc, 5.49x fewer allocs). Reference zero-copyTape::parsereached 2.21x faster (CV0.09%, 23.6x fewer allocs, 3.30x lower max peak) andSpannedTree::parsereached 1.68x faster (CV0.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, CV0.26% -> 0.41%, startup-bound on one 2.2 KiB file); corpus Peak RSS13,268 -> 13,268 KiB(0.00%); CLI Peak RSS27,680 -> 29,124 KiB(+5.22%) and stripped non-LTO binary+2.01 MiB(+2.85%) while externalrattler_*crates still linkserde_yaml.
- Built-in unmodified Criterion
- 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 replacingmarked-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:
- Full read-only traversal on
SpannedNode(as_mapping() -> Option<SpannedMapIter>,as_sequence() -> Option<&[SpannedNode]>,get(&str),lookup(&[PathSegment]),scalar_value(),scalar_style(), andscalar_tag()), closing themarked-yamlmigration gap found inrattler-build. - Complete primitive
Fromimpls onayaml::Number(i8,u8,i16,u16,isize,usize, andf32alongside existing 32/64/128-bit andf64impls), closing the ergonomic gap found inzizmor. - Cleaner
Debugformatting onayaml::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). - Configurable duplicate-key rejection in
libyaml-compatviacompat::ParseOptions::with_allow_duplicates(false), letting linters such asprekaccept libyaml-style under-indented flow continuations while keepingErrorCode::DuplicateKeyenforcement.
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
ayamlreplacesserde-saphyrcompletely, 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 pullserde_yaml(rattler-build:rattler_conda_types,rattler_upload, andtext-stub-library,+2.01 MiBwhile 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 withParseOptions::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 enablelibyaml-compatwithcompat::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 exactstart..endspans, and canonical double-quoted scalars ("3.11"rather than'3.11').