Consolidate bundled-data loading behind compression helpers#693
Merged
Conversation
All compressed blobs were loaded with ad-hoc `OnceLock` + inline `postcard::from_bytes(&decompress_deflate(include_bytes!(...)))` boilerplate, repeated (and slightly varied) across ~10 sites plus the generated loaders. Introduce three small helpers in `compression.rs` and route every site through them: - `LazyData<T>`: a blob decompressed + postcard-deserialized into `T` on first use and cached. Used where the value is consumed as-is (version tables, per-browser version order, generated key tables). - `LazyBlob`: a blob decompressed to raw bytes and cached, for data decoded by hand at the use site (the byte-plane and run-length blobs). - `load<T>`: one-shot decompress + deserialize, shared by `LazyData` and by the few sites that transform the decoded value further (node versions, the browser map, the region pair table). This removes the per-site accessor functions and unifies the idiom; the remaining `OnceLock`s cache only derived/transformed values. No data or behavior change (blobs are byte-identical); musl `inspect` example 764,160 -> 761,920 B as the shared helpers de-duplicate the per-site loaders.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #693 +/- ##
==========================================
- Coverage 99.06% 98.81% -0.26%
==========================================
Files 47 47
Lines 2456 2443 -13
==========================================
- Hits 2433 2414 -19
- Misses 23 29 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Every compressed blob was loaded with ad-hoc
OnceLock+ inlinepostcard::from_bytes(&decompress_deflate(include_bytes!(…)))boilerplate — repeated and slightly varied across ~10 call sites plus the two generated loaders. This consolidates them behind three small helpers incompression.rs:LazyData<T>— a blob decompressed + postcard-deserialized intoTon first use and cached. For values consumed as-is: the feature/region version tables, the per-browser version order, and the generated key tables.LazyBlob— a blob decompressed to raw bytes and cached, for data decoded by hand at the use site (the byte-plane and run-length blobs, where a generic deserializer would bloat the binary).load<T>— one-shot decompress + deserialize, shared byLazyDataand by the few sites that transform the decoded value further (node versions, the browser map, the region pair table).Call sites lose their hand-written accessor functions and become uniform
static X: LazyData<…> = LazyData::new(include_bytes!(…))/X.get(). The remainingOnceLocks now cache only derived/transformed values (e.g. the browserFxHashMap, version aliases), and their blob loads route throughload().No data/behavior change, small size win
Blobs are byte-identical (regenerated). Sharing the loaders de-duplicates the per-site monomorphized closures, so the musl
inspectexample drops 764,160 → 761,920 B (−2,240). All tests and the JS-equivalence proptests pass.🤖 Generated with Claude Code