Reduce binary size of bundled caniuse/electron data#688
Merged
Conversation
Re-represent the embedded data tables so the existing deflate compresses them better and the generated rodata carries no string relocations. All changes are lossless: query results are byte-identical to before (verified across every region/feature/electron/cover query), tests and proptests pass. - Delta-encode region usage percentages (non-increasing per region, so the deltas are small with long zero runs) - Intern region (browser, version) pairs into one popularity-ordered table and store a u16 pair-index per datum, dropping the redundant per-region browser-id array (only ~557 unique pairs were stored ~47k times) - Intern feature-support version strings via a sorted table + u16 indices - Move region/feature lookup keys out of inline &[&str] into deflate blobs decoded once (no fat pointers / relocations) - String-pack the global-usage and electron tables: a concatenated &str pool referenced by a u32 bitpacking offset<<8|len, eliminating the per-entry &str relocations Linux (x86_64-unknown-linux-musl): 861,760 -> 784,128 bytes (-9.0%).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #688 +/- ##
==========================================
+ Coverage 99.03% 99.04% +0.01%
==========================================
Files 47 47
Lines 2374 2411 +37
==========================================
+ Hits 2351 2388 +37
Misses 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Decode each string lookup table (the region and feature version tables and the generated region/feature key tables) into a single OnceLock<Vec<String>> instead of the previous two-OnceLock "decompressed bytes + borrowing Vec<&str>" pair; .as_str() still hands the call sites the &'static str they need. Inline include_bytes! so each compressed blob needs only one static. Plain std::sync::OnceLock throughout, no helper types. No behavior change (query results stay byte-identical; verified across the full region/feature/ electron/cover query space).
fb0e9cc to
b394b04
Compare
Merged
Boshen
pushed a commit
that referenced
this pull request
May 29, 2026
## 🤖 New release * `oxc-browserslist`: 3.0.3 -> 3.0.4 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [3.0.4](oxc-browserslist-v3.0.3...oxc-browserslist-v3.0.4) - 2026-05-29 ### Other - DRY up feature/region codegen with shared table + lookup helpers ([#694](#694)) - Consolidate bundled-data loading behind compression helpers ([#693](#693)) - Reduce binary size: run-length encode feature support versions ([#692](#692)) - Reduce binary size: Zopfli codegen compression + percentage byte-plane ([#691](#691)) - Reduce binary size: byte-plane (stream-split) compression for region pair indices ([#690](#690)) - Update README binary size to 621K ([#689](#689)) - Reduce binary size of bundled caniuse/electron data ([#688](#688)) - Switch codegen data source from caniuse-db to caniuse-lite ([#687](#687)) - Update browserslist ([#685](#685)) - Update rust crates ([#682](#682)) - Update browserslist ([#679](#679)) - Update browserslist ([#678](#678)) - Update browserslist ([#677](#677)) - Update browserslist ([#673](#673)) - Update browserslist ([#671](#671)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
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.
Reduces the footprint that this crate's bundled Can I Use / Electron / Node data adds to a binary, by re-representing the embedded tables so the existing deflate compresses them better and the generated
rodatacarries no string relocations. No new dependencies, no profile changes, and no loss of precision — query results are byte-identical to before (verified across the full region / feature / electron / cover query space, plus the existing test suite and JS-reference proptests).Size
Measured with the
inspectexample:x86_64-unknown-linux-muslaarch64-apple-darwin)The Linux figure is the more representative one: on ELF every
&strin a static table costs a 24-byte.rela.dynrelocation on top of its 16-byte fat pointer, so removing those (see the last two techniques) pays off most there.Techniques
All are lossless and operate on the generated data representation (
xtaskcodegen) together with the matching runtime decoders:prev − curryields small deltas with long runs of zeros that deflate packs tightly.u16pair-index per entry instead of a browser byte and a version index — dropping the redundant per-region browser array.y/asupport lists referenced the same version strings over and over; they're nowu16indices into a sorted version table.&[&str](a 16-byte fat pointer plus a relocation per entry); they're now deflate blobs decoded once.&stris replaced by au32that bitpacksoffset << 8 | leninto a single concatenated string pool, eliminating the per-entry&strrelocations with no decode code.Decoding stays plain
std::sync::OnceLock, with no helper types.🤖 Generated with Claude Code