{"id":16761034,"url":"https://github.com/bmeurer/async-hooks-performance-impact","last_synced_at":"2025-10-09T03:33:08.141Z","repository":{"id":141109419,"uuid":"117679678","full_name":"bmeurer/async-hooks-performance-impact","owner":"bmeurer","description":"Performance impact of async_hooks","archived":false,"fork":false,"pushed_at":"2018-01-17T18:58:19.000Z","size":287,"stargazers_count":59,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-29T18:33:52.341Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmeurer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-16T12:15:13.000Z","updated_at":"2024-12-31T01:04:13.000Z","dependencies_parsed_at":"2024-07-12T00:22:34.445Z","dependency_job_id":null,"html_url":"https://github.com/bmeurer/async-hooks-performance-impact","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bmeurer/async-hooks-performance-impact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmeurer%2Fasync-hooks-performance-impact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmeurer%2Fasync-hooks-performance-impact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmeurer%2Fasync-hooks-performance-impact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmeurer%2Fasync-hooks-performance-impact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmeurer","download_url":"https://codeload.github.com/bmeurer/async-hooks-performance-impact/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmeurer%2Fasync-hooks-performance-impact/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000714,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T04:25:16.717Z","updated_at":"2025-10-09T03:33:08.124Z","avatar_url":"https://github.com/bmeurer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Performance impact of async_hooks\n\n - https://github.com/nodejs/diagnostics/issues/124\n - https://github.com/nodejs/benchmarking/issues/188\n\nThis is a simple demo of the potential performance impact of `async_hooks`\non Promise heavy workloads. This repository contains the popular\n[Bluebird](https://github.com/petkaantonov/bluebird) benchmarks and the\nso-called *Wikipedia Promise* benchmark with and\nwithout `async_hooks` (running with native promises).\n\nTo measure the actual impact there's a version of each benchmark with\nan empty `init` hook, i.e. we prepend the following code to the actual\ncode under test:\n\n```js\nconst async_hooks = require('async_hooks');\nconst hook = async_hooks.createHook({\n    init(asyncId, type, triggerAsyncId) { }\n});\nhook.enable();\n```\n\nWe also test with all hooks (i.e. `init`, `before`, `after`, `destroy`\nand `promiseResolve`) using the following snippet:\n\n```js\nconst async_hooks = require('async_hooks');\nconst hook = async_hooks.createHook({\n    init(asyncId, type, triggerAsyncId, resource) { },\n    before(asyncId) { },\n    after(asyncId) { },\n    destroy(asyncId) { },\n    promiseResolve(asyncId) { },\n});\nhook.enable();\n```\n\n## Results\n\nHere the results of running the Promise micro benchmarks with and without\n`async_hooks` enabled:\n\n| Benchmark                      | Node 8.9.4 | Node 9.4.0 |\n| ------------------------------:| ----------:| ----------:|\n| Bluebird-doxbee (regular)      |     226 ms |     189 ms |\n| Bluebird-doxbee (init hook)    |     383 ms |     341 ms |\n| Bluebird-doxbee (all hooks)    |     440 ms |     411 ms |\n| Bluebird-parallel (regular)    |     924 ms |     696 ms |\n| Bluebird-parallel (init hook)  |    1380 ms |    1050 ms |\n| Bluebird-parallel (all hooks)  |    1488 ms |    1220 ms |\n| Wikipedia (regular)            |     993 ms |     804 ms |\n| Wikipedia (init hook)          |    2025 ms |    1893 ms |\n| Wikipedia (all hooks)          |    2109 ms |    2124 ms |\n\n![Results for Node 9.4.0](https://raw.githubusercontent.com/bmeurer/async-hooks-performance-impact/master/results-promise-node-9.4.0.png)\n\nAnd we also ran some more realistic benchmarks, based on `hapi` and\n`koa`, with and without `async_hooks` enabled:\n\n| Benchmark         | Node 9.4.0    |\n| ----------------: | ------------: |\n| hapi (asynchooks) | 6026.9 reqs   |\n| hapi (regular)    | 9024.19 reqs  |\n| koa (asynchooks)  | 11508.6 reqs  |\n| koa (regular)     | 12592.55 reqs |\n\nThe `koa` benchmark is pretty flaky, so the performance difference could be\nwithin noise and thus not relevant.\n\n![Results for Node 9.4.0](https://raw.githubusercontent.com/bmeurer/async-hooks-performance-impact/master/results-hapi-koa-node-9.4.0.png)\n\n## Bluebird benchmarks\n\nThe files here are modified from: [https://github.com/petkaantonov/bluebird/tree/master/benchmark](https://github.com/petkaantonov/bluebird/tree/master/benchmark)\n\nThe current version is based on `bluebird@c0d4472cecd523c2f9d4805a23d87be3cfe03b41`\n\n\n## Wikipedia Benchmark\n\nThe files here are modified from: [https://github.com/wikimedia/web-stream-util](https://github.com/wikimedia/web-stream-util)\n\nThe current version is based on `web-stream-util@fc76740cd6a73dcb044251a233bc3c868d3c9a77`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmeurer%2Fasync-hooks-performance-impact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmeurer%2Fasync-hooks-performance-impact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmeurer%2Fasync-hooks-performance-impact/lists"}