-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
module: implement flushCompileCache() #54971
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54971 +/- ##
==========================================
+ Coverage 88.06% 88.27% +0.21%
==========================================
Files 652 652
Lines 183545 183610 +65
Branches 35866 35848 -18
==========================================
+ Hits 161639 162082 +443
+ Misses 15150 14802 -348
+ Partials 6756 6726 -30
|
This works better in terms of avoiding race conditions.
This implements an API for users to intentionally flush the accumulated compile cache instead of waiting until process shutdown. It may be useful for application that loads dependencies first and then either reload itself in other instances, or spawning other instances that load an overlapping set of its dependencies - in this case its useful to flush the cache early instead of waiting until the shutdown of itself. Currently flushing is triggered by either process shutdown or user requests. In the future we should simply start the writes right after module loading on a separate thread, and this method only blocks until all the pending writes (if any) on the other thread are finished. In that case, the off-thread writes should finish long before any attempt of flushing is made so the method would then only incur a negligible overhead from thread synchronization.
f54cb3b
to
b141f8c
Compare
Updated to remove the |
@anonrig @nodejs/loaders @nodejs/cpp-reviewers can I get some reviews please? |
module: write compile cache to temporary file and then rename it
This works better in terms of avoiding race conditions.
Drive-by: throw instead of abort when module.enableCompileCache()
gets passed a non-string argument.
module: implement flushCompileCache()
This implements an API for users to intentionally flush the
accumulated compile cache instead of waiting until process
shutdown. It may be useful for application that loads dependencies
first and then either reload itself in other instances, or spawning
other instances that load an overlapping set of its dependencies -
in this case its useful to flush the cache early instead of waiting
until the shutdown of itself.
Currently flushing is triggered by either process
shutdown or user requests. In the future we should simply start the
writes right after module loading on a separate thread, and this method
only blocks until all the pending writes (if any) on the other thread
are finished. In that case, the off-thread writes should finish long
before any attempt of flushing is made so the method would then only
incur a negligible overhead from thread synchronization.
Fixes: #54770
Fixes: #54465