RFC: Persistent Cache Architecture #8458
                  
                    
                      jerrykingxyz
                    
                  
                
                  started this conversation in
                RFC
              
            Replies: 1 comment 2 replies
-
| 
         This is great that we have an RFC. May I ask you to provide more specific information regarding the persistent cache - the lifecycle, where it is stored (particular paths on the file system), and how to invalidate the whole cache? Also, it would be interesting to see the ratio is cache hits - let's say if we switch branches.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    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.
Uh oh!
There was an error while loading. Please reload this page.
-
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.MakeArtfactis the onlyArtifactat 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 ownOccasionimplementation, responsible for storing and transforming specificArtifactand hot-start restoration. RFC: Persistent Cache MakeOccasion #8636Storage: Underlying persistent storage module, providing KV storage functions. RFC: Persistent Cache Storage #8646The coupling between the persistent cache and the entire build process is low, with only the following call locations:
Snapshotwill be set.Artifactis empty, the correspondingOccasionwill be used to restore theArtifactfor filling.ArtifacttoOccasionfor saving.Snapshot, and theStorageis 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 removesArtifactin compilation when before_<step_name>, and does nothing at other call locations.MemoryCache: Memory cache(Default), since rspack will reuse theArtifactat previous compilation , no processing is required.PersistentCache: Persistent cache, it will generatesArtifactto 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.tsisThe configuration of Js side exposed to the outside is
Beta Was this translation helpful? Give feedback.
All reactions