Skip to content

docs(streaming): measure the streaming walks against the legacy reader per release band (#205) - #343

Merged
DrunkOnJava merged 13 commits into
mainfrom
stream3/throughput
Oct 26, 2026
Merged

DrunkOnJava merged 13 commits into
mainfrom
stream3/throughput

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Goal 3 of #205's streaming lane: measure the streaming walks against the legacy reader per release band, write the table and the command that reproduces it into docs/streaming/README.md.

Stacked on #333. The branch contains #333's commits because the R2004 measurement uses its R2004ObjectWalker; the merge train lands #333 first, after which this PR's diff is one example and one README section (merge main in, no rebase). No ARCHITECTURE.md section, no source change outside examples/.

What changed

  • examples/stream_throughput.rs: reads each drawing into memory, times the whole streaming walk in 256-byte reads from a SliceSource (FlatWalker for R13 to R2000, R2004ObjectWalker for the R2004 family) against DwgFile::from_bytes plus all_objects, and for the R2004 family against from_bytes plus a read of every section; fails if the walk and the legacy reader disagree on the record count. Best and median of N runs, one JSON line per file.
  • docs/streaming/README.md: a "Throughput" section with the six-drawing table, the command, the machine, the load and what is not measured.

Result (best of 40, in memory, Apple M2 Max, 2026-10-26, machine loaded)

Release Streaming walk Legacy all_objects Legacy read of every section
R14 387 MB/s 7,025 MB/s n/a
R2000 388 MB/s 6,266 MB/s n/a
R2004 190 MB/s 963 MB/s 974 MB/s
R2010 156 MB/s 824 MB/s 805 MB/s
R2013 199 MB/s 1,095 MB/s 980 MB/s
R2018 203 MB/s 1,153 MB/s 1,012 MB/s

The walk is 5 to 6 times slower than the legacy decode on the R2004 family and 16 to 18 times slower than the legacy bulk copy on R14 and R2000, while it verifies what the legacy reader does not (every record's CRC, every page's checksums, the page map twice) and holds a fixed state. Where its time goes has not been profiled. R2007 is measured by stream_r2007_timing in #340.

Test plan

No unit tests. The measurement tool is an example (a second run of 25 gave the same best times within 3% for the walks and 7% for the legacy reader); cargo fmt --all -- --check and cargo clippy --all-targets --all-features -- -D warnings pass. Corpus counts do not move: nothing under src/ changed.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. No Autodesk SDK, ODA Teigha/Drawings SDK or GPL DWG implementation source was consulted or imported. My contribution is based on timing this crate's own readers on the pinned public drawings; no algorithm-description comments from other projects were read.

)

R2004ObjectWalker is the whole-file walker with AcDb:AcDbObjects framed
into records in section order: each record's MS, R2010 MC, payload, CRC,
type and handle, with fixed state and a self-contained checkpoint. The
payload (the bytes the legacy RawObject::raw holds) is handed out as it
arrives and committed by an Object step after the CRC, type and handle
checks. Records come out in stream order with the handle they carry; the
AcDb:Handles map is not read and nothing is indexed. The walker refuses an
object page the page map lists out of order or a hole (ObjectsOrder)
rather than keep an index; every pinned drawing lists them in order.

Measured on the 28 pinned R2004-family drawings (8,007 records): the
records tile the section exactly after the 4-byte 0x0DCA prologue, every
record's CRC (seed 0xC0C1, MS through the last payload byte, MC included)
verifies, and every MC is at most 8 times the payload; three other CRC
readings agree with none (ARCHITECTURE.md 7v). The legacy walker never
checked the CRC.

Running the R13 to R2000 walk on two 1.3 MB drawings found that it refused
an object map chunk over 2,032 bytes. A chunk's size counts its own two
bytes, so AutoCAD's full chunk is 2,034 (2,033 and 2,034 in
sample_AC1014.dwg and sample_AC1015.dwg); the walk failed on both with
MapChunk. The limit is 2,034 now and both drawings are in verify_walk.py
(1,242 and 1,047 records equal to the legacy reader's).

R2004ObjectCheckpoint (DWGO, about 100 KB) holds the file walker's
checkpoint, the object section's id, the framer's cursors and the section
bytes not yet framed; restore requires a reachable state (the framer's CRC
is recomputed where its bytes are held, its MC re-read, the section checked
against the table and the unframed bytes against the section walker's
cursor). The wasm kernel gains run_objects and resume_objects.

verify_objects.py: every printed line equals an independent Python framing
of the independently assembled section, the AcDb:Handles map and the legacy
reader, on the four fixtures and the 28 drawings; fixed and proptest chunk
schedules; real object sections repacked at page sizes from 4 bytes and
with other sections' pages interleaved; fresh-process resume at 1,374 stops
including every framer stage and an MS and an MC split across pages; bit
flips, truncations and 118 resealed forgeries of checkpoints; 47 corrupt
object sections each ending in its named error with exactly the records
before it. verify_wasm_objects.py restores native checkpoints in the wasm32
kernel and the kernel's own in the native build, byte-identical in 611 of
611. Both run in the Streaming E2E job (timeout 30 minutes).
…etic and reject an MC of 2^64 (#205)

A forged but CRC-valid DWGO checkpoint could overflow u8 arithmetic in the
framer's reachable-state check (words 1 with a field length of 255) or reach
positions near u64::MAX, and an MC whose tenth byte held more than one payload
bit decoded to a small value because the shift dropped it. The check now
bounds every field before it computes with it, the stream length is bounded at
2^62 (more is CounterOverflow), the wrapper checks the framer first, and an MC
of 2^64 or more is RecordHeader, both when read and when re-read from a
checkpoint. verify_objects.py forges each case (158 resealed forgeries now)
and corrupts a real record's MC to 2^64 (49 corrupt sections).
…r per release band (#205)

examples/stream_throughput.rs times the whole streaming walk (FlatWalker for
R13 to R2000, R2004ObjectWalker for the R2004 family) against the legacy
reader on in-memory copies of the six ACadSharp drawings, best of 40, and
fails if the two disagree on the record count. On an Apple M2 Max the walk
runs at 387 and 388 MB/s on R14 and R2000 (legacy bulk copy 7,025 and 6,266
MB/s) and 156 to 203 MB/s on R2004 to R2018 (legacy decode of every section
805 to 1,012 MB/s): the fixed state, the exact demands and the verification
cost a factor of 5 to 18 in memory. The README states the command, the
machine, the load and what is not measured.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T19:53:15.607705Z aa0d906 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant