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
-
Feature Name: Design the
Snapshot
module at persistent cacheStart Date: 2024/11/18
Summary
Design the
Snapshot
module at persistent cacheContext
There is a big difference in functionality between rspack
Snapshot
and webpackSnapshot
.For webpack
Snapshot
, it is mainly used to check whether the cache is available when accessing.For rspack
Snapshot
is 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_paths
andmanaged_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
,PackageVersion
will be used for verification.CompileTime
: Verify the last compile time and file modification time, default strategy.API
The
Snapshot
module supportsadding
/removing
files and folders to the listening list. Throughcalc_changed_files
, we can calculate which files have been modified and deleted.Detailed design
Option
SnapshotOption
providesis_immutable_path
andis_managed_path
to quick validation.Strategy
StrategyHelper
encapsulatesStrategy
related operations, providingcompile_time
,package_version
generation functions, and also supports validate them.API
The implementation of
Snapshot
is relatively simple. It requires associating theOption
andStrategy
to achieve the following methods:add
: Need to generate the corresponding verification strategy for the file and save them toStorage
.remove
: Delete file strategy directly fromStorage
calc_changed_files
: Get all files inStorage
, verify these files according to their verification strategy, and collect a list of changed and deleted files.CacheTrait
Snapshot
needs to support incremental save(only save the newly added and delete dependent files when HMR finish), specifically, we need to call theadd
&remove
method according to this incremental information when callafter_compile
.Beta Was this translation helpful? Give feedback.
All reactions