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

misc: implement uv_getrusage_thread #4666

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

juanarbol
Copy link
Contributor

@juanarbol juanarbol commented Jan 9, 2025

Refs: #3119


This is #3120 with all comments addressed and tested on Linux, FreeBSD and macOS

$ uname -a
Linux kimchi 6.8.0-41-generic #41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 23:26:06
 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
 
$ ./build/uv_run_tests_a platform_output platform_output
...
uv_getrusage_thread:
  user: 0 sec 4071 microsec
  system: 0 sec 47834 microsec
  page faults: 0
  maximum resident set size: 2304 
$ uname -a
FreeBSD 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14/2-n239506-c8918d6c7412 GENERIC arm64
 
$ ./build/uv_run_tests_a platform_output platform_output
...
uv_getrusage_thread:
  user: 0 sec 0 microsec
  system: 0 sec 2654 microsec
  page faults: 0
  maximum resident set size: 0 
$ uname -a
Darwin Juans-MacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 18:56:34 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6020 arm64

$ ./build/uv_run_tests_a platform_output platform_output
...
uv_getrusage_thread:
  user: 0 sec 22114 microsec
  system: 0 sec 117326 microsec
  page faults: 0
  maximum resident set size: 0

src/unix/core.c Outdated Show resolved Hide resolved
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.

I believe it's possible to get the relevant info out of xnu with proc_pidinfo(PROC_PIDTHREADID64INFO) and I think (but am not 100% sure) you can obtain the thread id with pthread_threadid_np().

(I wrote some code to that effect years ago but I don't have macOS at hand to test on.)

src/unix/core.c Outdated Show resolved Hide resolved
src/win/util.c Outdated Show resolved Hide resolved
@juanarbol juanarbol force-pushed the juan-james/getrusage branch from 535f95f to 83c222f Compare January 9, 2025 18:46
@juanarbol
Copy link
Contributor Author

This new revision address all your comments and adds support for macOS.

src/unix/core.c Outdated Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
src/win/util.c Show resolved Hide resolved
src/win/util.c Outdated Show resolved Hide resolved
src/unix/core.c Outdated Show resolved Hide resolved
@juanarbol juanarbol force-pushed the juan-james/getrusage branch 2 times, most recently from 1f1b9f1 to b0fcbaf Compare January 9, 2025 19:41
Copy link
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

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

Good work!

@juanarbol juanarbol force-pushed the juan-james/getrusage branch from b0fcbaf to 6a6fd0b Compare January 9, 2025 20:24
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 with a suggestion.

src/unix/core.c Outdated Show resolved Hide resolved
Refs: libuv#3119
Co-authored-by: Juan José Arboleda <[email protected]>
Signed-off-by: Juan José Arboleda <[email protected]>
@juanarbol juanarbol force-pushed the juan-james/getrusage branch from 6a6fd0b to db3f686 Compare January 12, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants