Skip to content

Commit

Permalink
Use omrtime_hires_clock() for monotonic time when necessary in gc
Browse files Browse the repository at this point in the history
The omrtime_current_time_millis() uses UNIX gettimeofday() function,
and is therefore non-monotonic and error-prone.
We turn to use omrtime_hires_clock() function call
whenever we need the time to be monotonic.

Issue: #7051
  • Loading branch information
kangyining committed Jul 12, 2023
1 parent e10a1e5 commit 76772b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gc/base/standard/Scavenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3288,7 +3288,7 @@ MM_Scavenger::getFreeCache(MM_EnvironmentStandard *env)
if (NULL == cache) {
env->_scavengerStats._scanCacheOverflow = 1;
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
uint64_t duration = omrtime_current_time_millis();
uint64_t duration = omrtime_hires_clock();

bool resizePerformed = false;
omrthread_monitor_enter(_freeCacheMonitor);
Expand All @@ -3305,8 +3305,8 @@ MM_Scavenger::getFreeCache(MM_EnvironmentStandard *env)
/* Still need a new cache and nothing left reserved - create it in Heap */
cache = createCacheInHeap(env);
}
duration = omrtime_current_time_millis() - duration;
env->_scavengerStats._scanCacheAllocationDurationDuringSavenger += duration;
duration = omrtime_hires_clock() - duration;
env->_scavengerStats._scanCacheAllocationDurationDuringSavenger += omrtime_hires_delta(0, duration, OMRPORT_TIME_DELTA_IN_MILLISECONDS);

}

Expand Down

0 comments on commit 76772b3

Please sign in to comment.