Tracking issue: compile cache
Open
Nobody has claimed this yet.
esm
module
never-stale
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Follow up to https://github.com/nodejs/node/issues/47472 . Some items that can be investigated:
- Initial implementation, enabled via
NODE_COMPILE_CACHEenvironment variable: https://github.com/nodejs/node/pull/52535 - Exposing an API for user code to control the caching https://github.com/nodejs/node/pull/54501
- An API for flushing the cache: https://github.com/nodejs/node/pull/54971
- Support relative/portable cache: https://github.com/nodejs/node/pull/58797
- Embedder API for configuring the storage
- Support reading a list of files to generate cache ahead of time: https://github.com/nodejs/node/issues/58482
- 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?)
- Inode caching like https://github.com/ccache/ccache/pull/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 (this likely tanks the performance for simpler use cases)
- Implement TS -> JS caching https://github.com/nodejs/node/issues/54741
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked follow-up issue 47472 and the unchecked compile-cache items in this tracking issue. Choose one specific investigation, such as the embedder API or ahead-of-time cache generation, then identify the relevant Node.js entry points and tests before defining completion for that item. The issue currently provides no file or test path, so scope must be established first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- performance, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100