Skip to content

perf(core): unzip decks with native decompression - #151

Merged
sadmann7 merged 4 commits into
mainfrom
sadman/perf-core-native-unzip
Nov 30, 2026
Merged

sadmann7 merged 4 commits into
mainfrom
sadman/perf-core-native-unzip

Conversation

@sadmann7

Copy link
Copy Markdown
Owner

Unzipping was most of the time to the first slide: JSZip inflates and decodes every part in JavaScript, which took 273 ms of the 318 ms it took to show the first slide of the 300-slide bench deck.

  • ooxml/unzip.ts reads the zip's central directory and inflates entries with the platform's DecompressionStream("deflate-raw"), decoding text with TextDecoder. readPptx uses it whenever the runtime supports deflate-raw.
  • It matches JSZip's output: the same entry names (JSZip's path resolution, its directory test, duplicate names), a kept leading BOM, empty entries, stored and deflated entries, and a check that each entry inflates to exactly its declared size.
  • The size check stops inflating as soon as an entry passes its declared size. Input goes in 16 KB slices with backpressure, so a header that understates its size can't get past maxTotalUncompressedBytes or maxMediaBytes, or inflate far past them first. JSZip only checked once it had inflated the whole entry.
  • Archives it doesn't cover (zip64, encryption, split archives, other compression methods, unicode-path extra fields), runtimes without deflate-raw, and non-zip input all go through JSZip as before. The editable source package (keepSourcePackage) still loads with JSZip, which only reads the directory up front.
  • Size limits skip re-encoding decoded text just to count its bytes, which JSZip's path did for every part.
  • Core only. Nothing diceui syncs is touched.

pnpm bench --runs 9 --against <main build>: the two builds alternate run by run, median of 9, Chromium headless shell 156 on Linux. Times in milliseconds:

deck slides unzip open → first slide open → all slides
small 8 36 → 7 (5.4×) 66 → 37 (1.8×) 204 → 180 (1.1×)
text-heavy 60 48 → 19 (2.5×) 82 → 55 (1.5×) 611 → 609
image-heavy 40 40 → 8 (5.3×) 141 → 91 (1.6×) 432 → 318 (1.4×)
many-slides 300 273 → 95 (2.9×) 318 → 138 (2.3×) 3454 → 3305
shapes-charts 40 60 → 25 (2.4×) 221 → 192 (1.2×) 1047 → 1019

An A/A run moves these by up to ±10%. pnpm bench --shots before and after, compared with pnpm bench:diff: 448 of 448 slides identical pixel for pixel.

Not shown:

  • Firefox and Safari not run. Both ship deflate-raw (Firefox 113, Safari 16.4), and older versions use JSZip. The Chromium e2e project passes (72 passed).
  • A 1 GB zip bomb declaring 1 KB stops after one 64 KB output chunk in Chromium; that was checked by script, not in the test suite, because Node inflates lazily.

@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pptx Ready Ready Preview Nov 30, 2026 2:43pm UTC

Request Review

@sadmann7
sadmann7 merged commit 3bb2bd2 into main Nov 30, 2026
7 checks passed
@sadmann7
sadmann7 deleted the sadman/perf-core-native-unzip branch November 30, 2026 14:55

This branch was successfully deployed

1 active deployment
Preview — 591a2bde Deployed Nov 30, 2026 by vercel[bot]
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