Title: Event Loop Additional Metrics to make event-loop stalls more visible · Issue #67649 · nodejs/node · GitHub
Open Graph Title: Event Loop Additional Metrics to make event-loop stalls more visible · Issue #67649 · nodejs/node
X Title: Event Loop Additional Metrics to make event-loop stalls more visible · Issue #67649 · nodejs/node
Description: What is the problem this feature will solve? Hey! This feature will help with more precise detection of long-running tasks in Node.js event loop. When calculating p99, it will help make long event-loop stalls more visible What is the fea...
Open Graph Description: What is the problem this feature will solve? Hey! This feature will help with more precise detection of long-running tasks in Node.js event loop. When calculating p99, it will help make long event-...
X Description: What is the problem this feature will solve? Hey! This feature will help with more precise detection of long-running tasks in Node.js event loop. When calculating p99, it will help make long event-...
Opengraph URL: https://github.com/nodejs/node/issues/67649
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Event Loop Additional Metrics to make event-loop stalls more visible","articleBody":"### What is the problem this feature will solve?\n\nHey!\nThis feature will help with more precise detection of long-running tasks in Node.js event loop. \nWhen calculating p99, it will help make long event-loop stalls more visible\n\n\n\n### What is the feature you are proposing to solve the problem?\n\nMy proposal is to add additional metrics like:\n- exceededIntervalCounter / okIntervalCounter\n - to calculate ratio between both of them\n- exceededIntervalDelay\n\nThanks to them, it would be easier to detect event-loop stalls.\nCause `ok samples` and `exceeded samples` are treated separately.\n\n\n\nBefore going further let me first explain current metrics, to be sure, that my understanding is correct.\nCause maybe there is something, I still don't understand well and this issue doesn't make sense.\n\nNote: During issue I'm writing typically about `task duration`. But I'm aware that more precise interpretation is `event loop probe delay`.\n\n#### Event Loop Utilisation\n\nMy understanding of Event Loop Utilization (ELU) is:\n- ELU isn't aware about task duration\n- ELU is similar to CPU utilization, but it's not CPU utilization\n- ELU like 85% may mean:\n - there is a problem with event loop\n - there is no problem with event loop, all tasks are short and event loop is healthy\n- ELU is great to detect skew in node.js cluster mode\n - worker1: ELU 20%\n - worker2: ELU 15%\n - worker3: ELU 85% - probably something wrong with this worker\n\n\u003cimg width=\"1808\" height=\"768\" alt=\"utilization\" src=\"https://github.com/user-attachments/assets/01a9b21d-af07-4080-bde5-fadfa20c4359\" />\n\n#### Event Loop Delay\n\nMy understanding of Event Loop Delay (ELD) is:\n- when calculating `p99`\n - it can be low, because a lot of short tasks can hide long tasks\n- `max` is always helpful\n- it's rather like: catastrophe detector\n\nCode looks like this:\n```javascript\nfunction monitorSample(diffNanos) {\n delay.observe(diffNanos / 1e9);\n // delay.observe((diffNanos - intervalNanos ) / 1e9); i'm not sure\n}\n```\n\n\n\u003cimg width=\"3168\" height=\"2048\" alt=\"event_loop_delay\" src=\"https://github.com/user-attachments/assets/adcb5a75-9547-44fb-a5a4-3a7dc1e488a2\" />\n\nAbout those metrics:\n- exceededIntervalCounter\n- exceededIntervalDelay\n\nMy understanding of those Event Loop those metrics is:\n- exceededIntervalCounter ( together with okIntervalCounter )\n - how often event loop was doing tasks longer than interval?\n - to be more precise: how often probe wasn't able to execute?\n - `okIntervalCounter` is needed to calculate ratio\n - `exceededRatio = exceededIntervalCounter / (okIntervalCounter + exceededIntervalCounter)`\n- exceededIntervalDelay\n - if probe wasn't able to execute, how long it was delayed?\n\nLet's assume interval 10ms to describe event loop status:\n- event loop idle or tasks below 10ms\n - always healthy sample\n- task between 10ms and 20ms - healthy or unhealthy sample\n - cause we don't know when task started\n- task higher than 20ms \n - always unhealthy sample\n\nCode could look like this:\n```javascript\nfunction monitorSample(diffNanos) {\n const lagNanos = Math.max(0, diffNanos - intervalNanos - intervalNanos);\n\n if (lagNanos > 0) {\n const missedSamples = Math.floor(diffNanos / intervalNanos);\n exceededCounter.inc(missedSamples);\n exceededHistogram.observe(lagNanos / 1e9);\n } else {\n okCounter.inc();\n }\n}\n```\n\n\u003cimg width=\"5368\" height=\"2928\" alt=\"exceeded\" src=\"https://github.com/user-attachments/assets/eb29f5c1-e76c-4d03-9978-84df8c530c94\" />\n\n#### The best part in all of that\n- all of those metrics still do not directly measure end-user latency\n - splitting one big task into smaller tasks may cause tasks overlap\n - from logical point of view, there is a lot of concurrent cpu tasks\n- so higher response times during day, faster during night, may suggest, that tasks are overlapping\n - healthy event loop metric won't tell anything about that\n\n\u003cimg width=\"3048\" height=\"2688\" alt=\"yield_and_semaphore\" src=\"https://github.com/user-attachments/assets/383aff7f-7f6e-494b-ac9d-ca62a54f2be1\" />\n\n### What alternatives have you considered?\n\nJust use current Event Loop Utilization and Event Loop Delay metrics.\n\nI'm open to your feedback!","author":{"url":"https://github.com/mateusz-nalepa","@type":"Person","name":"mateusz-nalepa"},"datePublished":"2026-11-20T11:34:55Z","url":"https://github.com/nodejs/node/issues/67649"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:8dc6cf55-a812-1f10-2ad8-3f8500ee43df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD00:107A1:3ACF65:4D393E:6B06199F |
| html-safe-nonce | 4d9488a6467427f3aebd6f6a53a982aca4715fab5b8b0297247e33fe41cbfa2f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDAwOjEwN0ExOjNBQ0Y2NTo0RDM5M0U6NkIwNjE5OUYiLCJ2aXNpdG9yX2lkIjoiNjM5MDkzOTY1MDY2Nzk3NzExOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 66d9e4d11027f466789939e20098988c7535cab71bc9d6a953d9bd1b85a0524d |
| hovercard-subject-tag | issue:6510617732 |
| 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/67649/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84be20ad849951f8bdb7565e6bc0106343cab7422ae7f42514b679c058e23eb0/nodejs/node/issues/67649 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84be20ad849951f8bdb7565e6bc0106343cab7422ae7f42514b679c058e23eb0/nodejs/node/issues/67649 |
| og:image:alt | What is the problem this feature will solve? Hey! This feature will help with more precise detection of long-running tasks in Node.js event loop. When calculating p99, it will help make long event-... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mateusz-nalepa |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| 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 | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width