Title: perf_hooks.performance.timerify() with histogram: RangeError [ERR_OUT_OF_RANGE] on arm64 · Issue #41641 · nodejs/node · GitHub
Open Graph Title: perf_hooks.performance.timerify() with histogram: RangeError [ERR_OUT_OF_RANGE] on arm64 · Issue #41641 · nodejs/node
X Title: perf_hooks.performance.timerify() with histogram: RangeError [ERR_OUT_OF_RANGE] on arm64 · Issue #41641 · nodejs/node
Description: Version v14, v16, v17, v18, v26 Platform macOS v12.4 (21F79). Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 Subsystem perf_hooks What steps will reproduce the bu...
Open Graph Description: Version v14, v16, v17, v18, v26 Platform macOS v12.4 (21F79). Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 Subsystem per...
X Description: Version v14, v16, v17, v18, v26 Platform macOS v12.4 (21F79). Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 Subsystem per...
Opengraph URL: https://github.com/nodejs/node/issues/41641
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"perf_hooks.performance.timerify() with histogram: RangeError [ERR_OUT_OF_RANGE] on arm64","articleBody":"### Version\n\nv14, v16, v17, v18, v26\n\n### Platform\n\nmacOS v12.4 (21F79).\n\nDarwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64\n\n### Subsystem\n\nperf_hooks\n\n### What steps will reproduce the bug?\n\nRun this snippet:\n\n```js\nimport {createHistogram, performance} from 'node:perf_hooks';\n\nconst fn = () => {};\n\nconst timerified = performance.timerify(fn, {histogram: createHistogram()});\n\nfor (let i = 0; i \u003c 100_000; i++) {\n\ttry {\n\t\ttimerified();\n\t} catch (error) {\n\t\tconsole.error('Crashed on iteration', i);\n\n\t\tthrow error;\n\t}\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\n100% consistent reproduction, requires arm64, maybe requires macOS.\n\n### What is the expected behavior?\n\nCalling the timerified function returned from `perf_hooks.performance.timerify()` should successfully record to the histogram.\n\n### What do you see instead?\n\n```\nnode:internal/errors:466\n ErrorCaptureStackTrace(err);\n ^\n\nRangeError [ERR_OUT_OF_RANGE]: The value of \"val\" is out of range. It must be a safe integer greater than 0. Received 0\n at new NodeError (node:internal/errors:377:5)\n at RecordableHistogram.record (node:internal/histogram:290:13)\n at processComplete (node:internal/perf/timerify:40:15)\n at timerified fn (node:internal/perf/timerify:88:5)\n at file:///Users/jonah/programming/benchmark/index.mjs:9:3\n at ModuleJob.run (node:internal/modules/esm/module_job:198:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:409:24)\n at async loadESM (node:internal/process/esm_loader:85:5)\n at async handleMainPromise (node:internal/modules/run_main:61:12) {\n code: 'ERR_OUT_OF_RANGE'\n}\n\nNode.js v18.1.0\n```\n\n### Additional information\n\nOriginally reported here: https://github.com/sindresorhus/yoctocolors/pull/9#issuecomment-1019033882\n\n---\n\nThe bug appears to be from the implementation of `perf_hooks.performance.timerify()` with a histogram, when calling the returned timerified function. The error comes from the input validation of `RecordableHistogram#record()`, attempting to record a value `x \u003c 1` will throw. For whatever reason `timerify()` seems to be recording an execution duration of 0 and trying to record that. See the error stacktrace for more info.","author":{"url":"https://github.com/jonahsnider","@type":"Person","name":"jonahsnider"},"datePublished":"2022-01-22T07:10:51Z","url":"https://github.com/nodejs/node/issues/41641"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8179c5a1-7191-ff1a-6b7f-5b3b608707cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9070:137C1B:31C49B:40E516:6AED1DAA |
| html-safe-nonce | 8daf81fce30d8969e406f18a66b23eea9555efeb9e07006e7c85dbe956960e2d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDcwOjEzN0MxQjozMUM0OUI6NDBFNTE2OjZBRUQxREFBIiwidmlzaXRvcl9pZCI6IjgwNDAzMDM5MDk0ODMxMjYxODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 87c4eab6163e4a414310030fa523c9f7d5543b9a7764ab8df75b1b234d8e78c7 |
| hovercard-subject-tag | issue:1111307705 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/41641/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da94628baad9bbb25903d7c87e8086a3c5c062cbb83c45bd8b817d7ea2ff8ffe/nodejs/node/issues/41641 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da94628baad9bbb25903d7c87e8086a3c5c062cbb83c45bd8b817d7ea2ff8ffe/nodejs/node/issues/41641 |
| og:image:alt | Version v14, v16, v17, v18, v26 Platform macOS v12.4 (21F79). Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 Subsystem per... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonahsnider |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width