RFC: Persistent Cache Snapshot #8463
jerrykingxyz
started this conversation in
RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Name: Design the
Snapshotmodule at persistent cacheStart Date: 2024/11/18
Summary
Design the
Snapshotmodule at persistent cacheContext
There is a big difference in functionality between rspack
Snapshotand webpackSnapshot.For webpack
Snapshot, it is mainly used to check whether the cache is available when accessing.For rspack
Snapshotis responsible for calculating the files updated or deleted during downtime. (PS. rspack cache availability check is implemented by incremental rebuild in the corresponding step)User Guide
Option
Snaphot configuration items support
immutable_paths,unmanaged_pathsandmanaged_paths.Verification Strategy
Snapshot needs to support two types of file validation
PackageVersion: Verify with the version field in package.json. When the file path is inmanaged_paths,PackageVersionwill be used for verification.CompileTime: Verify the last compile time and file modification time, default strategy.API
The
Snapshotmodule supportsadding/removingfiles and folders to the listening list. Throughcalc_changed_files, we can calculate which files have been modified and deleted.Detailed design
Option
SnapshotOptionprovidesis_immutable_pathandis_managed_pathto quick validation.Strategy
StrategyHelperencapsulatesStrategyrelated operations, providingcompile_time,package_versiongeneration functions, and also supports validate them.API
The implementation of
Snapshotis relatively simple. It requires associating theOptionandStrategyto achieve the following methods:add: Need to generate the corresponding verification strategy for the file and save them toStorage.remove: Delete file strategy directly fromStoragecalc_changed_files: Get all files inStorage, verify these files according to their verification strategy, and collect a list of changed and deleted files.CacheTrait
Snapshotneeds to support incremental save(only save the newly added and delete dependent files when HMR finish), specifically, we need to call theadd&removemethod according to this incremental information when callafter_compile.Beta Was this translation helpful? Give feedback.
All reactions