src/hotspot/share/services/runtimeService.cpp
author rehn
Fri, 22 Feb 2019 14:20:06 +0100
changeset 53895 b22d8ae270a2
parent 53775 5d20b085d893
permissions -rw-r--r--
8219436: Safepoint logs correction and misc Reviewed-by: mdoerr, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53775
5d20b085d893 8203469: Faster safepoints
rehn
parents: 52148
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4901
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4901
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4901
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "classfile/classLoader.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33959
diff changeset
    27
#include "logging/log.hpp"
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    28
#include "logging/logStream.hpp"
29201
fee2bbb2ec1d 8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents: 27462
diff changeset
    29
#include "runtime/vm_version.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "services/attachListener.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "services/management.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "services/runtimeService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "utilities/dtrace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "utilities/exceptions.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13975
diff changeset
    35
#include "utilities/macros.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 10739
diff changeset
    37
#if INCLUDE_MANAGEMENT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
PerfCounter*  RuntimeService::_sync_time_ticks = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
PerfCounter*  RuntimeService::_total_safepoints = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
PerfCounter*  RuntimeService::_safepoint_time_ticks = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
PerfCounter*  RuntimeService::_application_time_ticks = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
void RuntimeService::init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    EXCEPTION_MARK;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _sync_time_ticks =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
              PerfDataManager::create_counter(SUN_RT, "safepointSyncTime",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
                                              PerfData::U_Ticks, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    _total_safepoints =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
              PerfDataManager::create_counter(SUN_RT, "safepoints",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                                              PerfData::U_Events, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _safepoint_time_ticks =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
              PerfDataManager::create_counter(SUN_RT, "safepointTime",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
                                              PerfData::U_Ticks, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    _application_time_ticks =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
              PerfDataManager::create_counter(SUN_RT, "applicationTime",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                                              PerfData::U_Ticks, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    // create performance counters for jvm_version and its capabilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    PerfDataManager::create_constant(SUN_RT, "jvmVersion", PerfData::U_None,
52148
2d9f8845d0ae 7041262: VM_Version should be called instead of Abstract_VM_Version so that overriding works
hseigel
parents: 47216
diff changeset
    66
                                     (jlong) VM_Version::jvm_version(), CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    // The capabilities counter is a binary representation of the VM capabilities in string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    // This string respresentation simplifies the implementation of the client side
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    // to parse the value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    char capabilities[65];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    size_t len = sizeof(capabilities);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    memset((void*) capabilities, '0', len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    capabilities[len-1] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    capabilities[0] = AttachListener::is_attach_supported() ? '1' : '0';
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 10739
diff changeset
    76
#if INCLUDE_SERVICES
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    capabilities[1] = '1';
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 10739
diff changeset
    78
#endif // INCLUDE_SERVICES
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    PerfDataManager::create_string_constant(SUN_RT, "jvmCapabilities",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                                            capabilities, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    84
void RuntimeService::record_safepoint_begin(jlong app_ticks) {
10739
91935236600e 7098194: integrate macosx-port changes
dcubed
parents: 7397
diff changeset
    85
  HS_PRIVATE_SAFEPOINT_BEGIN();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    _total_safepoints->inc();
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    88
    _application_time_ticks->inc(app_ticks);
27462
2fef16b8c70f 8059216: Make PrintGCApplicationStoppedTime print information about stopping threads
vkempik
parents: 23443
diff changeset
    89
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    92
void RuntimeService::record_safepoint_synchronized(jlong sync_ticks) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  if (UsePerfData) {
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    94
    _sync_time_ticks->inc(sync_ticks);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
53895
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    98
void RuntimeService::record_safepoint_end(jlong safepoint_ticks) {
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
    99
  HS_PRIVATE_SAFEPOINT_END();
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
   100
  if (UsePerfData) {
b22d8ae270a2 8219436: Safepoint logs correction and misc
rehn
parents: 53775
diff changeset
   101
    _safepoint_time_ticks->inc(safepoint_ticks);
53775
5d20b085d893 8203469: Faster safepoints
rehn
parents: 52148
diff changeset
   102
  }
5d20b085d893 8203469: Faster safepoints
rehn
parents: 52148
diff changeset
   103
}
5d20b085d893 8203469: Faster safepoints
rehn
parents: 52148
diff changeset
   104
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
jlong RuntimeService::safepoint_sync_time_ms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  return UsePerfData ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    Management::ticks_to_ms(_sync_time_ticks->get_value()) : -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
jlong RuntimeService::safepoint_count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  return UsePerfData ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    _total_safepoints->get_value() : -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
jlong RuntimeService::safepoint_time_ms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return UsePerfData ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    Management::ticks_to_ms(_safepoint_time_ticks->get_value()) : -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
jlong RuntimeService::application_time_ms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  return UsePerfData ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    Management::ticks_to_ms(_application_time_ticks->get_value()) : -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 10739
diff changeset
   124
#endif // INCLUDE_MANAGEMENT