summaryrefslogtreecommitdiff
path: root/benchmark/async_hooks
Commit message (Collapse)AuthorAgeFilesLines
* async_hooks: add async local storage propagation benchmarksChengzhong Wu2023-02-034-0/+186
| | | | | | | | | | | | | Add micro-benchmarks to verify the performance degradation related to the number of active `AsyncLocalStorage`s. With these benchmarks, trying to improve the async context propagation to be an O(1) operation, which is an operation more frequent compared to `asyncLocalStorage.run` and `asyncLocalStorage.getStore`. PR-URL: https://github.com/nodejs/node/pull/46414 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
* benchmark: add trailing commas in `benchmark/async_hooks`Antoine du Hamel2023-02-015-21/+21
| | | | | | PR-URL: https://github.com/nodejs/node/pull/46424 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* async_hooks: use resource stack for AsyncLocalStorage runStephen Belanger2021-08-311-0/+21
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/39890 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
* benchmark: always throw the same Error instanceAnna Henningsen2020-07-291-1/+2
| | | | | | | | | | | | | | | | Stack trace capturing currently accounts for 40 % of the benchmark running time. Always throwing the same exception object removes that overhead and lets the benchmark be more focused on what it is supposed to measure. Refs: https://github.com/nodejs/node/pull/34512#issuecomment-663977271 PR-URL: https://github.com/nodejs/node/pull/34523 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
* async_hooks: optimize fast-path promise hook for ALSAndrey Pechkurov2020-07-281-0/+6
| | | | | | | | | | | | | Remove unnecessary native-to-JS code switches in fast-path for PromiseHooks. Those switches happen even if a certain type of hook (say, before) is not installed, which may lead to sub-optimal performance in the AsyncLocalStorage scenario, i.e. when there is only an init hook. PR-URL: https://github.com/nodejs/node/pull/34512 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
* benchmark: fix async-resource benchmarkAnna Henningsen2020-06-061-0/+2
| | | | | | | | | | | | | | | | | | | | In the benchmark, because it performs asynchronous operations before writing its HTTP replies, the underlying socket can be closed by the peer before the response is written. Since 28e6626ce7020, that means that attempting to `.end()` the HTTP response results in an uncaught exception, breaking the benchmark. Fix that by checking whether the response object has been destroyed or not before attempting to call `.end()`. https://github.com/nodejs/node/issues/33591 PR-URL: https://github.com/nodejs/node/pull/33642 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
* async_hooks: move PromiseHook handler to JSStephen Belanger2020-05-091-4/+23
| | | | | | | | | | | | | | | This avoids the need to wrap every promise in an AsyncWrap and also makes it easier to skip the machinery to track destroy events when there's no destroy listener. Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com> PR-URL: https://github.com/nodejs/node/pull/32891 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
* async_hooks: merge run and exit methodsAndrey Pechkurov2020-04-131-1/+1
| | | | | | PR-URL: https://github.com/nodejs/node/pull/31950 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
* async_hooks: move to lazy destroy hook registration in AsyncResourceAndrey Pechkurov2020-04-061-1/+10
| | | | | | PR-URL: https://github.com/nodejs/node/pull/32429 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
* benchmark: fix error on server close in AsyncLocalStorage benchmarkAndrey Pechkurov2020-04-021-4/+7
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/32503 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* benchmark: use const instead of var in async_hooksDaniele Belardi2020-03-301-1/+1
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31794 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* benchmark: add `test` and `all` options and improve errors"Ruben Bridgewater2020-03-092-9/+10
| | | | | | | | | | This reverts commit 4671d551cf9210434bdadf65ee5654606d24da70 and contains a fix to the issue raised for the revert. PR-URL: https://github.com/nodejs/node/pull/31755 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* async_hooks: add store arg in AsyncLocalStorageAndrey Pechkurov2020-02-271-3/+3
| | | | | | | | | | | | | | | | | | | | | This commit introduces store as the first argument in AsyncLocalStorage's run methods. The change is motivated by the following expectation: most users are going to use a custom object as the store and an extra Map created by the previous implementation is an overhead for their use case. Important note. This is a backwards incompatible change. It was discussed and agreed an incompatible change is ok since the API is still experimental and the modified methods were only added within the last week so usage will be minimal to none. PR-URL: https://github.com/nodejs/node/pull/31930 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* async_hooks: introduce async-context APIvdeturckheim2020-02-231-3/+34
| | | | | | | | | | | | | | | | Adding AsyncLocalStorage class to async_hooks module. This API provide a simple CLS-like set of features. Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com> PR-URL: https://github.com/nodejs/node/pull/26540 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
* async_hooks: add executionAsyncResourceMatteo Collina2020-02-111-0/+151
| | | | | | | | | | | | Remove the need for the destroy hook in the basic APM case. Co-authored-by: Stephen Belanger <admin@stephenbelanger.com> PR-URL: https://github.com/nodejs/node/pull/30959 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* Revert "benchmark: add `test` and `all` options and improve errors"Anna Henningsen2020-02-101-4/+2
| | | | | | | | | | | This reverts commit dac579516ca662e731ac502c15e75009a2b9a8c9. Refs: https://github.com/nodejs/node/pull/31396 PR-URL: https://github.com/nodejs/node/pull/31722 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* benchmark: add `test` and `all` options and improve errorsRuben Bridgewater2020-02-091-2/+4
| | | | | | | | | | | | | | | | | | | | This adds a new `test` option. Using it automatically uses a single minimal option matrix to verify the benchmark works as expected. Using the new `all` option makes sure all test suites are run. On top of that the benchmarks will from now on report properly what category might have a typo, if any. The http duration was also refactored to use a option instead of relying on a configuration setting. The fixture folder is ignored as test suite from now on. PR-URL: https://github.com/nodejs/node/pull/31396 Fixes: https://github.com/nodejs/node/issues/31083 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* benchmark: benchmarking impacts of async hooks on promiseslegendecas2020-01-082-9/+39
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31188 Refs: https://github.com/nodejs/diagnostics/issues/124 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* benchmark: add benchmark on async_hooks enabled http serverlegendecas2020-01-021-0/+40
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31100 Refs: https://github.com/nodejs/diagnostics/issues/124 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
* benchmark: use let instead of var in async_hooksdnlup2019-11-181-3/+2
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/30470 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* benchmark: refactorRuben Bridgewater2018-02-011-3/+4
| | | | | PR-URL: https://github.com/nodejs/node/pull/18320 Reviewed-By: James M Snell <jasnell@gmail.com>
* benchmark: use destructuringRuben Bridgewater2018-01-231-4/+2
| | | | | | | | | This applies to all `async_hooks`, `dns`, `cluster`, `domain` and `module` benchmarks. PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* async_hooks: add destroy event for gced AsyncResourcesSebastian Mayr2017-11-161-0/+45
In cases where libraries create AsyncResources which may be emitting more events depending on usage, the only way to ensure that destroy is called properly is by calling it when the resource gets garbage collected. Fixes: https://github.com/nodejs/node/issues/16153 PR-URL: https://github.com/nodejs/node/pull/16998 Fixes: https://github.com/nodejs/node/issues/16153 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>