Repository navigation
perf(@angular/build): selectively compress large entries in SQLite cache store - #34021
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces payload compression (using DEFLATE) for the SQLite cache store for entries exceeding 32 KB, which helps reduce disk usage and SQLite overflow pages. It also adds comprehensive unit tests to verify compression, decompression, legacy support, and error handling. The feedback suggests replacing Buffer.allocUnsafe with new Uint8Array to avoid triggering security scanner false positives and to allow removing the unused Buffer import.
c9efb9b to
775112a
Compare
55cc123 to
0eebe6c
Compare
…che store Transformed JavaScript files from node_modules and other cached assets stored in the persistent SQLite cache store can range from tens to hundreds of kilobytes. Because SQLite rows exceeding the page size spill into overflow b-tree pages, storing large uncompressed entries increases disk I/O and cache file bloat. Serialized entries and binary payloads of 32 KB or greater are now selectively compressed asynchronously using raw DEFLATE at level 1. Performing compression asynchronously offloads CPU-intensive compression work to worker threads, preventing blocking of the main JavaScript event loop during builds. Smaller payloads and incompressible entries remain uncompressed. A dedicated `format` column stores the encoding format (`CacheFormat`), distinguishing between V8 serialized and raw binary (`Uint8Array`) data in both uncompressed and compressed states. This allows raw binary payloads (such as transformed JavaScript files) to be stored and retrieved with zero serialization overhead and zero memory copies. For backward compatibility with existing databases on disk, the database schema migration adds the `format` column with a default value of 0 (`V8`), ensuring pre-existing cache entries continue to deserialize seamlessly.
0eebe6c to
6bca7f7
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Transformed JavaScript files from node_modules and other cached assets stored in the persistent SQLite cache store can range from tens to hundreds of kilobytes. Because SQLite rows exceeding the page size spill into overflow b-tree pages, storing large uncompressed entries increases disk I/O and cache file bloat.
Serialized entries and binary payloads of 32 KB or greater are now selectively compressed asynchronously using raw DEFLATE at level 1. Performing compression asynchronously offloads CPU-intensive compression work to worker threads, preventing blocking of the main JavaScript event loop during builds. Smaller payloads and incompressible entries remain uncompressed.
A dedicated
formatcolumn stores the encoding format (CacheFormat), distinguishing between V8 serialized and raw binary (Uint8Array) data in both uncompressed and compressed states. This allows raw binary payloads (such as transformed JavaScript files) to be stored and retrieved with zero serialization overhead and zero memory copies.