Skip to content

perf: replace byte-by-byte takeByte() with block reads in xml.zig and json.zig#150

Merged
vmvarela merged 1 commit into
masterfrom
issue-135/block-reads-xml-json
May 10, 2026
Merged

perf: replace byte-by-byte takeByte() with block reads in xml.zig and json.zig#150
vmvarela merged 1 commit into
masterfrom
issue-135/block-reads-xml-json

Conversation

@vmvarela
Copy link
Copy Markdown
Owner

Summary

  • Replaces takeByte() loops that read stdin one byte at a time with reader.allocRemaining(allocator, .unlimited), which issues a single bulk read through the Io vtable
  • For a 10 MB input this reduces reader dispatch iterations from ~10 M to a handful of 4 KB-sized reads
  • No API changes; all existing integration and unit tests pass

Functions updated

  • src/xml.zig: loadXmlInput, getXmlColumnNames, summarizeXml
  • src/json.zig: loadJsonArray

Note on readLine in json.zig

The readLine function (NDJSON line reader) uses takeByte() for a different purpose — reading until \n — and is intentionally left unchanged, as it cannot be replaced with allocRemaining.

Closes #135

… json.zig

Replace the tight takeByte() loops that read stdin one byte at a time
with reader.allocRemaining(allocator, .unlimited), which issues a single
bulk read using the Io vtable dispatch instead of one dispatch per byte.

Functions updated:
  - xml.zig: loadXmlInput, getXmlColumnNames, summarizeXml
  - json.zig: loadJsonArray

No API changes; all existing tests continue to pass.

Closes #135
@vmvarela vmvarela added type:chore Maintenance, refactoring, tooling priority:low Nice to have, do when possible size:s Small — 1 to 4 hours tech-debt Technical debt — address proactively labels May 10, 2026
@vmvarela vmvarela merged commit 27a85bd into master May 10, 2026
5 checks passed
@vmvarela vmvarela deleted the issue-135/block-reads-xml-json branch May 10, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:low Nice to have, do when possible size:s Small — 1 to 4 hours tech-debt Technical debt — address proactively type:chore Maintenance, refactoring, tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: replace byte-by-byte takeByte() with block reads in xml.zig and json.zig

1 participant