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

process: expose uv_rusage on process.resourceUsage() #28018

Closed
wants to merge 1 commit into from

Conversation

vmarchaud
Copy link
Contributor

@vmarchaud vmarchaud commented Jun 2, 2019

As discussed in nodejs/diagnostics#161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
metrics like the page faults and context switches.

The make -j4 test are not passing locally because of a failing test test/parallel/test-worker-prof.js but i believe it's not related to my changes.
Concerning the tests, i didn't really tested the output of the function mainly because it might make the test flaky depending on the platform and runtime behavior.

This is my first PR on the core, so i might have forgotten some requirements.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. errors Issues and PRs related to JavaScript errors originated in Node.js core. process Issues and PRs related to the process subsystem. labels Jun 2, 2019
@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 2, 2019
doc/api/process.md Outdated Show resolved Hide resolved
src/node_process_methods.cc Outdated Show resolved Hide resolved
@Trott
Copy link
Member

Trott commented Jun 2, 2019

This is my first PR on the core, so i might have forgotten some requirements.

Looks like you didn't forget anything. Thanks for the pull request and welcome!

@nodejs-github-bot
Copy link
Collaborator

@vmarchaud vmarchaud force-pushed the resources-usage branch 3 times, most recently from dfdcae7 to 2eff3d1 Compare June 2, 2019 12:41
@addaleax addaleax removed the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Jun 2, 2019
@Trott
Copy link
Member

Trott commented Jun 2, 2019

Any reason this would make test-worker-prof less reliable? It's failing a lot in CI here, but I'm not sure if it's because of the changes here or something else?

doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Show resolved Hide resolved
-->

* Returns: {Object}
* `minflt` {integer}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it matters at the JS level, but these are all unsigned integers.

doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
test/parallel/test-resources-usage.js Outdated Show resolved Hide resolved
test/parallel/test-resources-usage.js Outdated Show resolved Hide resolved
@vmarchaud vmarchaud force-pushed the resources-usage branch 4 times, most recently from 315c0e1 to 3f0d72b Compare June 3, 2019 11:31
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM. My comments are not blockers.

doc/api/process.md Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
test/parallel/test-resource-usage.js Outdated Show resolved Hide resolved
@vmarchaud vmarchaud changed the title process: expose uv_rusage on process.resourcesUsage() process: expose uv_rusage on process.resourceUsage() Jun 5, 2019
@vmarchaud
Copy link
Contributor Author

I've switched to full names, added the mapping between node names and libuv ones. Also exposed all the fields even if not supported as @bnoordhuis said.

@BridgeAR
Copy link
Member

BridgeAR commented Jun 5, 2019

What benefit do we have by exposing entries that are not supported on any platform?

@addaleax
Copy link
Member

addaleax commented Jun 5, 2019

@BridgeAR Future-proofing and standards conformance would be the two big pro arguments, I imagine?

doc/api/process.md Show resolved Hide resolved
doc/api/process.md Outdated Show resolved Hide resolved
@vmarchaud vmarchaud force-pushed the resources-usage branch 2 times, most recently from d6374b6 to 7bed043 Compare June 5, 2019 12:51
@vmarchaud
Copy link
Contributor Author

I believe the PR is good to be merged expect if someone has a blocker on the exposed fields ?

@vmarchaud vmarchaud force-pushed the resources-usage branch 2 times, most recently from b582b90 to d9579de Compare June 18, 2019 09:04
@vmarchaud
Copy link
Contributor Author

I've rebased on master hoping that the test on worker-prof will pass now

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@vmarchaud
Copy link
Contributor Author

I've checked the test failures and it doesn't seems to be related to this PR, what are the next steps in this case ?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

As discussed in nodejs/diagnostics#161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
mertrics like the page faults and context switches.
@vmarchaud
Copy link
Contributor Author

@Trott I'm not sure what are the next steps, do you think the PR can be merged ?

@addaleax
Copy link
Member

addaleax commented Jul 1, 2019

@vmarchaud Thanks for the ping!

Landed in 6271ef0 🎉

@addaleax addaleax closed this Jul 1, 2019
addaleax pushed a commit that referenced this pull request Jul 1, 2019
As discussed in nodejs/diagnostics#161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
mertrics like the page faults and context switches.

PR-URL: #28018
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@vmarchaud vmarchaud deleted the resources-usage branch July 1, 2019 20:35
targos pushed a commit that referenced this pull request Jul 2, 2019
As discussed in nodejs/diagnostics#161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
mertrics like the page faults and context switches.

PR-URL: #28018
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Jul 2, 2019
As discussed in nodejs/diagnostics#161,
the core should expose important metrics about the runtime, this PR's
goal is to let user get the number of io request made, and lower level
mertrics like the page faults and context switches.

PR-URL: #28018
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos added a commit that referenced this pull request Jul 2, 2019
Notable changes:

* build:
  * Experimental support for building Node.js on MIPS architecture
    is back. #27992
* child_process:
  * The promisified versions of `child_process.exec` and
    `child_process.execFile` now both return a `Promise` which has the
	child instance attached to their `child` property.
	#28325
* deps:
  * Updated libuv to 1.30.0. #28449
    * Support for the Haiku platform has been added.
    * The maximum `UV_THREADPOOL_SIZE` has been increased from 128 to
	  1024.
    * `uv_fs_copyfile()` now works properly when the source and
	  destination files are the same.
* process:
  * A new method, `process.resourceUsage()` was added. It returns
    resource usage for the current process, such as CPU time.
	#28018
* src:
  * Fixed an issue related to stdio that could lead to a crash of the
    process in some circumstances.
	#28490
* stream:
  * Added a `writableFinished` property to writable streams. It
    indicates that all the data has been flushed to the underlying
	system. #28007
* worker:
  * Fixed an issue that prevented worker threads to listen for data on
    stdin. #28153

PR-URL: #28508
@targos targos mentioned this pull request Jul 2, 2019
targos added a commit that referenced this pull request Jul 2, 2019
Notable changes:

* build:
  * Experimental support for building Node.js on MIPS architecture
    is back. #27992
* child_process:
  * The promisified versions of `child_process.exec` and
    `child_process.execFile` now both return a `Promise` which has the
	child instance attached to their `child` property.
	#28325
* deps:
  * Updated libuv to 1.30.0. #28449
    * Support for the Haiku platform has been added.
    * The maximum `UV_THREADPOOL_SIZE` has been increased from 128 to
	  1024.
    * `uv_fs_copyfile()` now works properly when the source and
	  destination files are the same.
* process:
  * A new method, `process.resourceUsage()` was added. It returns
    resource usage for the current process, such as CPU time.
	#28018
* src:
  * Fixed an issue related to stdio that could lead to a crash of the
    process in some circumstances.
	#28490
* stream:
  * Added a `writableFinished` property to writable streams. It
    indicates that all the data has been flushed to the underlying
	system. #28007
* worker:
  * Fixed an issue that prevented worker threads to listen for data on
    stdin. #28153
* meta:
  * Added Jiawen Geng (https://github.com/gengjiawen) to collaborators.
    #28322

PR-URL: #28508
targos added a commit that referenced this pull request Jul 2, 2019
Notable changes:

* build:
  * Experimental support for building Node.js on MIPS architecture
    is back. #27992
* child_process:
  * The promisified versions of `child_process.exec` and
    `child_process.execFile` now both return a `Promise` which has the
	child instance attached to their `child` property.
	#28325
* deps:
  * Updated libuv to 1.30.1. #28449,
    #28511
    * Support for the Haiku platform has been added.
    * The maximum `UV_THREADPOOL_SIZE` has been increased from 128 to
	  1024.
    * `uv_fs_copyfile()` now works properly when the source and
	  destination files are the same.
* process:
  * A new method, `process.resourceUsage()` was added. It returns
    resource usage for the current process, such as CPU time.
	#28018
* src:
  * Fixed an issue related to stdio that could lead to a crash of the
    process in some circumstances.
	#28490
* stream:
  * Added a `writableFinished` property to writable streams. It
    indicates that all the data has been flushed to the underlying
	system. #28007
* worker:
  * Fixed an issue that prevented worker threads to listen for data on
    stdin. #28153
* meta:
  * Added Jiawen Geng (https://github.com/gengjiawen) to collaborators.
    #28322

PR-URL: #28508
targos added a commit that referenced this pull request Jul 3, 2019
Notable changes:

* build:
  * Experimental support for building Node.js on MIPS architecture
    is back. #27992
* child_process:
  * The promisified versions of `child_process.exec` and
    `child_process.execFile` now both return a `Promise` which has the
	child instance attached to their `child` property.
	#28325
* deps:
  * Updated libuv to 1.30.1. #28449,
    #28511
    * Support for the Haiku platform has been added.
    * The maximum `UV_THREADPOOL_SIZE` has been increased from 128 to
	  1024.
    * `uv_fs_copyfile()` now works properly when the source and
	  destination files are the same.
* process:
  * A new method, `process.resourceUsage()` was added. It returns
    resource usage for the current process, such as CPU time.
	#28018
* src:
  * Fixed an issue related to stdio that could lead to a crash of the
    process in some circumstances.
	#28490
* stream:
  * Added a `writableFinished` property to writable streams. It
    indicates that all the data has been flushed to the underlying
	system. #28007
* worker:
  * Fixed an issue that prevented worker threads to listen for data on
    stdin. #28153
* meta:
  * Added Jiawen Geng (https://github.com/gengjiawen) to collaborators.
    #28322

PR-URL: #28508
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++. 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.

10 participants