# HG changeset patch # User rehn # Date 1551867316 -3600 # Node ID 13acb433989549d83c6d50223a1751857f2c6fbc # Parent 8b341d6728fe1fea4de95bdcb2ea11702d793311 8220151: SafepointTracing::end_of_last_safepoint_ms should return ms since epoch. Reviewed-by: dholmes, redestad diff -r 8b341d6728fe -r 13acb4339895 src/hotspot/share/runtime/safepoint.cpp --- a/src/hotspot/share/runtime/safepoint.cpp Thu Feb 28 09:43:23 2019 +0800 +++ b/src/hotspot/share/runtime/safepoint.cpp Wed Mar 06 11:15:16 2019 +0100 @@ -1121,6 +1121,7 @@ jlong SafepointTracing::_last_safepoint_sync_time_ns = 0; jlong SafepointTracing::_last_safepoint_cleanup_time_ns = 0; jlong SafepointTracing::_last_safepoint_end_time_ns = 0; +jlong SafepointTracing::_last_safepoint_end_time_epoch_ms = 0; jlong SafepointTracing::_last_app_time_ns = 0; int SafepointTracing::_nof_threads = 0; int SafepointTracing::_nof_running = 0; @@ -1133,6 +1134,8 @@ void SafepointTracing::init() { // Application start _last_safepoint_end_time_ns = os::javaTimeNanos(); + // amount of time since epoch + _last_safepoint_end_time_epoch_ms = os::javaTimeMillis(); } // Helper method to print the header. @@ -1232,6 +1235,8 @@ void SafepointTracing::end() { _last_safepoint_end_time_ns = os::javaTimeNanos(); + // amount of time since epoch + _last_safepoint_end_time_epoch_ms = os::javaTimeMillis(); if (_max_sync_time < (_last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns)) { _max_sync_time = _last_safepoint_sync_time_ns - _last_safepoint_begin_time_ns; diff -r 8b341d6728fe -r 13acb4339895 src/hotspot/share/runtime/safepoint.hpp --- a/src/hotspot/share/runtime/safepoint.hpp Thu Feb 28 09:43:23 2019 +0800 +++ b/src/hotspot/share/runtime/safepoint.hpp Wed Mar 06 11:15:16 2019 +0100 @@ -240,6 +240,8 @@ static jlong _last_safepoint_sync_time_ns; static jlong _last_safepoint_cleanup_time_ns; static jlong _last_safepoint_end_time_ns; + // amount of ms since epoch + static jlong _last_safepoint_end_time_epoch_ms; // Relative static jlong _last_app_time_ns; @@ -268,8 +270,8 @@ return (os::javaTimeNanos() - _last_safepoint_end_time_ns) / (NANOUNITS / MILLIUNITS); } - static jlong end_of_last_safepoint_ms() { - return _last_safepoint_end_time_ns / (NANOUNITS / MILLIUNITS); + static jlong end_of_last_safepoint_epoch_ms() { + return _last_safepoint_end_time_epoch_ms; } static jlong start_of_safepoint() { diff -r 8b341d6728fe -r 13acb4339895 src/hotspot/share/runtime/tieredThresholdPolicy.cpp --- a/src/hotspot/share/runtime/tieredThresholdPolicy.cpp Thu Feb 28 09:43:23 2019 +0800 +++ b/src/hotspot/share/runtime/tieredThresholdPolicy.cpp Wed Mar 06 11:15:16 2019 +0100 @@ -479,7 +479,7 @@ // We don't update the rate if we've just came out of a safepoint. // delta_s is the time since last safepoint in milliseconds. - jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms(); + jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms(); jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement // How many events were there since the last time? int event_count = m->invocation_count() + m->backedge_count(); @@ -504,7 +504,7 @@ // Check if this method has been stale from a given number of milliseconds. // See select_task(). bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { - jlong delta_s = t - SafepointTracing::end_of_last_safepoint_ms(); + jlong delta_s = t - SafepointTracing::end_of_last_safepoint_epoch_ms(); jlong delta_t = t - m->prev_time(); if (delta_t > timeout && delta_s > timeout) { int event_count = m->invocation_count() + m->backedge_count();