Skip to content

process: add threadCpuUsage#56467

Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom
ShogunPanda:thread-cpu-usage
Feb 21, 2025
Merged

process: add threadCpuUsage#56467
nodejs-github-bot merged 1 commit intonodejs:mainfrom
ShogunPanda:thread-cpu-usage

Conversation

@ShogunPanda
Copy link
Copy Markdown
Contributor

This PR add the threadCpuUsage method to process.
The method works exactly like cpuUsage but it returns thread specific metrics.
This is already implemented (by me :)) in user-land in https://www.npmjs.com/package/thread-cpu-usage.

The PR is currently a draft as I'm gonna use the CI to see which platform don't support this. I'll add documentation updates once this is solved.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jan 4, 2025
@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 4, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 4, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/64336/

@santigimeno
Copy link
Copy Markdown
Member

What about moving the platform dependent code to libuv? Maybe taking libuv/libuv#3120 to the finish line would be a good idea.

Copy link
Copy Markdown
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except couple of questions and concerns

};
}

const threadCpuValues = new Float64Array(2);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend moving this to C++ side and updating it. A similar implementation exist in node url

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look it up. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to look it up in the code but I couldn't find it.
Do you mind linking a reference to the similar implementation so I can check it out?

@ShogunPanda
Copy link
Copy Markdown
Contributor Author

What about moving the platform dependent code to libuv? Maybe taking libuv/libuv#3120 to the finish line would be a good idea.

I'm sorry but I have very limited bandwidth lately. Trying to contribute to a codebase I never already did to it's not feasible for me.

Once this lands everyone is absolutely welcome to port this to libuv.

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 7, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 7, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@juanarbol
Copy link
Copy Markdown
Member

What about moving the platform dependent code to libuv? Maybe taking libuv/libuv#3120 to the finish line would be a good idea.

if that PR is orphaned, I can work on that one. Can I @jasnell?

@ShogunPanda
Copy link
Copy Markdown
Contributor Author

@juanarbol Ok, I'll pause on this until you update me about libuv PR. Thanks for taking care of that!

@juanarbol
Copy link
Copy Markdown
Member

@juanarbol Ok, I'll pause on this until you update me about libuv PR. Thanks for taking care of that!

There we go libuv/libuv#4666

@ShogunPanda
Copy link
Copy Markdown
Contributor Author

Amazing! Keep up posted when this is released in libuv so I can update the dependencies and make this PR much leaner :)

Do you have an approximate ETA?

@juanarbol
Copy link
Copy Markdown
Member

juanarbol commented Jan 9, 2025

Do you have an approximate

I do not. They asked for macOS support, I'm gonna send patches on my spare time, I think I have some slots today and tomorrow after work. But idk when is the next release.

I just gave support to macOS and addressed all the comments.

@juanarbol
Copy link
Copy Markdown
Member

juanarbol commented Jan 14, 2025

@ShogunPanda Paolo, the feature is landed and it is about to be released see libuv/libuv#4667

The feature is released!

@ShogunPanda ShogunPanda marked this pull request as ready for review January 18, 2025 07:50
@ShogunPanda
Copy link
Copy Markdown
Contributor Author

@juanarbol Thanks for your effort on this.
Since #56616 has landed, I updated this to use the new API.
This is now ready to be reviewed!

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2025
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ShogunPanda ShogunPanda added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 21, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 21, 2025
@nodejs-github-bot nodejs-github-bot merged commit e027791 into nodejs:main Feb 21, 2025
57 checks passed
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Landed in e027791

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.