| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway.
This patch changes the NativeModuleLoader to always try to find code cache for native modules when it compiles them, and always produce and store the code cache after compilation. The cache map is protected by a mutex and can be accessed by different threads - including the worker threads and the main thread. Hence any thread can reuse the code cache if the native module has already been compiled by another thread - in particular the cache of the bootstrappers and per_context.js will always be hit when a new thread is spun. This results in a ~6% startup overhead in the worst case (when only the main thread is launched without requiring any additional native module - it now needs to do the extra work of finding and storing caches), which balances out the recent improvements by moving the compilation to C++, but it also leads to a ~60% improvement in the best case (when a worker thread is spun and requires a lot of native modules thus hitting the cache compiled by the main thread).
|
@joyeecheung build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/1890/pipeline |
Sorry, something went wrong.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/19408/ |
Sorry, something went wrong.
|
@addaleax Thanks for the review, updated. Also updated the emplace() calls since gcc 4.9.4 needs the pointers to be moved before the call, and updated the test to pass the --worker test suit since compileWithCache is no longer guaranteed to be empty when a worker thread is spun (that's the whole point of this patch :p) PTAL. Also cc @nodejs/process @nodejs/build-files CI: https://ci.nodejs.org/job/node-test-pull-request/19412/ |
Sorry, something went wrong.
|
Removing author-ready because this needs at least one more approval to land before next week. From the previous benchmark CI: confidence improvement accuracy (*) (**) (***) misc/startup.js mode='process' script='benchmark/fixtures/require-cachable' dur=1 *** -7.38 % ±1.09% ±1.46% ±1.90% misc/startup.js mode='process' script='test/fixtures/semicolon' dur=1 *** -5.12 % ±0.79% ±1.06% ±1.37% misc/startup.js mode='worker' script='benchmark/fixtures/require-cachable' dur=1 *** 54.77 % ±1.42% ±1.91% ±2.50% misc/startup.js mode='worker' script='test/fixtures/semicolon' dur=1 *** 48.22 % ±3.27% ±4.40% ±5.82% Resume CI: https://ci.nodejs.org/job/node-test-pull-request/19454/ |
Sorry, something went wrong.
|
@joyeecheung the label is not meant as ready to land but the author is done. Missing LGs are absolutely fine while having the author ready label applied :-) |
Sorry, something went wrong.
That seems to contradict the label description:
And the collaborator guide:
|
Sorry, something went wrong.
The label was not up to date. It's fixed now.
Thanks! Seems like I missed that in #24893. I am opening a PR to fix that right away. |
Sorry, something went wrong.
|
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/19636/ |
Sorry, something went wrong.
Sorry, something went wrong.
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway. PR-URL: #24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This patch changes the NativeModuleLoader to always try to find code cache for native modules when it compiles them, and always produce and store the code cache after compilation. The cache map is protected by a mutex and can be accessed by different threads - including the worker threads and the main thread. Hence any thread can reuse the code cache if the native module has already been compiled by another thread - in particular the cache of the bootstrappers and per_context.js will always be hit when a new thread is spun. This results in a ~6% startup overhead in the worst case (when only the main thread is launched without requiring any additional native module - it now needs to do the extra work of finding and storing caches), which balances out the recent improvements by moving the compilation to C++, but it also leads to a ~60% improvement in the best case (when a worker thread is spun and requires a lot of native modules thus hitting the cache compiled by the main thread). PR-URL: #24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
This does not land cleanly on v11.x, would someone be willing to backport? |
Sorry, something went wrong.
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway. PR-URL: #24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This patch changes the NativeModuleLoader to always try to find code cache for native modules when it compiles them, and always produce and store the code cache after compilation. The cache map is protected by a mutex and can be accessed by different threads - including the worker threads and the main thread. Hence any thread can reuse the code cache if the native module has already been compiled by another thread - in particular the cache of the bootstrappers and per_context.js will always be hit when a new thread is spun. This results in a ~6% startup overhead in the worst case (when only the main thread is launched without requiring any additional native module - it now needs to do the extra work of finding and storing caches), which balances out the recent improvements by moving the compilation to C++, but it also leads to a ~60% improvement in the best case (when a worker thread is spun and requires a lot of native modules thus hitting the cache compiled by the main thread). PR-URL: #24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Lands cleanly now 👍 |
Sorry, something went wrong.
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway. PR-URL: nodejs#24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This patch changes the NativeModuleLoader to always try to find code cache for native modules when it compiles them, and always produce and store the code cache after compilation. The cache map is protected by a mutex and can be accessed by different threads - including the worker threads and the main thread. Hence any thread can reuse the code cache if the native module has already been compiled by another thread - in particular the cache of the bootstrappers and per_context.js will always be hit when a new thread is spun. This results in a ~6% startup overhead in the worst case (when only the main thread is launched without requiring any additional native module - it now needs to do the extra work of finding and storing caches), which balances out the recent improvements by moving the compilation to C++, but it also leads to a ~60% improvement in the best case (when a worker thread is spun and requires a lot of native modules thus hitting the cache compiled by the main thread). PR-URL: nodejs#24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
In preparation of sharing code cache among different threads - we simply rely on v8 to reject invalid cache, since there isn't any serious consequence when the cache is invalid anyway. PR-URL: nodejs#24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This patch changes the NativeModuleLoader to always try to find code cache for native modules when it compiles them, and always produce and store the code cache after compilation. The cache map is protected by a mutex and can be accessed by different threads - including the worker threads and the main thread. Hence any thread can reuse the code cache if the native module has already been compiled by another thread - in particular the cache of the bootstrappers and per_context.js will always be hit when a new thread is spun. This results in a ~6% startup overhead in the worst case (when only the main thread is launched without requiring any additional native module - it now needs to do the extra work of finding and storing caches), which balances out the recent improvements by moving the compilation to C++, but it also leads to a ~60% improvement in the best case (when a worker thread is spun and requires a lot of native modules thus hitting the cache compiled by the main thread). PR-URL: nodejs#24950 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This behavior of sometimes returning the function & other times returning the code cache was removed a long time ago in the referenced PR, as evinced by the return type `MaybeLocal<Function>`. Remove these incorrect comments. Refs: nodejs#24950
This behavior of sometimes returning the function & other times returning the code cache was removed a long time ago in the referenced PR, as evinced by the return type `MaybeLocal<Function>`. Remove these incorrect comments. Refs: #24950 PR-URL: #47083 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This behavior of sometimes returning the function & other times returning the code cache was removed a long time ago in the referenced PR, as evinced by the return type `MaybeLocal<Function>`. Remove these incorrect comments. Refs: #24950 PR-URL: #47083 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This behavior of sometimes returning the function & other times returning the code cache was removed a long time ago in the referenced PR, as evinced by the return type `MaybeLocal<Function>`. Remove these incorrect comments. Refs: #24950 PR-URL: #47083 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
| Back | FazBrowse Home | New Git URL |
src: remove code cache integrity check
In preparation of sharing code cache among different threads -
we simply rely on v8 to reject invalid cache, since there isn't
any serious consequence when the cache is invalid anyway.
src: always compile and store code cache for native modules
This patch changes the NativeModuleLoader to always try to find
code cache for native modules when it compiles them, and always
produce and store the code cache after compilation. The cache
map is protected by a mutex and can be accessed by different
threads - including the worker threads and the main thread. Hence any
thread can reuse the code cache if the native module has already
been compiled by another thread - in particular the cache of the
bootstrappers and per_context.js will always be hit when a new thread
is spun.
This results in a ~6% startup overhead in the worst case
(when only the main thread is launched without requiring any additional
native module - it now needs to do the extra work of finding and
storing caches), which balances out the recent improvements by moving
the compilation to C++, but it also leads to a ~60% improvement in
the best case (when a worker thread is spun and requires a lot of native
modules thus hitting the cache compiled by the main thread).
Local benchmark results:
Checklist