Skip to content

Commit

Permalink
Merge pull request #7078 from dmitripivkine/master
Browse files Browse the repository at this point in the history
Remove incorrect assertions and adjust stall time calculation
  • Loading branch information
babsingh authored Jul 28, 2023
2 parents e5dabb6 + 7dbcda3 commit f95ba19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 0 additions & 2 deletions gc/base/standard/ParallelScavengeTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ MM_ParallelScavengeTask::synchronizeGCThreadsAndReleaseMain(MM_EnvironmentBase *
}

/* _syncCriticalSectionDuration must be set now, this thread's stall time is at least the duration of critical section */
Assert_MM_true((endTime - startTime) >= _syncCriticalSectionDuration);
env->_scavengerStats.addToSyncStallTime(startTime, endTime, _syncCriticalSectionDuration);

return result;
Expand All @@ -117,7 +116,6 @@ MM_ParallelScavengeTask::synchronizeGCThreadsAndReleaseSingleThread(MM_Environme
}

/* _syncCriticalSectionDuration must be set now, this thread's stall time is at least the duration of critical section */
Assert_MM_true((endTime - startTime) >= _syncCriticalSectionDuration);
env->_scavengerStats.addToSyncStallTime(startTime, endTime, _syncCriticalSectionDuration);

return result;
Expand Down
16 changes: 14 additions & 2 deletions gc/stats/ScavengerStats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,21 @@ class MM_ScavengerStats
MMINLINE void
addToSyncStallTime(uint64_t startTime, uint64_t endTime, uint64_t criticalSectionDuration = 0)
{
uint64_t criticalTime = criticalSectionDuration;
uint64_t deltaTime = endTime - startTime;

/*
* criticalSectionDuration and deltaTime can be measured on clocks running on different cores asynchronously.
* It means for close intervals (despite clocks are monotonic) criticalTime can be measured
* slightly larger than deltaTime. So, criticalSectionDuration should be adjusted in this case.
*/
if (criticalTime > deltaTime) {
criticalTime = deltaTime;
}

_syncStallCount += 1;
_syncStallTime += (endTime - startTime);
_adjustedSyncStallTime += ((endTime - startTime) - criticalSectionDuration);
_syncStallTime += deltaTime;
_adjustedSyncStallTime += (deltaTime - criticalTime);
}

MMINLINE void
Expand Down

0 comments on commit f95ba19

Please sign in to comment.