Repository navigation
perf(table): read a node table where it lies, without a JSON value tree - #20
Merged
adammharris merged 1 commit intoOct 26, 2026
Merged
Conversation
decode and decode_bare check the text in one pass and gather the top object's and each row's members as borrowed slices, then read the rows from those lists. from_value goes through the same reader over a parsed Value. On a 34 KB djot document a keystroke through the runtime row drops from 5.8x to 4.2x the compiled row's; the task stays in progress, since 3x is out of reach by the decode alone.
adammharris
deleted the
agent/backlog-table-decode-without-a-value-tree
branch
October 30, 2026 01:25
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.
What changed
table::decodeandtable::decode_bareread a node table where it lies,instead of parsing it into a
json::Valuetree first.json::check_rowsmakes one pass over the text. It refuses exactly whatjson::parserefuses, and as it goes it gathers the top object's membersand every row's members as borrowed slices of the text.
readwalks those two lists and allocates only for what theDocumentkeeps. It is generic over a small
json::Json/json::Objectpair,which both
&Valueand the newjson::Rawimplement. Sofrom_value(public, and still taking a
&Value) goes through the sameread, andthe two paths cannot drift.
ast::json::read_kindkeeps its signature. The newread_kind_inserves both kinds of object.
Such a row is refused either way, and the count says which refusal it
gets. Otherwise counting would cost a pass of its own.
Why
docs/tasks/table-decode-without-a-value-tree.md: every reparse through aruntime row decodes the language's table, and building the value tree was
most of what a keystroke cost. The task was written against the Zig engine.
The Rust port kept the same shape and the same cost.
bench_edit, i5-8279U, documents cut from this repository's docs:Task
This advances the task and does not close it. Its status moves to
in-progress, and it now records the numbers above. The done-when's 3xcan't be reached by the decode alone. On the 34 KB document, 3x leaves
about 0.5 ms to decode a 220 KB table. But building the
Documentfromrows already in hand costs 0.44 ms, and one checking pass over the text
costs about 0.4 ms. Reaching 3x needs a cheaper encode or a smaller table,
or the target has to be relaxed, and the task now says that choice is open.
Verification
decode_in_place_agrees_with_the_parsed_value(about 70hand-picked texts: malformed JSON, escapes in keys and strings, duplicate
keys, floats, out-of-range integers, the nesting limit, invalid UTF-8,
every refusal
readmakes) anddecode_in_place_agrees_on_damaged_tables(4,000 one- or two-byte mutations of a real table). Both hold
decodeanddecode_bareto the sameDocumentand the sameProblemasjson::parsefollowed by the value-tree reader. Each catches a plantedbug in the number reader.
table.rsandruntime.rspass unchanged.ship ci: test, cli-wasi, capi and version pass. The typescript job skipped itself (nonpm ciinbindings/typescripthere), so GitHub CI is the first run of it.