Go to file
Mihaela Mihaljevic 8d1fcaf020 docs: point the benchmark site at Codeberg Pages
The GitHub Pages deployment died with the deleted repository. The site
now serves from the pages branch at
https://mihaela.codeberg.page/PureYAMLStreaming/ via a git-pages
webhook; the loader fetches the gzipped module and decompresses
client-side, and the same-origin COOP/COEP service worker provides
crossOriginIsolated for the true-streaming benchmark without server
headers. All assets verified serving, module byte count intact.

Closes #2
2026-07-05 06:48:57 +02:00
.forgejo/workflows chore(rules): track shared-rules baseline v1.1.0 2026-07-02 21:38:06 +02:00
.github/workflows feat: show streaming document preview 2026-06-07 01:10:38 +02:00
docs feat: scaffold PureYAML streaming incubator 2026-06-06 21:23:21 +02:00
scripts fix: harden browser WASM benchmark 2026-06-06 23:20:03 +02:00
Sources feat: add true browser WASI streaming benchmark 2026-06-07 00:32:11 +02:00
Tests/PureYAMLStreamingTests feat: publish WASM streaming smoke site 2026-06-06 22:06:38 +02:00
WasmSite fix: batch streaming document rendering 2026-06-07 01:22:45 +02:00
.gitignore fix: harden browser WASM benchmark 2026-06-06 23:20:03 +02:00
.rules-version chore(rules): track shared-rules baseline v1.1.2 2026-07-05 00:27:41 +02:00
.swiftformat chore(rules): track shared-rules baseline v1.1.0 2026-07-02 21:38:06 +02:00
.swiftlint.yml chore(rules): track shared-rules baseline v1.1.0 2026-07-02 21:38:06 +02:00
LICENSE feat: scaffold PureYAML streaming incubator 2026-06-06 21:23:21 +02:00
Package.resolved chore: repoint dependencies and README to codeberg.org/Mihaela 2026-07-04 23:05:30 +02:00
Package.swift chore: repoint dependencies and README to codeberg.org/Mihaela 2026-07-04 23:05:30 +02:00
README.md docs: point the benchmark site at Codeberg Pages 2026-07-05 06:48:57 +02:00

PureYAMLStreaming

macOS Linux Windows WASM WASM Site

Experimental full-streaming incubator for PureYAML.

This package is intentionally separate from PureYAML while the chunked input, document streaming, and eventual event streaming APIs settle. It depends on PureYAML for the stable model and parser semantics, then adds streaming input adapters around that stable core.

Status

Prototype.

The current implementation streams YAML input in chunks, detects document-boundary candidates, and emits one parsed PureYAML.Stream.Document at a time. That gives bounded memory for multi-document streams where each document fits in memory.

It is not yet a token-level YAML scanner. A future milestone will replace the document-boundary scanner with a resumable token scanner that can feed event-level consumers directly.

Memory Contract

  • parseDocuments is bounded by the largest current document plus parser state.
  • collectDocuments is a convenience helper and retains all returned documents.
  • Anchors, aliases, merge keys, and PureYAML.Model.Value construction can require retaining semantic state until the current document is complete.
  • Future event-level APIs should be lower memory than document-level APIs, but they still cannot promise constant memory for every YAML feature.

Example

import Foundation
import PureYAMLStreaming

let url = URL(fileURLWithPath: "stream.yaml")
let parser = PureYAMLStreaming.Parser()

try parser.parseDocuments(from: url) { document in
    print("document", document.index, document.value)
}

WASM Browser Benchmark Site

Live site:

https://mihaela.codeberg.page/PureYAMLStreaming/

Deployed from the pages branch: bash scripts/build-wasm-site.sh, copy WasmSite/ (with the gzipped module, not the raw one) onto that branch, and push; a repository webhook triggers the git-pages redeploy.

Build the Swift WASI benchmark executable and copy it into the static test site:

bash scripts/build-wasm-site.sh

The build script requires npm so it can stage the pinned browser WASI shim as a local WasmSite/vendor/ asset. The deployed page does not import the shim from a runtime CDN.

Serve the site locally:

bash scripts/serve-wasm-site.sh

Then open http://localhost:8080 and click Run Buffered Benchmark or Run True Streaming Benchmark. The page loads pureyaml-streaming-wasm-smoke.wasm, lets you choose from 10+ public multi-megabyte YAML files, and reports fetch time, Swift parse time, throughput, document count, stdout JSON, and a timestamped run log.

Inside Swift, SwiftWASIHTTPClient.HostHTTPClient models that host-provided HTTP response. The benchmark then parses the response body through PureYAMLStreaming.ChunkedUTF8Reader and ResumableDocumentScanner, reporting chunk count, chunk size, scanner document-source emissions, fetch time, parse time, throughput, document count, and stdout JSON.

The buffered benchmark fetches the selected YAML file in JavaScript before invoking the WASM guest. It keeps SwiftWASIHTTPClient.HostHTTPClient in the loop to model the host-response boundary.

The experimental true-streaming benchmark requires crossOriginIsolated, SharedArrayBuffer, Worker, and Atomics.wait. A same-origin COOP/COEP service worker enables that mode on localhost and Codeberg Pages. In this path, the main thread reads fetch().body with a ReadableStream reader, writes each network chunk into a SharedArrayBuffer ring buffer, and a Worker-owned WASI runtime serves those bytes through a blocking custom stdin fd_read. Swift then parses stdin with ChunkedUTF8Reader without calling readDataToEndOfFile().

Relationship To PureYAML

PureYAML remains the dependency-free core package. This package is the incubator for file, byte, and async streaming APIs. Stable pieces can move back into PureYAML later once the API and memory behavior are proven.