Open
Description
Follow up to #47472 . Some items that can be investigated:
- Initial implementation, enabled via
NODE_COMPILE_CACHE
environment variable: module: implement NODE_COMPILE_CACHE for automatic on-disk code caching #52535 - Exposing an API for user code to control the caching module: implement NODE_COMPILE_CACHE for automatic on-disk code caching #52535 (comment)
- An API for flushing the cache: module: implement flushCompileCache() #54971
- Idle-time cache serialization like what Blink does, to avoid penalizing the first load
- Other hashing algorithm (CRC32 may be good enough for our use case. In the initial implementation, it was chosen because it can be used on no-crypto builds and fast enough. For reference, ccache has used md4 and later BLAKE2b -> BLAKE3)
- Other directory layout (splitting the cache for each file and read on the fly seems to be fast enough and I don't really see I/O showing up in the profile anyway) or using a db (if/when we implement Web Storage?)
- Embedder API for configuring the storage
- Inode caching like Inode cache for file hashes ccache/ccache#577 (note that CRC32 also barely shows up in the profile, it may not worth the complexity).
- Avoid UTF8 transcoding by directly reading the source code as buffer from disk (this needs to dance with CJS loader monkey patching)
- Move the flushing operations off-thread so that they can be done as soon as the code cache is ready and can be done concurrently https://github.com/joyeecheung/node/tree/parallel-compile-cache
- Implement TS -> JS caching Use the compilation cache when running typescript files through
--experimental-transform-types
#54741