Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative utilization in eventLoopUtilization for worker_threads #40525

Open
tshemsedinov opened this issue Oct 19, 2021 · 2 comments
Open

Negative utilization in eventLoopUtilization for worker_threads #40525

tshemsedinov opened this issue Oct 19, 2021 · 2 comments
Labels
perf_hooks Issues and PRs related to the implementation of the Performance Timing API. worker Issues and PRs related to Worker support.

Comments

@tshemsedinov
Copy link
Contributor

tshemsedinov commented Oct 19, 2021

Version

v14.18.1, v15.14.0, v16.11.1, v17.0.0-pre (as of 16 Oct `21)

Platform

Linux marcus 5.13.19-200.fc34.x86_64 #1 SMP Sat Sep 18 16:32:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

worker_threads

What steps will reproduce the bug?

Repository with example: https://github.com/tshemsedinov/wtu

How often does it reproduce? Is there a required condition?

If worker event loop is empty in delta calculation period.

What is the expected behavior?

Delta fields active and utilization are expected to be positive, utilization expected to be [0..1].

What do you see instead?

Negative values in ~50% cases. But if you add setInterval with empty handler for minimum eventloop load, utilization will be always between 0 and 1.

Additional information

I know that it is a stable API but it would be better in far future:

  • I'd propose to reduce time between loopIdleTime() call and now() in lower level, but my experiments in this field is not successful, still getting negative utilization.
  • To decompose this function to respect separation of concerns into performance.eventLoopUsage(): EventLoopUsage and performance.eventLoopUtilization(usage1, usage2): EventLoopUtilization.
  • Now we have 6 places to calculate proportion (for utilization), 3 in internal/worker.js and 3 in internal/perf/event_loop_utilization.js.
@tshemsedinov
Copy link
Contributor Author

Refs: #35664
Refs: #37134

FYI: @trevnorris and @addaleax

@Mesteery Mesteery added perf_hooks Issues and PRs related to the implementation of the Performance Timing API. worker Issues and PRs related to Worker support. labels Oct 19, 2021
@trevnorris
Copy link
Contributor

Thanks. I'll give it a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf_hooks Issues and PRs related to the implementation of the Performance Timing API. worker Issues and PRs related to Worker support.
Projects
None yet
Development

No branches or pull requests

3 participants