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

Replace j9time_current_time_millis() with j9time_hires_clock() in gc #17739

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

kangyining
Copy link
Contributor

The j9time_current_time_millis() uses UNIX gettimeofday() function, and is therefore non-monotonic and error-prone.
We turn to use monotonic j9time_hires_clock() function call.

Issue: #17706

@@ -58,7 +58,7 @@ printCardCleaningStats(OMR_VMThread *omrVMThread)
U_64 totalTime = 0;
UDATA totalCardsCleaned = 0;

omrstr_ftime_ex(timestamp, sizeof(timestamp), "%b %d %H:%M:%S %Y", j9time_current_time_millis(), OMRSTR_FTIME_FLAG_LOCAL);
omrstr_ftime_ex(timestamp, sizeof(timestamp), "%b %d %H:%M:%S %Y", j9time_hires_clock(), OMRSTR_FTIME_FLAG_LOCAL);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not the same: j9time_current_time_millis() returns time in milliseconds since January 1st 1970 UTC but j9time_hires_clock() output is read of high-resolution performance counter (ticks).

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can just leave this unchanged, and care only about those that calculate time diff?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is correct. We need to fix only critical ones (like cases where delta time may be calculated). No need to modify places like general day/time reporting.

@kangyining kangyining changed the title Replace j9time_current_time_millis() with j9time_hires_clock() in gc WIP: Replace j9time_current_time_millis() with j9time_hires_clock() in gc Jul 6, 2023
@@ -425,7 +425,7 @@ MM_IncrementalGenerationalGC::globalMarkPhase(MM_EnvironmentVLHGC *env, bool inc

if (incrementalMark) {
reportGMPMarkStart(env);
I_64 endTime = j9time_current_time_millis() + _schedulingDelegate.currentGlobalMarkIncrementTimeMillis(env);
U_64 endTime = j9time_hires_clock() + _schedulingDelegate.currentGlobalMarkIncrementTimeMillis(env)*j9time_hires_frequency()/1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor, formating: keep spaces around binary operators like '*', '/'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@amicic
Copy link
Contributor

amicic commented Jul 7, 2023

looks good. remove WIP and squash the commits

@@ -190,7 +190,7 @@ class MM_ParallelScrubCardTableTask : public MM_ParallelTask
private:
MM_CycleState * const _cycleState; /**< Current cycle state information */
bool _timeLimitWasHit; /**< true if any requests to check the time came in after we had hit our time threshold */
const I_64 _timeThreshold; /**< The millisecond which represents the end of this increment */
const U_64 _timeThreshold; /**< The millisecond which represents the end of this increment */
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this variable stored ticks instead of milliseconds now? If so, comment should be changed. Here and below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

Copy link
Contributor

@amicic amicic Jul 7, 2023

Choose a reason for hiding this comment

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

Does not seem to be fixed yet.

Note, there a few of them to fix. For example, comment above declaration markScan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why they are not there last Friday, but they should be fine now.

@kangyining kangyining force-pushed the issue_17706 branch 2 times, most recently from 6799c2f to 96765c8 Compare July 7, 2023 20:34
@kangyining kangyining changed the title WIP: Replace j9time_current_time_millis() with j9time_hires_clock() in gc Replace j9time_current_time_millis() with j9time_hires_clock() in gc Jul 7, 2023
The j9time_current_time_millis() uses UNIX gettimeofday() function, and is therefore non-monotonic and error-prone.
We turn to use monotonic j9time_hires_clock() function call.

Issue: eclipse-openj9#17706
@amicic
Copy link
Contributor

amicic commented Jul 10, 2023

jenkins test sanity win jdk11

@amicic
Copy link
Contributor

amicic commented Jul 10, 2023

jenkins compile aix jdk17

@amicic amicic merged commit 770dc2a into eclipse-openj9:master Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants