< prev index next >

src/share/vm/services/runtimeService.cpp

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"

  27 #include "runtime/vm_version.hpp"
  28 #include "services/attachListener.hpp"
  29 #include "services/management.hpp"
  30 #include "services/runtimeService.hpp"
  31 #include "utilities/dtrace.hpp"
  32 #include "utilities/exceptions.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 #if INCLUDE_MANAGEMENT
  36 TimeStamp RuntimeService::_app_timer;
  37 TimeStamp RuntimeService::_safepoint_timer;
  38 PerfCounter*  RuntimeService::_sync_time_ticks = NULL;
  39 PerfCounter*  RuntimeService::_total_safepoints = NULL;
  40 PerfCounter*  RuntimeService::_safepoint_time_ticks = NULL;
  41 PerfCounter*  RuntimeService::_application_time_ticks = NULL;
  42 double RuntimeService::_last_safepoint_sync_time_sec = 0.0;
  43 
  44 void RuntimeService::init() {
  45   // Make sure the VM version is initialized
  46   Abstract_VM_Version::initialize();


  72     // The capabilities counter is a binary representation of the VM capabilities in string.
  73     // This string respresentation simplifies the implementation of the client side
  74     // to parse the value.
  75     char capabilities[65];
  76     size_t len = sizeof(capabilities);
  77     memset((void*) capabilities, '0', len);
  78     capabilities[len-1] = '\0';
  79     capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
  80 #if INCLUDE_SERVICES
  81     capabilities[1] = '1';
  82 #endif // INCLUDE_SERVICES
  83     PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
  84                                             capabilities, CHECK);
  85   }
  86 }
  87 
  88 void RuntimeService::record_safepoint_begin() {
  89   HS_PRIVATE_SAFEPOINT_BEGIN();
  90 
  91   // Print the time interval in which the app was executing
  92   if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) {
  93     gclog_or_tty->date_stamp(PrintGCDateStamps);
  94     gclog_or_tty->stamp(PrintGCTimeStamps);
  95     gclog_or_tty->print_cr("Application time: %3.7f seconds",
  96                                 last_application_time_sec());
  97   }
  98 
  99   // update the time stamp to begin recording safepoint time
 100   _safepoint_timer.update();
 101   _last_safepoint_sync_time_sec = 0.0;
 102   if (UsePerfData) {
 103     _total_safepoints->inc();
 104     if (_app_timer.is_updated()) {
 105       _application_time_ticks->inc(_app_timer.ticks_since_update());
 106     }
 107   }
 108 }
 109 
 110 void RuntimeService::record_safepoint_synchronized() {
 111   if (UsePerfData) {
 112     _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
 113   }
 114   if (PrintGCApplicationStoppedTime) {
 115     _last_safepoint_sync_time_sec = last_safepoint_time_sec();
 116   }
 117 }
 118 
 119 void RuntimeService::record_safepoint_end() {
 120   HS_PRIVATE_SAFEPOINT_END();
 121 
 122   // Print the time interval for which the app was stopped
 123   // during the current safepoint operation.
 124   if (PrintGCApplicationStoppedTime) {
 125     gclog_or_tty->date_stamp(PrintGCDateStamps);
 126     gclog_or_tty->stamp(PrintGCTimeStamps);
 127     gclog_or_tty->print_cr("Total time for which application threads "
 128                            "were stopped: %3.7f seconds, "
 129                            "Stopping threads took: %3.7f seconds",
 130                            last_safepoint_time_sec(),
 131                            _last_safepoint_sync_time_sec);
 132   }
 133 
 134   // update the time stamp to begin recording app time
 135   _app_timer.update();
 136   if (UsePerfData) {
 137     _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
 138   }
 139 }
 140 
 141 void RuntimeService::record_application_start() {
 142   // update the time stamp to begin recording app time
 143   _app_timer.update();
 144 }
 145 
 146 // Don't need to record application end because we currently
 147 // exit at a safepoint and record_safepoint_begin() handles updating
 148 // the application time counter at VM exit.
 149 
 150 jlong RuntimeService::safepoint_sync_time_ms() {
 151   return UsePerfData ?
 152     Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "logging/log.hpp"
  28 #include "runtime/vm_version.hpp"
  29 #include "services/attachListener.hpp"
  30 #include "services/management.hpp"
  31 #include "services/runtimeService.hpp"
  32 #include "utilities/dtrace.hpp"
  33 #include "utilities/exceptions.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 #if INCLUDE_MANAGEMENT
  37 TimeStamp RuntimeService::_app_timer;
  38 TimeStamp RuntimeService::_safepoint_timer;
  39 PerfCounter*  RuntimeService::_sync_time_ticks = NULL;
  40 PerfCounter*  RuntimeService::_total_safepoints = NULL;
  41 PerfCounter*  RuntimeService::_safepoint_time_ticks = NULL;
  42 PerfCounter*  RuntimeService::_application_time_ticks = NULL;
  43 double RuntimeService::_last_safepoint_sync_time_sec = 0.0;
  44 
  45 void RuntimeService::init() {
  46   // Make sure the VM version is initialized
  47   Abstract_VM_Version::initialize();


  73     // The capabilities counter is a binary representation of the VM capabilities in string.
  74     // This string respresentation simplifies the implementation of the client side
  75     // to parse the value.
  76     char capabilities[65];
  77     size_t len = sizeof(capabilities);
  78     memset((void*) capabilities, '0', len);
  79     capabilities[len-1] = '\0';
  80     capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
  81 #if INCLUDE_SERVICES
  82     capabilities[1] = '1';
  83 #endif // INCLUDE_SERVICES
  84     PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
  85                                             capabilities, CHECK);
  86   }
  87 }
  88 
  89 void RuntimeService::record_safepoint_begin() {
  90   HS_PRIVATE_SAFEPOINT_BEGIN();
  91 
  92   // Print the time interval in which the app was executing
  93   if (_app_timer.is_updated()) {
  94     log_info(safepoint)("Application time: %3.7f seconds", last_application_time_sec());



  95   }
  96 
  97   // update the time stamp to begin recording safepoint time
  98   _safepoint_timer.update();
  99   _last_safepoint_sync_time_sec = 0.0;
 100   if (UsePerfData) {
 101     _total_safepoints->inc();
 102     if (_app_timer.is_updated()) {
 103       _application_time_ticks->inc(_app_timer.ticks_since_update());
 104     }
 105   }
 106 }
 107 
 108 void RuntimeService::record_safepoint_synchronized() {
 109   if (UsePerfData) {
 110     _sync_time_ticks->inc(_safepoint_timer.ticks_since_update());
 111   }
 112   if (log_is_enabled(Info, safepoint)) {
 113     _last_safepoint_sync_time_sec = last_safepoint_time_sec();
 114   }
 115 }
 116 
 117 void RuntimeService::record_safepoint_end() {
 118   HS_PRIVATE_SAFEPOINT_END();
 119 
 120   // Print the time interval for which the app was stopped
 121   // during the current safepoint operation.
 122   log_info(safepoint)("Total time for which application threads were stopped: %3.7f seconds, Stopping threads took: %3.7f seconds",





 123                            last_safepoint_time_sec(),
 124                            _last_safepoint_sync_time_sec);

 125 
 126   // update the time stamp to begin recording app time
 127   _app_timer.update();
 128   if (UsePerfData) {
 129     _safepoint_time_ticks->inc(_safepoint_timer.ticks_since_update());
 130   }
 131 }
 132 
 133 void RuntimeService::record_application_start() {
 134   // update the time stamp to begin recording app time
 135   _app_timer.update();
 136 }
 137 
 138 // Don't need to record application end because we currently
 139 // exit at a safepoint and record_safepoint_begin() handles updating
 140 // the application time counter at VM exit.
 141 
 142 jlong RuntimeService::safepoint_sync_time_ms() {
 143   return UsePerfData ?
 144     Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
< prev index next >