-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib: allow CJS source map cache to be reclaimed #51711
Conversation
Review requested:
|
4d27198
to
af592c5
Compare
44c40aa
to
5baf322
Compare
@aduh95 @joyeecheung would you mind taking a look again? Thank you! |
run(); | ||
|
||
// Run until the source map is cleared by GC, or fail the test after determined iterations. | ||
common.gcUntil('SourceMap of deleted CJS module is cleared', () => { |
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.
I think this has the potential of flakes because the strategy used by common.gcUntil()
isn't very sound (i.e. sometimes gc()
is not aggressive enough to purge things). It would be safer to do it for a bunch more modules (say 30), and checks if any of them can be collected, which reduces the likelihood of the one single module that we are looking at just cannot be garbage collected in time because V8 just doesn't feel pressured enough to do that.
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.
Thanks for the suggestion, updated the test with more GC pressure to reduce the chance of flaky.
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.
Maybe we should launch a stress-test CI to make sure we're not introducing any flakiness
9482198
to
611d7db
Compare
@joyeecheung would you mind taking another look at this? Thank you! |
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 but this needs a rebase
Unifies the CJS and ESM source map cache map with SourceMapCacheMap and allows the CJS cache entries to be queried more efficiently with a source url without iteration on an IterableWeakMap. Add a test to verify that the CJS source map cache entry can be reclaimed.
611d7db
to
ed1a8c7
Compare
CI is green. @joyeecheung @aduh95 would be great to have another review, thanks! |
run(); | ||
|
||
// Run until the source map is cleared by GC, or fail the test after determined iterations. | ||
common.gcUntil('SourceMap of deleted CJS module is cleared', () => { |
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.
Maybe we should launch a stress-test CI to make sure we're not introducing any flakiness
Stress test: https://ci.nodejs.org/job/node-stress-single-test/508 (passed) |
Landed in c0c598d |
Unifies the CJS and ESM source map cache map with SourceMapCacheMap and allows the CJS cache entries to be queried more efficiently with a source url without iteration on an IterableWeakMap. Add a test to verify that the CJS source map cache entry can be reclaimed. PR-URL: #51711 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Unifies the CJS and ESM source map cache map with SourceMapCacheMap and allows the CJS cache entries to be queried more efficiently with a source url without iteration on an IterableWeakMap. Add a test to verify that the CJS source map cache entry can be reclaimed. PR-URL: nodejs#51711 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Unifies the CJS and ESM source map cache map with SourceMapCacheMap and allows the CJS cache entries to be queried more efficiently with a source url without iteration on an IterableWeakMap. Add a test to verify that the CJS source map cache entry can be reclaimed. PR-URL: nodejs#51711 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Unifies the CJS and ESM source map cache map and allows the CJS cache
entries to be queried more efficiently with a source url without
iteration on an IterableWeakMap. Reclaims the CJS cache entry with
a FinalizationRegistry instead.
Add a regression test to verify that the CJS source map cache entry can be
reclaimed.