Repository navigation
perf(streaming): flatten §5.10.1's copy table at compile time (#205) - #365
Merged
Merged
Conversation
A literal run of the R2007 LZ dialect is copied out of order in blocks of up to 32 bytes whose bytes follow §5.10.1's copy table. The decoder walked the table recursively for every block, one byte per leaf. In the Time Profiler profile of the streaming R2007 walk of sample_AC1021, that recursion (r2007_lz::emit) was about 27% of the walk's samples. The table is now flattened once at compile time into a permutation per block size, so a block is one gather. A scratch check against the recursive version (not committed) compared all 32 sizes on 64,000 random blocks and that each table is a permutation of 0..n; the decoder's state and checkpoints are unchanged. R2007 streaming walk, best of 15 in memory (examples/stream_r2007_timing), against origin/main, Apple M2 Max under load: sample_AC1021 20.63 ms -> 15.88 ms (x1.30; 51.5 -> 66.9 MB/s of the file)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
5 tasks done
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
A literal run of the R2007 LZ dialect (§5.10) is copied out of order in blocks of up to 32 bytes whose bytes follow §5.10.1's copy table. The streaming decoder walked that table recursively for every block, one byte per leaf. The table is now flattened once at compile time into a permutation per block size, so a block is one gather. The decoder's state and checkpoints are unchanged.
Profile (Time Profiler, the streaming R2007 walk of
sample_AC1021.dwgalone): the recursion (r2007_lz::emit) was 25.8% of the walk's samples.A scratch check against the recursive version (not committed) compared all 32 block sizes on 64,000 random blocks and that each table is a permutation of 0..n.
R2007 streaming walk, best of 15 in memory (
examples/stream_r2007_timing, Apple M2 Max under load), againstorigin/mainata315f04:sample_AC1021(1.06 MB)Spec reference
§5.10 and §5.10.1 (the R2007 LZ dialect and its copy table), unchanged in meaning. Performance only: part of #205. No format finding, no coverage-state change.
Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo +1.85 check --all-features(MSRV)cargo test --release --all-features(existing suites only; no test added; built without LTO to fit the machine's CPU budget, perf(streaming): fold eight bytes per step in the DWG CRC-8 (#205) #360 ran the full LTO profile)python3 tools/streaming/check_invariants.py;tools/streaming/no_std.rscompiled natively and forwasm32-unknown-unknown, state bounds holdverify_r2007.py(the 8 pinned drawings and the files it builds: every output line and every assembled section byte equal to the independent Python reader and the legacy reader, fixed and proptest schedules, fresh-process resumes, forged checkpoints, corruptions) andverify_wasm_r2007.py(native and wasm32 checkpoints byte-identical). Both passed; each writes its binary SHA to its evidence JSON.emit(all 32 sizes, 64,000 random blocks; each table a permutation of 0..n). Not committed (no unit tests): every literal run of the verifiers above goes through it.cargo build --release --example stream_r2007_timing, thentarget/release/examples/stream_r2007_timing <corpus>/acadsharp/sample_AC1021.dwg 15, build oforigin/mainagainst build of this branch, alternated.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. Specifically:
CLEANROOM.md).dwg-rsis Apache-2.0 and must remain compatible.My contribution is based on:
CLEANROOM.md.See
CLEANROOM.mdfor the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.Developer Certificate of Origin
By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.
I will sign off commits with
git commit -swhen asked, which adds aSigned-off-bytrailer to the commit message asserting the DCO.