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

Add JFR CPULoad and ThreadCPU event support #20186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thallium
Copy link
Contributor

@thallium thallium commented Sep 18, 2024

Depends on: eclipse/omr#7491

@thallium
Copy link
Contributor Author

@tajila requesting your review

@tajila
Copy link
Contributor

tajila commented Oct 4, 2024

Im seeing negative numbers for Thread user mode CPU load

runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
@thallium thallium force-pushed the cpuload branch 2 times, most recently from 9399d91 to 9f17f2e Compare October 7, 2024 18:37
@thallium thallium force-pushed the cpuload branch 3 times, most recently from 42e1d9d to 94218be Compare October 8, 2024 22:21
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
thallium added a commit to thallium/omr that referenced this pull request Oct 10, 2024
This function returns the user and system cpu time of the calling
thread.
Related: eclipse-openj9/openj9#20186

Signed-off-by: Gengchen Tuo <[email protected]>
@thallium
Copy link
Contributor Author

Opend OMR PR and addressed previous state.

thallium added a commit to thallium/omr that referenced this pull request Oct 10, 2024
This function returns the user and system cpu time of the calling
thread.
Related: eclipse-openj9/openj9#20186

Signed-off-by: Gengchen Tuo <[email protected]>
thallium added a commit to thallium/omr that referenced this pull request Oct 11, 2024
This function returns the user and system cpu time of the calling
thread.
Related: eclipse-openj9/openj9#20186

Signed-off-by: Gengchen Tuo <[email protected]>
thallium added a commit to thallium/omr that referenced this pull request Oct 11, 2024
This function returns the user and system cpu time of the calling
thread.
Related: eclipse-openj9/openj9#20186

Signed-off-by: Gengchen Tuo <[email protected]>
runtime/vm/jfr.cpp Outdated Show resolved Hide resolved
Comment on lines 848 to 851
if (count % 100 == 0) { // 1000ms
jfrCPULoad(currentThread);
}
if (count % 1000 == 0) { // 10s
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing parentheses, constants go on the left of ==:

			if (0 == (count % 100)) { // 1000ms

By the way, how do you conclude that 100 counts is 1000ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

J9JFR_SAMPLING_RATE is defined to be 10 so 100 counts is 1000ms

thallium added a commit to thallium/omr that referenced this pull request Oct 11, 2024
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 added a commit to thallium/omr that referenced this pull request Oct 11, 2024
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 added a commit to thallium/omr that referenced this pull request Oct 11, 2024
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 added a commit to thallium/omr that referenced this pull request Oct 11, 2024
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]>
if (NULL != jfrEvent) {
initializeEventFields(currentThread, (J9JFREvent *)jfrEvent, J9JFR_EVENT_TYPE_CPU_LOAD);
UDATA numberOfCpus = j9sysinfo_get_number_CPUs_by_type(J9PORT_CPU_ONLINE);
U_64 currentTime = (U_64)j9time_nano_time();
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not mix types: it should use int64_t as declared by OMR. Related locals should use int64_t instead of I_64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you suggest changing prevProcTimestamp fields to int64_t as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, they should use the same type as the source (int64_t omrtime_nano_time()).

thallium added a commit to thallium/omr that referenced this pull request Oct 11, 2024
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]>
Comment on lines +300 to +303
if (_isLE) {
newVal = byteSwap(newVal);
}
writeData((U_8 *)&newVal, 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest this be simplified to:

		writeU32(newVal);

@@ -5640,6 +5662,9 @@ typedef struct JFRState {
void *constantEvents;
BOOLEAN isConstantEventsInitialized;
omrthread_monitor_t isConstantEventsInitializedMutex;
J9SysinfoCPUTime prevSysCPUTime;
omrthread_process_time_t prevProcCPUTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest this field be named prevProcCPUTimes consistent with its source omrthread_get_process_times().

if (0 == (count % 1000)) { // 10s
J9SignalAsyncEvent(vm, NULL, vm->jfrThreadCPULoadAsyncKey);
}
count++;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use +=:

			count += 1;

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.

3 participants