Skip to content

feat: persistent cache snapshot save file hash by default#10050

Merged
jerrykingxyz merged 1 commit intomainfrom
jerry/hash
Apr 17, 2025
Merged

feat: persistent cache snapshot save file hash by default#10050
jerrykingxyz merged 1 commit intomainfrom
jerry/hash

Conversation

@jerrykingxyz
Copy link
Copy Markdown
Contributor

@jerrykingxyz jerrykingxyz commented Apr 16, 2025

Summary

The persistent cache snapshot will store the compile times and use them to calculate which files were modified when hot start. However, this strategy is invalid in scenarios such as CI because the update time of all files will be refreshed.

This PR will make snapshot store both compile time and file hash, and when calculate modified files the file hash will be compared when the file modification time has been updated.

This PR will introduce some performance regression due to the addition of hash calculations, and I manually benchmarked the performance of snapshot generation in cold start.

Name File Count Hash Count Before After
Docusaurus 4059 2143 22.32ms 73.274ms
Large real project 44905 8891 106.189ms 365.41ms

As can be seen from the table above, this takes three times longer than before, and the main time consumption occurs in file IO. This is currently acceptable in large real projects.

PS. For hot start, it will take 3 times longer if you update a lot of files like in CI, otherwise it will be the same as before. HMR will create snapshots incrementally so the performance impact is smaller.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: feature release: feature related release(mr only) labels Apr 16, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 16, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 551ce57
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67ff7993a44ea100081cf048

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2025

CodSpeed Performance Report

Merging #10050 will not alter performance

Comparing jerry/hash (551ce57) with main (bc56391)

🎉 Hooray! codspeed-node just leveled up to 4.0.1!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 11 untouched benchmarks

@jerrykingxyz jerrykingxyz merged commit 5a49a01 into main Apr 17, 2025
29 checks passed
@jerrykingxyz jerrykingxyz deleted the jerry/hash branch April 17, 2025 03:41
@LingyuCoder
Copy link
Copy Markdown
Contributor

can this issue #9064 be closed?

@jerrykingxyz
Copy link
Copy Markdown
Contributor Author

can this issue #9064 be closed?

No, this is another bug caused by storage invalidation, not snapshot invalidation. I will fix it in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Rspack persistent cache doesn't work for code-generated files

2 participants