RFC: Persistent Cache Architecture #8458
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 Persistent Cache Architecture
Start Date: 2024/11/18
Summary
Design persistent cache architecture.
Context
The ColdStart needs to build all the memory data, the build speed is slow.
The HMR can use the memory data that has been built to accelerate the build, so the speed is fast.
The HotStart that enables persistent cache will restore the memory data as much as possible in the starting phase, so that the start speed is infinitely close to HMR.
Glossary
Artifact
: The output of each compile step in rspack. It can be a data structure or multiple data structures. eg.MakeArtfact
is the onlyArtifact
at Make step.Detailed design
Architecture
The persistent cache consists of three modules:
Snapshot
: Responsible for calculating the files updated or deleted during downtime. RFC: Persistent Cache Snapshot #8463Occasion
: Each build step includes its ownOccasion
implementation, responsible for storing and transforming specificArtifact
and hot-start restoration.Storage
: Underlying persistent storage module, providing KV storage functions.The coupling between the persistent cache and the entire build process is low, with only the following call locations:
Snapshot
will be set.Artifact
is empty, the correspondingOccasion
will be used to restore theArtifact
for filling.Artifact
toOccasion
for saving.Snapshot
, and theStorage
is notified to be idle.Cache implementation
The rspack cache maintains a one-to-one relationship with the compiler, and there are the following cache types:
DisableCache
: Disable cache, which removesArtifact
in compilation when before_<step_name>, and does nothing at other call locations.MemoryCache
: Memory cache(Default), since rspack will reuse theArtifact
at previous compilation , no processing is required.PersistentCache
: Persistent cache, it will generatesArtifact
to memory when current compilation withoutArtifact
.Cache configuration
The configuration on the Rust side is relatively simple, just need to gather the configurations of various caches.
The cache configuration on the Napi side is to convert the above configuration into JS style.
The configuration at
binding.d.ts
isThe configuration of Js side exposed to the outside is
Beta Was this translation helpful? Give feedback.
All reactions