Skip to content

Release 3.2.0: issue #5 performance work - #6

Merged
WilliamSmithEdward merged 2 commits into
mainfrom
perf-3.2.0
Aug 2, 2026
Merged

Release 3.2.0: issue #5 performance work#6
WilliamSmithEdward merged 2 commits into
mainfrom
perf-3.2.0

Conversation

@WilliamSmithEdward

Copy link
Copy Markdown
Owner

Implements both halves of issue #5, byte-exactness preserved throughout.

  • decompress: slice copies for non-overlapping tokens, literal-run batching, hoisted copy-token masks. Measured 12.4 -> 21.8 MB/s (1.76x) on the 31 live-fixture streams; oracle-equivalence tests against the original per-byte decoder including identical error messages on malformed input. New max_bytes chunk-aligned prefix parameter.
  • lazy module source: parse_vba_project decompresses one chunk per module (header included; single-chunk modules stay fully eager) and defers the rest to first VBAModule.source access. module_names() on the large fixture: 1.47 ms -> 0.79 ms. Saving an unrelated edit no longer decompresses untouched modules.

Verification: 390 tests + pyright strict + ruff clean; 25-case save matrix byte-identical against a v3.1.0 worktree baseline; live Excel gate green.

Closes #5.

Decompression dominated project opening (88-96% per the issue's
profile). Two changes, both output-preserving:

decompress now produces output with slice operations wherever the spec
allows: non-overlapping copy tokens (offset >= length) move as one
slice, runs of literal tokens within a flag byte extend once, and the
copy-token masks recompute only when the chunk-local output size
crosses a power of two instead of once per token. Overlapping copies
keep the spec's byte-at-a-time semantics, which are load-bearing
there. Measured 12.4 -> 21.8 MB/s over the 31 module and dir streams
in the live fixtures. A new oracle test suite pins the optimized
decoder against the original per-byte implementation: live-fixture
streams, synthetic round trips (overlap-heavy included), and byte-equal
error messages and offsets on malformed input. A new max_bytes
parameter returns a chunk-aligned prefix; chunk locality (enforced by
this decoder) makes the prefix byte-identical to the same range of a
full decompression.

parse_vba_project now decompresses only the first chunk of each module
stream. That prefix carries the Attribute header, and for single-chunk
modules it already is the complete source, which stays eager at zero
extra cost. Multi-chunk modules defer the remaining chunks to the
first VBAModule.source access via a stored loader; stream lookup and
MODULEOFFSET bounds checks remain eager, and a header that runs to the
chunk boundary falls back to eager full decompression rather than risk
a truncated attribute_header. VBAModule becomes a regular class with
an unchanged constructor signature plus a source_loaded property;
dataclass field equality and repr are gone (equality is identity).
Opening the large-module fixture for module_names() drops 1.47 ms ->
0.79 ms, and saving an unrelated edit no longer decompresses untouched
modules (tested).

Verified byte-identical end to end: the 25-case save matrix across all
live fixtures hashes identically against a v3.1.0 worktree baseline,
and the live Excel gate passes.
@WilliamSmithEdward
WilliamSmithEdward merged commit 0fbcd18 into main Aug 2, 2026
8 checks passed
@WilliamSmithEdward
WilliamSmithEdward deleted the perf-3.2.0 branch August 2, 2026 06:01
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.

perf: 1.75x byte-identical decompress, and lazy module source loading (measured)

1 participant