src/hotspot/share/services/runtimeService.cpp
changeset 53895 b22d8ae270a2
parent 53775 5d20b085d893
--- a/src/hotspot/share/services/runtimeService.cpp	Thu Feb 21 14:24:44 2019 +0100
+++ b/src/hotspot/share/services/runtimeService.cpp	Fri Feb 22 14:20:06 2019 +0100
@@ -25,7 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/classLoader.hpp"
 #include "logging/log.hpp"
-#include "runtime/timer.hpp"
+#include "logging/logStream.hpp"
 #include "runtime/vm_version.hpp"
 #include "services/attachListener.hpp"
 #include "services/management.hpp"
@@ -35,18 +35,12 @@
 #include "utilities/macros.hpp"
 
 #if INCLUDE_MANAGEMENT
-TimeStamp RuntimeService::_app_timer;
-TimeStamp RuntimeService::_safepoint_timer;
 PerfCounter*  RuntimeService::_sync_time_ticks = NULL;
 PerfCounter*  RuntimeService::_total_safepoints = NULL;
 PerfCounter*  RuntimeService::_safepoint_time_ticks = NULL;
 PerfCounter*  RuntimeService::_application_time_ticks = NULL;
-jlong RuntimeService::_last_safepoint_sync_time_ns = 0;
-jlong RuntimeService::_last_safepoint_end_time_ns = 0;
-jlong RuntimeService::_last_app_time_ns = 0;
 
 void RuntimeService::init() {
-
   if (UsePerfData) {
     EXCEPTION_MARK;
 
@@ -87,85 +81,27 @@
   }
 }
 
-void RuntimeService::record_safepoint_begin() {
+void RuntimeService::record_safepoint_begin(jlong app_ticks) {
   HS_PRIVATE_SAFEPOINT_BEGIN();
-
-  // Print the time interval in which the app was executing
-  if (_app_timer.is_updated()) {
-    _last_app_time_ns = _app_timer.ticks_since_update();
-    log_info(safepoint)("Application time: %3.7f seconds", TimeHelper::counter_to_seconds(_last_app_time_ns));
-  }
-
-  // update the time stamp to begin recording safepoint time
-  _last_safepoint_sync_time_ns = 0;
-  _last_safepoint_end_time_ns = 0;
-  _safepoint_timer.update();
   if (UsePerfData) {
     _total_safepoints->inc();
-    if (_app_timer.is_updated()) {
-      _application_time_ticks->inc(_app_timer.ticks_since_update());
-    }
-  }
-}
-
-void RuntimeService::record_safepoint_synchronized() {
-  if (UsePerfData) {
-    _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
-  }
-  if (log_is_enabled(Info, safepoint) || log_is_enabled(Info, safepoint, stats)) {
-    _last_safepoint_sync_time_ns = _safepoint_timer.ticks_since_update();
+    _application_time_ticks->inc(app_ticks);
   }
 }
 
-void RuntimeService::record_safepoint_end() {
-  HS_PRIVATE_SAFEPOINT_END();
-
-  // Logging of safepoint+stats=info needs _last_safepoint_end_time_ns to be set.
-  // Logging of safepoint=info needs _last_safepoint_end_time_ns for following log.
-  if (log_is_enabled(Info, safepoint) || log_is_enabled(Info, safepoint, stats)) {
-    _last_safepoint_end_time_ns = _safepoint_timer.ticks_since_update();
-    log_info(safepoint)(
-       "Total time for which application threads were stopped: %3.7f seconds, "
-       "Stopping threads took: %3.7f seconds",
-       TimeHelper::counter_to_seconds(_last_safepoint_end_time_ns),
-       TimeHelper::counter_to_seconds(_last_safepoint_sync_time_ns));
-  }
-
-  // update the time stamp to begin recording app time
-  _app_timer.update();
+void RuntimeService::record_safepoint_synchronized(jlong sync_ticks) {
   if (UsePerfData) {
-    _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
+    _sync_time_ticks->inc(sync_ticks);
   }
 }
 
-void RuntimeService::record_safepoint_epilog(const char* operation_name) {
-  if (!log_is_enabled(Info, safepoint, stats)) {
-    return;
+void RuntimeService::record_safepoint_end(jlong safepoint_ticks) {
+  HS_PRIVATE_SAFEPOINT_END();
+  if (UsePerfData) {
+    _safepoint_time_ticks->inc(safepoint_ticks);
   }
-
-  log_info(safepoint, stats)(
-     "Safepoint \"%s\", "
-     "Time since last: " JLONG_FORMAT " ns; "
-     "Reaching safepoint: " JLONG_FORMAT " ns; "
-     "At safepoint: " JLONG_FORMAT " ns; "
-     "Total: " JLONG_FORMAT " ns",
-      operation_name,
-      _last_app_time_ns,
-      _last_safepoint_sync_time_ns,
-      _last_safepoint_end_time_ns - _last_safepoint_sync_time_ns,
-      _last_safepoint_end_time_ns
-     );
 }
 
-void RuntimeService::record_application_start() {
-  // update the time stamp to begin recording app time
-  _app_timer.update();
-}
-
-// Don't need to record application end because we currently
-// exit at a safepoint and record_safepoint_begin() handles updating
-// the application time counter at VM exit.
-
 jlong RuntimeService::safepoint_sync_time_ms() {
   return UsePerfData ?
     Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;