Repository navigation
Releases
v0.3.0
A stream of documents read whole, in order or on many threads; a faster
parser and writer; and eight kinds of input the YAML spec forbids, which
this release refuses where 0.2.0 read them.
New
yaml.parseDocuments: every document of a stream into a slice, in
order.parseFromSlicestill reads one document and refuses more.yaml.parseDocumentsConcurrently: the same documents, read side by
side on astd.Io's threads. The stream is cut between documents and
each piece read by a task of its own; the values and any error are
those ofparseDocuments. A stream under 128 KiB is read in order,
and the allocator must be threadsafe. 20,000 documents (4.4 MB), on a
shared machine with about 10 of its 18 cores busy: 29.7 ms in order,
12.8 ms on 4 threads, 8.2 ms on 8.Parser.text_lifetime = .next_event: an event's text lives until the
next event, as libyaml's does, and its memory is reused. Reading the
benchmark's 4.9 MB as events then peaks at 2.8 KB, where it held 4.2
MB. The default is as before.
Faster
- Writing YAML (
stringify) is 58% faster: text goes out in runs, and
most scalars skip the character-by-character analysis. - Parsing to events takes 43% fewer instructions (21.5 ms to 12.3 on
the benchmark): the parser reads with the one-pass reader the node
tree already used, with the same events, errors and diagnostics. - Long comments and block scalars read 15 to 26% faster, their text
found 64 bytes at a time with SIMD.
Stricter: eight kinds of input the spec forbids, now refused
0.2.0 passed the whole yaml-test-suite and still read each of these,
found by fuzzing against libfyaml (below). The YAML reference parser
refuses every one:
- A tag or anchor followed at once by
[or{inside a flow
collection:[!{a: b}]. Put a space after it:[! {a: b}]. - A block scalar at the column of the mapping or sequence it belongs
to:k:and then|at the start of the next line. Indent it. - A block collection on the same line as an empty key's
::: - a.
Only an explicit? key's value can start one there. - Text after
...on its line before any document:... a. - A
?with no space after it inside a flow collection:[?]. - A reserved directive (
%FOO) with no---after it, or after a
document with no...before it. - Inside a flow collection, a
[or{right after the:of a key
that is not quoted:{a:[b]}. Put a space after the:. A quoted
key's value may still follow at once, as in JSON:{"a":[b]}. - A tab as the indentation of a flow collection in a block:
key:and
then a tab and[a]on the next line. Indent with spaces.
If a file that read with 0.2.0 now fails with one of these errors, the
file is not YAML 1.2.2. One valid input 0.2.0 refused now reads: a
comment line indented with a tab right after a block scalar, at the end
of a document. yaml events also now escapes \0 \a \v \f \e \N \_ \L \P as the test suite's notation does.
Checked against another reader
zig build differential -Ddifferential holds yaml.zig's events to
libfyaml's on every test-suite input, and --fuzz fuzzes the two
against each other. The YAML reference parser, generated from the
spec's grammar, settles each disagreement
(tools/differential/arbitrate.sh). An hour's fuzzing campaign found
the last two refusals above and the tab-indented comment; the rest of
what it recorded were libfyaml's mistakes, inputs all three refuse, or
quirks of the reference parser's own.
CI now also fetches every dependency from nothing and checks its hash.
Python
pyyaml-zig 0.3.0 is built on this release.
Also
Full Changelog: v0.2.0...v0.3.0 (pull request #1)
v0.2.0
v0.1.0
Full Changelog: https://github.com/kmoneil/yaml.zig/commits/v0.1.0