Repository navigation
perf(datasource): helm indexes, PyPI pages and image digests stream - #294
Merged
Merged
Conversation
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…differential test Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
sweepies
force-pushed
the
perf/stream-rest
branch
from
November 13, 2026 10:04
409b784 to
907bd97
Compare
The walk sat on yaml-rust2, whose scanner is not libyaml; every scanner divergence from the buffered serde_yaml_ng derive had to be compensated in code. It now reads libyaml-safer's events — the safe-Rust port of the unsafe-libyaml serde_yaml_ng runs — forced to UTF-8 the way serde's own parser is, so scanner behaviour matches by construction and the Chars filter, colon_in_flow tracking and FEFF column tricks are gone. Anchored nodes are recorded whole as they close and an alias replays into a stack of frames, the way serde's jump gives each alias its own cursor, so a nested alias replays ahead of the outer frame's tail. A recording past serde's 128-deep recursion budget ends as a too-deep marker that fails only if aliased into a kept position — deep ignored anchors still succeed — keeping clone, replay and drop shallow. The whole derive runs under catch_unwind so a libyaml-safer panic is a failed document, never a worker abort. Alias work keeps serde's hundred-jumps-per-event bound checked at stream end, plus a fixed replayed-event ceiling that only an alias bomb reaches; the residual is documented and tested on both sides. Differential coverage against the verbatim buffered derive now spans the hand table from both review rounds — directives, tags, tabs, U+2028/29, NEL, BOMs, UTF-16, control characters, flow nesting 249-300, alias bombs, redefined and nested anchors, merge keys and duplicate keys spelled differently — plus 6,000 generated documents, each at whole, 1-, 3-, 7- and 64-byte chunkings. Deep cases run on a 2 MB thread the way production does. No case diverges. On the real 27.6 MB bitnami index the walk peaks at 59.9 MB in 0.30 s against the buffered derive's 273.9 MB in 0.46 s. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Recording every event into every open anchored tree kept a copy per enclosing anchor: 128 anchors nested around a scalar stored it 128 times, and ~60 MB of that shape aborted the process. Open recordings now share one append-only event buffer and each anchor binds its start..end span — a nested span covers the inner anchors' events without holding them again — so anchored memory tracks the anchored events, not the nesting. An abandoned past-budget recording is simply never bound, which fails a kept alias the way serde's remaining-depth check would, and an honest index records nothing. On the real 27.6 MB bitnami index the walk still peaks at ~59.8 MB in 0.29 s against the buffered derive's ~274 MB in 0.41 s, same derived bytes. On 128 nested anchors around a scalar the peak is 7.8 MB for a 1 MB scalar (was 148 MB) and 35.6 MB for a 10 MB scalar (was 1.29 GB), under the buffered parse's 51.8 MB. Also asserted as a residual: a tag immediately followed by `,` in a flow collection, where libyaml-safer's scanner panics and C libyaml emits the Tag token — the buffered parse accepts, the walk's catch_unwind fails the document. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #288. Three transforms still held their whole response: Helm
index.yaml, PyPI simple-index pages and container image digests. They now derive as the bytes arrive.crates/datasource/src/helm.rs):serde_yaml_ng::from_readerread the whole document and built a full value tree, about ten times the document's size. It is replaced by a pull-event walk overlibyaml-safer's parser.version,created,digest,deprecated,sourcesand theartifacthub.io/changesannotation..inf/.nan, nulls), including its quirks: tagged scalars read verbatim as strings, a non-null!!nullis an error, an empty plain scalar reads as an empty map or sequence, and the last duplicate key wins.serde_yaml_ngbecomes a dev-dependency of the datasource crate (the test oracle);libyaml-saferjoins it.>is allowed in attributes,data-yankedis read, anchors may split across chunks, and malformed UTF-8 fails the document. The catalog output is unchanged.HashReadupdates SHA-256 per read while the document parses, and stores the finalised digest with no second pass and no retained body (image-platform,sbom-os).No behaviour change.
Proof:
derive_parityruns every derive over every fixture body whole and in 997-byte and 1-byte chunks: byte-identical output for all five touched transforms, error cases included.a_simple_page_scans_anchors_the_samecovers the HTML fallback, which no fixture exercised. It also caught a bug in the first draft, now fixed.helm-index,pypi-index-catalog,image-platform,sbom-os, plusterraform-catalogandpypi-simple-catalog, whose listed source file changed.Peak memory (release binary, VmHWM, VM):
index.yaml(27.6 MB)Parity with the buffered derive (review fixes)
Two review rounds compared origin/main's buffered derive with the walk. The first found ten divergence classes and a PyPI panic (a multi-byte character split at a chunk boundary). The second found a process abort and more divergences that came from yaml-rust2's scanner (tabs,
%YAMLversions and unknown directives, U+2028/U+2029, the flow-nesting cap).The walk now reads events from
libyaml-safer, a line-by-line safe-Rust port of the unsafe-libyaml that serde_yaml_ng uses, run against libyaml's test suite, with UTF-8 forced as serde_yaml_ng forces it. Scanner behaviour matches by construction; the walk only emulates serde's layer (scalar resolution, duplicate keys, the 128 recursion budget, alias replay, the alias jump bound). yaml-rust2 is gone from this crate.serde_yaml_ngis a dev-dependency only), about 140 hand cases from both reviews plus 6,000 seeded documents, each fed whole and in 1-, 3-, 7- and 64-byte chunks; output must be byte-identical or both must fail. Zero divergences. The PyPI scan and image digests are checked at every chunk size 1–16 on non-ASCII pages.Peak memory and time on the bitnami index (27.6 MB): 273.9 MB / 0.46 s buffered → 59.9 MB / 0.30 s streaming.
Nested anchors share one recording: each event is stored once while any anchor is open, and an anchor is a range into that buffer, so 128 nested anchors around a 10 MB value peak at 35.6 MB (it was 1.29 GB, and the old derive uses 52 MB).
Two residuals, both fail-closed and adversarial only, both asserted by tests:
panic!("TODO: What is expected here?")in its scanner) on a tag followed directly by,in a flow collection, such as[!x, a], where C libyaml emits the tag. The derive turns the panic into a failed document. Helm indexes don't contain it.A stress run found no crash: 96 nesting cases up to 100k levels on a 2 MB stack, about 335k fuzzed inputs, and 4,000 mutations of a real index compared against the old derive.
Versions:
helm-index,pypi-index-catalog,pypi-simple-catalog,terraform-catalog,image-platform,sbom-os→ 3.