Repository navigation
ci: non-vacuous coverage-smoke corpus + a criterion noise floor (task #94, refs #17) - #19
Merged
Merged
Conversation
…age-smoke non-vacuous tests/fixtures/canonical/ held no .dwg file, so the CI job "Coverage smoke test (canonical corpus)" skipped with a warning on every run and provided zero regression protection (task #94). The corpus README said this was blocked on write-path Stages 2-5. It is not: file_writer::assemble_dwg_bytes lands a complete R2004-family byte buffer, handle_map::write_handle_map emits AcDb:Handles, and the ElementEncoder impls cover LINE / CIRCLE / ARC / POINT. Wiring those together with a common-entity-preamble writer (the exact inverse of common_entity::read_common_entity_data) produces files this crate's reader decodes end-to-end. - examples/build_fixtures.rs generates the corpus: four Apache-2.0, self-generated files (~1.2 KB each), one per version assemble_dwg_bytes accepts (R2004, R2010, R2013, R2018), each with AcDb:Header + AcDb:Handles + AcDb:AcDbObjects and five entities (2D LINE, 3D LINE, CIRCLE, ARC, POINT). Generation is byte-deterministic. - Measured with `cargo run --release --example coverage_report`: 20 decoded / 0 unhandled / 0 errored, aggregate decoded_ratio 100.0%. - ci.yml now fails when the corpus is empty instead of skipping, checks the committed bytes still match the generator, and asserts decoded_ratio >= 95.0 — the measured 100.0 minus one entity out of twenty. The margin is small on purpose: the ratio is a deterministic function of the committed bytes, not a timing measurement. - tests/canonical_corpus.rs is the tight companion gate under `cargo test`: it pins per-file entity counts AND decoded field values, so a bit-alignment regression that still "decodes" into garbage coordinates fails even though the ratio would stay at 100%. No byte of any Autodesk-, ODA-, or third-party-produced DWG is redistributed; provenance and the honest-scope note are in tests/fixtures/canonical/README.md.
…nfirming re-run Refs #17. Profiling first. An attribution probe (replace both compute_checksum call sites in build_section with black_box(0u32), re-run the bench) shows stage1_build_section/uniform_16k is 92% section_writer:: compute_checksum: 21.25 us -> 1.73 us. lz77_encode::compress is literal-only and performs no match search at all, so #17's premise — "the longest-match path of the encoder ... the most branch-predictor / alignment sensitive one" — does not hold: the four bench cells differ only in size, not in compressibility, and the moved cell is a serial rotate-and-add chain, not a matcher. That loop is `sum = rot1(sum) + b`, a strict loop-carried dependency of two 1-cycle ops. 2 cycles/byte is the floor and vectorisation is impossible (rot1 is 2x mod 2^32-1, the add is mod 2^32; they do not distribute). Measured cost is ~2.2 cycles/byte, already within ~11% of that floor. Then the layout hypothesis, tested. Six measurements of uniform_16k on an M2 Max, taking the minimum per-iteration time across criterion's 100 samples rather than the mean: rolled checksum, unperturbed ................ 20802 ns / 21893 ns rolled checksum, + unrelated fn in bitwriter 20960 ns 8-way unrolled + #[inline(never)], unperturbed 21830 ns 8-way unrolled + #[inline(never)], + that fn 20867 ns Everything lands in a 20.80-21.89 us band with no consistent ordering by build. The same source measured twice moves 5.2%. The unrolled + #[inline(never)] variant was therefore dropped: it stabilises nothing and it is not faster. What was actually unstable is the estimator. On a loaded machine criterion's mean reported 21.25 us -> 32.99 us (+55%) for the same binary where the minimum of the same samples showed +4.9%. A 21 us bench on a shared GitHub vCPU cannot support a 20%-ratio verdict on its own — which matches #13's run, where uniform_16k "regressed" 24% while three sibling cells improved 10-17%. So the fix is CI-side. A bench now fails only when all three hold: 1. ratio = pr_mean / main_mean >= 1.20 (threshold unchanged) 2. delta = pr_mean - main_mean >= 5000 ns 3. the same bench trips (1) and (2) again on an immediate re-run The table prints on every run regardless of the verdict, and the re-run only executes on the failing path. 5 us is chosen so the cells it exempts (alt_1k ~1.7 us, uniform_16k ~21 us) exercise the same build_sections code path as mixed_64k (~100 us) and mixed_256k (~334 us), which stay gated — no code path loses coverage. Also: - .github/scripts/criterion-gate.sh reads criterion's own estimates.json with jq instead of scraping critcmp's formatted text, which drops a ~1-minute `cargo install` from every run and gives the gate the exact nanosecond delta it needs. - benches/write_path.rs switches to iter_batched so the per-iteration 16-256 KiB payload clone is setup rather than measurement; it was charging allocator variance to the work under test. - compute_checksum grows a doc comment recording the attribution numbers, and a test pinning its output at every length and seed against the spec 4.6.1 reference definition, so the next person to try unrolling it has to stay byte-identical.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_0a77f808-f809-497d-b98b-be63a40d7f28) |
This was referenced Aug 30, 2026
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.
Summary
Two CI-gate-hygiene fixes: the coverage-smoke job now has a corpus to run against instead of skipping, and the Criterion job stops failing on runner noise. Task #94 and issue #17.
1. Coverage smoke test: a real corpus (task #94)
tests/fixtures/canonical/held no.dwgfile, so "Coverage smoke test (canonical corpus)" skipped with a warning on every run — a gate that could never fail.The corpus README said this was blocked on write-path Stages 2-5. It is not.
file_writer::assemble_dwg_byteslands a complete R2004-family byte buffer,handle_map::write_handle_mapemitsAcDb:Handles, and theElementEncoderimpls cover LINE / CIRCLE / ARC / POINT. Wiring those together with a common-entity-preamble writer — the exact inverse ofcommon_entity::read_common_entity_data— produces files this crate's reader decodes end-to-end.What the corpus contains
examples/build_fixtures.rs(new) emits four files, one per versionassemble_dwg_bytesaccepts, 1216 bytes each. Each carriesAcDb:Header(64-byte placeholder),AcDb:Handles, andAcDb:AcDbObjectswith five entities: a 2D LINE, a 3D LINE with non-default thickness and extrusion, a CIRCLE, an ARC, and a POINT.Measured —
cargo run --release --example coverage_report -- tests/fixtures/canonical:Generation is byte-deterministic; re-running the generator leaves
git statusclean.The floor
Measured 100.0 %, floor set to 95.0 % — the measured value minus one entity out of twenty. The margin is deliberately that small and the workflow says so:
decoded_ratiois a deterministic function of the committed bytes, not a timing measurement, so there is no CI noise to absorb. It exists only so a deliberately-unhandled fixture object (a DICTIONARY, to exercise theUnhandledpath) can be added later without editing the workflow in the same commit.CI changes
git diff --exit-codes it, so committed fixtures can never drift from the generator.tests/canonical_corpus.rs(new) is the tight companion gate undercargo test: it pins per-file entity counts and decoded field values, so a bit-alignment regression that still "decodes" into garbage coordinates fails there even when the ratio would stay at 100 %.Licence
Apache-2.0. No byte of any Autodesk-, ODA-, or third-party-produced DWG is redistributed — the files are generated by code in this repository. Provenance, command line, and base commit are recorded in
tests/fixtures/canonical/README.md, along with the honest-scope note that these prove our reader round-trips our writer and nothing about AutoCAD acceptance.2. Criterion noise floor (Refs #17)
The premise in #17 does not hold
#17 attributes the moved cell to "the longest-match path of the encoder — the most branch-predictor / alignment sensitive one".
lz77_encode::compressis literal-only. It emits one initial literal plus a terminator and performs no match search at all. The four bench cells are not a compressibility axis; they differ only in size.An attribution probe — replace both
compute_checksumcall sites inbuild_sectionwithblack_box(0u32), re-run the bench — shows where the time actually is:alt_1kuniform_16kmixed_64kmixed_256kSo the cell is
section_writer::compute_checksum—sum = rot1(sum) + b, a strict loop-carried dependency of two 1-cycle ops. 2 cycles/byte is the floor, and vectorisation is impossible (rot1is2x mod 2^32-1, the add is mod2^32; they do not distribute). Measured ~2.2 cycles/byte, already within ~11 % of that floor.The layout hypothesis, tested and rejected
Six measurements of
uniform_16kon an M2 Max, taking the minimum per-iteration time across criterion's 100 samples rather than the mean (the minimum is the sample closest to running uncontended):pub fnadded tobitwriter.rsmain)#[inline(never)]Everything lands in a 20.80–21.89 µs band with no consistent ordering by build. The same source measured twice moves 5.2 %. The perturbed builds came out faster in both rows. The unrolled +
#[inline(never)]variant was therefore dropped from this PR: it stabilises nothing and it is not faster.What was actually unstable: the estimator
On a loaded machine, criterion's mean reported 21.25 µs → 32.99 µs (+55 %) for a binary whose minimum-of-the-same-samples showed +4.9 %.
mixed_256kin that run: mean +63 %, minimum +1.5 %.A 21 µs benchmark on a shared GitHub vCPU cannot support a 20 %-ratio verdict on its own. That matches #13's run exactly:
uniform_16k"regressed" 24 % while three sibling cells improved 10-17 % — a whole-group swing in both directions is the signature of runner noise, not of a code change.The gate
Ratio threshold stays 1.20. A bench now fails only when all three hold:
ratio = pr_mean / main_mean >= 1.20delta = pr_mean - main_mean >= 5000 nsThe table prints on every run regardless of verdict. The re-run only executes on the failing path, so the happy path costs nothing.
Why 5 µs: the cells it exempts (
alt_1k~1.7 µs,uniform_16k~21 µs) exercise the sameWriterScaffold::build_sectionscode path asmixed_64k(~100 µs) andmixed_256k(~334 µs), which stay gated because 20 % of them is 20–67 µs. No code path loses coverage; what the floor removes is the class of failure whose only evidence is a few microseconds on the smallest cell.All of this reasoning, plus the
jqrecipe for extracting the minimum fromsample.json, is in the header comment of.github/workflows/perf.yml.Also in this half
.github/scripts/criterion-gate.shreads criterion's ownestimates.jsonwithjqinstead of scraping critcmp's formatted text. Dropscargo install critcmp(~1 min) from every run, removes a column-position parse that would silently mis-attribute if critcmp's layout changed, and gives the gate the exact nanosecond delta it needs. Exit 0 / 1 / 2 paths all exercised locally.benches/write_path.rsswitches toiter_batched, so the per-iteration 16–256 KiB payload clone is setup rather than measurement — it was charging allocator variance to the work under test.uniform_16kmeasures 19.85 µs after the change vs a 20.80–21.89 µs band before.compute_checksumgrows a doc comment recording the attribution numbers and the 2-cycles/byte floor, plus a test pinning its output at every length 0..300 × four seeds against the spec §4.6.1 reference definition — so the next person to try unrolling it has to stay byte-identical.Refs #17rather thanCloses: item (3) of the issue is fixed, item (1) is answered with measurements, and item (2) is answered in the negative — there is no layout effect left to pin once the estimator is corrected. Closing is the maintainer's call.Spec reference
cargo run --release --example coverage_report -- tests/fixtures/canonical.Test plan
cargo fmt --all -- --checkpassescargo clippy --all-targets --all-features -- -D warningspassescargo test --release --all-featurespasses (650 lib + 4 new canonical-corpus + all integration suites)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurespassescargo deny check allpasses (advisories ok, bans ok, licenses ok, sources ok)CARGO_TARGET_DIR=target-msrv cargo +1.85.0 test --no-run --all-featurespassestests/canonical_corpus.rs(4 tests) +checksum_matches_reference_definition_at_every_lengthcriterion-gate.shexercised locally on all three exit paths (clean, tripped, cold-baseline)Source-provenance declaration
Certified. No Autodesk DWG SDK source, no ODA Teigha / Drawings SDK source, and no GPL-licensed DWG implementation source (LibreDWG etc.) was consulted or imported. The write-path field orders used by
examples/build_fixtures.rswere derived from this repository's own reader (common_entity::read_common_entity_data,object::ObjectWalker::read_one_at_pos,entities::*::decode) plus the ODA public Open Design Specification for .dwg files v5.4.1. No third-party source was read for this change.Developer Certificate of Origin
Certified — DCO 1.1.
Note
Low Risk
Changes are mostly CI scripts, benchmarks, and test fixtures; production decode/write logic is documented and regression-tested rather than behaviorally altered.
Overview
Makes coverage-smoke a real gate and hardens perf CI against GitHub runner noise.
Coverage (task #94): Adds
examples/build_fixtures.rsand committed synthetic DWGs undertests/fixtures/canonical/. The job fails if the corpus is missing, diff-checks fixtures against the generator, and raises thecoverage_reportfloor from 20% → 95%.tests/canonical_corpus.rspins per-file counts, geometry, and section/handle readability so ratio-only checks cannot miss bit-alignment garbage.Perf (refs #17): Drops critcmp in favor of
criterion-gate.sh(estimates.json+jq) andrun-benches.sh. A regression requires ≥1.20× ratio, ≥5000 ns delta, and the same benchmark tripping on an immediate re-run.write_pathusesiter_batchedso payload clones are not timed;compute_checksumgets attribution docs and a byte-identical reference test..gitignoreadds/target-msrv/.Reviewed by Cursor Bugbot for commit 1413a31. Configure here.