New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use the process cache to reduce the memory for asar file #36600
Conversation
The change makes sense to me. Is there any chance you could add a test? Maybe by comparing the value of |
@zcbenz could you also take a look? |
Nice catch! |
Right, I mean adding a test to |
Haven't looked into it but are we sure that |
I refer to #29292 , and my conclusion is that Archive and GetOrCreateAsarArchive are thread-safe |
I will learn and try to add a test to the electron, but what about the data that determines a failed test? 1kb or 1mb? It is not easy to confirm the criteria for determining test failure. It is also difficult to confirm the time when the memory reclamation is completed when the worker exits |
Hmm, I'm not sure how this can be reproduced consistently. Maybe you would need to experiment with the values a bit? If it's hard to consistently reproduce, I guess it's okay to land this without a test too. |
electron/shell/common/asar/asar_util.cc Lines 62 to 63 in 6a798b1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
I have automatically backported this PR to "21-x-y", please check out #36663 |
I have automatically backported this PR to "22-x-y", please check out #36664 |
I have automatically backported this PR to "23-x-y", please check out #36665 |
…on#36600) * fix: use the process cache to reduce the memory for asar file * Update shell/common/api/electron_api_asar.cc Co-authored-by: webster.xu <webster.xu@ringcentral.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Description of Change
The memory leaks at /lib/asar/fs-wrapper.ts, const cachedArchives = new Map<string, NodeJS.AsarArchive>() Whenever a new worker is created, it will have an instance of this map. The contents of this map will not be cleaned up immediately.
And there is a process-level cache at /shell/common/asar/asar_util.cc, static base::NoDestructor s_archive_map
In summary, I decide to use this process-level cache to save the asar cache instead of creating a new one for each worker
Resolves #36597
Checklist
npm test
passesRelease Notes
Notes: use the process cache to reduce the memory for asar file