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

worker: allow retrieving elu from parent #45330

Closed
wants to merge 1 commit into from

Conversation

santigimeno
Copy link
Member

Usually, when extracting the ELU from a specific JS thread is better to do it from a different thread as the event loop we're observing might already be blocked. The Worker.performance.eventLoopUtilization() method allows us to do this for worker threads, but there's not a way to do this for the main thread. This new API, which allows us to retrieve the ELU of the parent thread from a specific worker, is going to enable this.

For the moment, I have defined this new API in

require('worker_threads').parent.performance.eventLoopUtilization()

though I haven't added documentation yet as
a) I want to know first whether this approach is acceptable, and in case it is,
b) I'm not really sure whether that's the place the API should live in. Would love receiving feedback on this.

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Nov 5, 2022
@santigimeno santigimeno changed the title worker_threads: allow retrieving elu from parent worker: allow retrieving elu from parent Nov 5, 2022
lib/internal/worker.js Outdated Show resolved Hide resolved
lib/internal/worker.js Outdated Show resolved Hide resolved
lib/internal/worker/io.js Outdated Show resolved Hide resolved
lib/worker_threads.js Outdated Show resolved Hide resolved
lib/worker_threads.js Outdated Show resolved Hide resolved
lib/internal/worker.js Show resolved Hide resolved
lib/internal/worker.js Outdated Show resolved Hide resolved
lib/worker_threads.js Outdated Show resolved Hide resolved
@aduh95 aduh95 requested a review from addaleax November 6, 2022 13:10
Usually, when extracting the ELU from a specific JS thread is better to
do it from a different thread as the event loop we're observing might
already be blocked. The `Worker.performance.eventLoopUtilization()`
method allows us to do this for worker threads, but there's not a way
to do this for the main thread. This new API, which allows us to
retrieve the ELU of the parent thread from a specific worker, is going
to enable this.

For the moment, I have defined this new API in
```
require('worker_threads').parent.performance.eventLoopUtilization()
```
though I haven't added documentation yet as
a) I want to know first whether this approach is acceptable, and in case
it is,
b) I'm not really sure whether that's the place the API should live in.
Would love receiving feedback on this.
@santigimeno santigimeno added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 10, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 10, 2022
@nodejs-github-bot
Copy link
Collaborator

@santigimeno
Copy link
Member Author

@aduh95 @jasnell any feedback on where this API should be located so I can add the docs? I've added it to

require('worker_threads').parent.performance.eventLoopUtilization()

Other option could be:

require('worker_threads').parentPerformance.eventLoopUtilization()

@aduh95
Copy link
Contributor

aduh95 commented May 11, 2024

This would need a rebase to fix the git conflicts.

any feedback on where this API should be located so I can add the docs?

Do we expect to expose more property related to the parent? If not, it might make more sense to go with parentPerformance – but no string feelings either way from my side.

@aduh95 aduh95 added the stalled Issues and PRs that are stalled. label May 11, 2024
Copy link
Contributor

This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open.

Copy link
Contributor

Closing this because it has stalled. Feel free to reopen if this issue/PR is still relevant, or to ping the collaborator who labelled it stalled if you have any questions.

@github-actions github-actions bot closed this Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants