Skip to content

Add information regarding synchronous compilations in javacore#24236

Open
dev-koan wants to merge 4 commits into
eclipse-openj9:masterfrom
dev-koan:feature/SyncCompInfo
Open

Add information regarding synchronous compilations in javacore#24236
dev-koan wants to merge 4 commits into
eclipse-openj9:masterfrom
dev-koan:feature/SyncCompInfo

Conversation

@dev-koan

@dev-koan dev-koan commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Added a struct in J9JITConfig to store information regarding synchronous compilations and print them in javacore file.

image

Signed-off-by: Dev Agarwal dev.agarwal@ibm.com

@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch 3 times, most recently from fbec998 to 2d33ba0 Compare July 2, 2026 14:00
@mpirvu mpirvu self-assigned this Jul 2, 2026

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have one decision to make: do we want to measure the times needed for synchronous compilations to be performed or the waiting time of application threads? there could be several application threads waiting for the same compilation to finish.

Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/rossa.cpp Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch 2 times, most recently from 43f338e to 177844e Compare July 3, 2026 19:21
@dev-koan
dev-koan requested a review from mpirvu July 3, 2026 19:22
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 543fdd6 to 0825011 Compare July 6, 2026 17:23
@dev-koan
dev-koan requested a review from mpirvu July 6, 2026 17:26
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 0825011 to 3ffce49 Compare July 6, 2026 17:46
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
@dev-koan
dev-koan requested a review from mpirvu July 6, 2026 18:59

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Please post an example of the output.

@mpirvu

mpirvu commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Also, please squash the 4 commits into 1.

@dev-koan

dev-koan commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

LGTM. Please post an example of the output.

image

@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 3ffce49 to 75bbae1 Compare July 6, 2026 19:18
@dev-koan
dev-koan marked this pull request as ready for review July 6, 2026 19:19
@amicic amicic added the comp:ras label Jul 8, 2026
@amicic

amicic commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

We have one decision to make: do we want to measure the times needed for synchronous compilations to be performed or the waiting time of application threads? there could be several application threads waiting for the same compilation to finish.

Ideally, i'd like to see each app thread maintain its own longest wait time (and associated info). For brevity, only threads that have wait times longer than a certain threshold (like 3ms or 10ms) should be reported it to javacore.

@mpirvu

mpirvu commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

If each thread maintains the name of the sync method, with long method names and many threads there could be some footprint increase. I like the idea of applying some filtering and not include quick compilations.

@mpirvu

mpirvu commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@amicic To clarify: each app thread that is subject to a wait due to a synchronous compilation will have a dynamically allocated string in J9VMThread struct (to hold the name of the method it waited for). This string needs to be freed when the thread is destroyed.
Caveat: if the thread gets destroyed before the javacore generation happen, the wait info will be lost.

@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 75bbae1 to 286bba4 Compare July 14, 2026 15:42
@dev-koan
dev-koan requested a review from dsouzai as a code owner July 14, 2026 15:42
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch 2 times, most recently from ee2ee8c to 1ca1fb1 Compare July 14, 2026 15:48
@dev-koan
dev-koan requested a review from mpirvu July 14, 2026 15:51

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Please post an example of the output in the description of this PR.

Comment thread runtime/oti/j9nonbuilder.h Outdated
typedef struct J9JITSyncCompilationStatistics {
uint32_t totalCount;
uint64_t totalWaitTime; // microseconds (us)
J9JITLongestSyncComp longestWaitMethods[J9_LONGEST_SYNC_COMP];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment showing how this array is sorted.

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.

Updated.

@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 1ca1fb1 to a65babe Compare July 20, 2026 20:52
@mpirvu
mpirvu requested review from amicic and removed request for dsouzai July 21, 2026 18:03
@mpirvu

mpirvu commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@amicic If you approve it, I am going to start testing and merge. Thanks

Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
_OutputStream.writeCharacters("2nd Longest");
}
else {
_OutputStream.writeCharacters("3rd Longest");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not quite the most robust (in case J9_LONGEST_SYNC_COMP increases a bit). you could simplify and just print numbers 1. longest, 2. longest

Just an observation. If you still prefer this way, i'm fine with it.

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.

Updated this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formatting: } else ....

@keithc-ca
keithc-ca self-requested a review July 21, 2026 19:28
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from a65babe to 97d5371 Compare July 21, 2026 19:28
Comment thread runtime/oti/j9nonbuilder.h Outdated
Added a struct in J9JITConfig to store information regarding
synchronous compilations and print them in javacore file.

Signed-off-by: Dev Agarwal <dev.agarwal@ibm.com>
@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 97d5371 to 88e217d Compare July 21, 2026 19:53
@dev-koan
dev-koan requested a review from keithc-ca July 21, 2026 19:55
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
Comment on lines +2978 to +2979
for (int i = 0; i < J9_LONGEST_SYNC_COMP; i++) {
stats->longestWaitMethods[i].waitTime = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems racy: other threads may be active.

@keithc-ca

Copy link
Copy Markdown
Contributor

Please post an example of the output in the description

Can we have a text version of that sample (as opposed to an image)?

Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
@dev-koan

Copy link
Copy Markdown
Contributor Author

Please post an example of the output in the description

Can we have a text version of that sample (as opposed to an image)?

NULL           ------------------------------------------------------------------------
0SECTION       Synchronous compilations info dump routine
NULL           ==============================
1NOTE          This data is reset after each javacore file is written
NULL           ------------------------------------------------------------------------
1JITSYNCSTATS  Synchronous Compilation Statistics
NULL           ------------------------------------------------------------------------
2JITSYNCCOUNT  Total synchronous compilations: 793
2JITTOTALWAIT  Total application wait time: 1239420us
2JITLONGEST    1. Longest Synchronous Compilation
3JITWAITTIME   Wait time: 29445us
3JITENDTIME    Wait time end: 2026-07-23T14:52:20.902
3JITMETHOD     Method: jdk/internal/classfile/impl/StackMapGenerator.processBlock(Ljdk/internal/classfile/impl/RawBytecodeHelper;)Z
3JITTHREAD     Thread: (unnamed thread)
2JITLONGEST    2. Longest Synchronous Compilation
3JITWAITTIME   Wait time: 18123us
3JITENDTIME    Wait time end: 2026-07-23T14:52:22.000
3JITMETHOD     Method: java/lang/Class.getEnumConstantsShared()[Ljava/lang/Object;
3JITTHREAD     Thread: main
2JITLONGEST    3. Longest Synchronous Compilation
3JITWAITTIME   Wait time: 18063us
3JITENDTIME    Wait time end: 2026-07-23T14:52:22.018
3JITMETHOD     Method: java/lang/Access.getEnumConstantsShared(Ljava/lang/Class;)[Ljava/lang/Enum;
3JITTHREAD     Thread: main

@dev-koan
dev-koan force-pushed the feature/SyncCompInfo branch from 2376107 to 5052e90 Compare July 23, 2026 19:05
Comment thread runtime/compiler/control/CompilationThread.cpp Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
Comment thread runtime/oti/j9nonbuilder.h Outdated
IDATA verboseOutputLevel;
omrthread_monitor_t compilationMonitor;
void* compilationInfo;
J9JITSyncCompilationStatistics *syncCompStats;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why need this be indirect? Why not:

	J9JITSyncCompilationStatistics syncCompStats;

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.

It is simpler to use a pointer here to make sure the same memory is being accessed everywhere (in compilationthread class and javadump class)
I can also use a reference (&) to syncCompStats in javadump and compilationthread if that is preferred.

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.

Updated.

Comment thread runtime/rasdump/javadump.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated
Comment thread runtime/rasdump/javadump.cpp Outdated

struct CompilationStatistics _stats;
struct CompilationStatsPerInterval _intervalStats;
SyncCompilationStatistics _syncCompStats;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should instead live in J9JITConfig.

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.

Updated.

* Assisted-by: IBM Bob
*******************************************************************************/

#include <cstdint>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is necessary.

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.

Updated.

_syncCompStats.totalWaitTime += duration;

/* Obtain index to insert. */
int idx = -1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should use the same type as i.

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.

Updated.

Comment thread runtime/oti/j9nonbuilder.h Outdated
typedef struct J9JITSyncCompilationStatistics {
uint32_t totalCount;
uint64_t totalWaitTime; /* microseconds */
J9JITLongestSyncComp longestWaitMethods[J9_NUM_LONGEST_SYNC_COMP]; /* sorted in increasing order */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you mean "decreasing" (the first entry has the longest wait time).

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.

Updated.

Comment thread runtime/rasdump/javadump.cpp Outdated
*******************************************************************************/

/* Includes */
#include <cstdint>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is necessary.

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.

Updated.

Comment thread runtime/rasdump/javadump.cpp Outdated
_OutputStream.writeCharacters("2JITTOTALWAIT Total application wait time: ");
_OutputStream.writeInteger64(stats->totalWaitTime, "%llu");
_OutputStream.writeCharacters("us\n");
for (int32_t i = 0; i < J9_NUM_LONGEST_SYNC_COMP; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest using UDATA instead of int32_t, in part so the format on line 2953 is correct, and for consistency with other loops in this file.

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.

Updated.

Comment thread runtime/rasdump/javadump.cpp Outdated

_OutputStream.writeCharacters("3JITENDTIME Wait time end: ");
omrstr_ftime_ex(timeStamp, _MaximumTimeStampLength, "%Y-%m-%dT%H:%M:%S",
longestWaitMethod.waitTimeEnd, OMRSTR_FTIME_FLAG_LOCAL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excessive indentation: Two tabs more than line 2961 is sufficient.

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.

Updated.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants