-
Notifications
You must be signed in to change notification settings - Fork 396
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
Add omrthread_get_self_thread_time() #7491
base: master
Are you sure you want to change the base?
Conversation
Depends on: eclipse/omr#7491 Signed-off-by: Gengchen Tuo <[email protected]>
@babsingh Please review |
Minor nit: please fix the spelling of "thread" in your commit and PR titles. Thanks. |
Fixed spelling |
The new function needs to be added similar to the existing functions in In the new function, the output of
|
AFAIK, the only way to get user time reliably on linux is with The goal is to do something like |
7b3ceba
to
52e7090
Compare
@thallium port and thread libraries are standalone. a thread library function shouldn't be added to the port library. see an existing function such as Also, include the justification in the commit on why the new function is needed. |
3777a2a
to
6053ad5
Compare
Moved the function to |
Depends on: eclipse/omr#7491 Signed-off-by: Gengchen Tuo <[email protected]>
Depends on: eclipse/omr#7491 Signed-off-by: Gengchen Tuo <[email protected]>
This function returns the user and system cpu time of the calling thread. This new function is needed because the only way that we're aware of to get the user CPU time of a thread is to use getrusage(RUSAGE_THREAD, ...) which can only be called on the current thread. Related: eclipse-openj9/openj9#20186 Signed-off-by: Gengchen Tuo <[email protected]>
@thallium Also, can you add tests for the new function in |
int64_t userTime = omrthread_get_user_time(self); | ||
int64_t cpuTime = omrthread_get_cpu_time(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given these existing API functions, what's the real value of adding this function?
If we decide to go ahead with this change, this should use omrthread_get_self_cpu_time()
and omrthread_get_self_user_time()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. Yeah, I think the best way is to add Linux implementation to omrthread_get_self_user_time()
so we don't need to add a new function. Then we'll be calling omrthread_get_self_cpu_time()
and omrthread_get_self_user_time()
on the J9 side. @tajila what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to avoid calling getrusage
twice, since we need both cpu and user time. What does the support look like on other platforms, are they separate system calls or can those be bundled as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like on Windows and AIX they can be bundled as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're concerned about making two system calls where one would suffice, I suggest this function should be used by omrthread_get_self_cpu_time()
and omrthread_get_self_user_time()
to reduce code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good idea because on some platforms omrthread_get_self_cpu_time
get CPU time directly rather than by adding user time and system time.
@babsingh how can I add tests for specific platforms? (since |
You can use
|
This function returns the user and system cpu time of the calling thread.
Related: eclipse-openj9/openj9#20186