src/hotspot/share/gc/g1/g1InitialMarkToMixedTimeTracker.hpp
author tschatzl
Wed, 17 Jul 2019 16:33:19 +0200
changeset 55722 5ee183a90e65
parent 53244 9807daeb47c4
permissions -rw-r--r--
8227084: Add timing information for merge heap root preparation Reviewed-by: sangheki, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     4
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     8
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    14
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    18
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    21
 * questions.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    22
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    23
 */
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    25
#ifndef SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    26
#define SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    27
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    29
#include "utilities/debug.hpp"
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    30
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    31
// Used to track time from the end of initial mark to the first mixed GC.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    32
// After calling the initial mark/mixed gc notifications, the result can be
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    33
// obtained in last_marking_time() once, after which the tracking resets.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    34
// Any pauses recorded by add_pause() will be subtracted from that results.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
    35
class G1InitialMarkToMixedTimeTracker {
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    36
private:
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    37
  bool _active;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    38
  double _initial_mark_end_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    39
  double _mixed_start_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    40
  double _total_pause_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    41
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    42
  double wall_time() const {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    43
    return _mixed_start_time - _initial_mark_end_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    44
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    45
public:
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    46
  G1InitialMarkToMixedTimeTracker() { reset(); }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    47
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    48
  // Record initial mark pause end, starting the time tracking.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    49
  void record_initial_mark_end(double end_time) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    50
    assert(!_active, "Initial mark out of order.");
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    51
    _initial_mark_end_time = end_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    52
    _active = true;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    53
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    54
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    55
  // Record the first mixed gc pause start, ending the time tracking.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    56
  void record_mixed_gc_start(double start_time) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    57
    if (_active) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    58
      _mixed_start_time = start_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    59
      _active = false;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    60
    }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    61
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    62
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    63
  double last_marking_time() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    64
    assert(has_result(), "Do not have all measurements yet.");
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    65
    double result = (_mixed_start_time - _initial_mark_end_time) - _total_pause_time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    66
    reset();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    67
    return result;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    68
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    69
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    70
  void reset() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    71
    _active = false;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    72
    _total_pause_time = 0.0;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    73
    _initial_mark_end_time = -1.0;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    74
    _mixed_start_time = -1.0;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    75
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    76
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    77
  void add_pause(double time) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    78
    if (_active) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    79
      _total_pause_time += time;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    80
    }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    81
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    82
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    83
  // Returns whether we have a result that can be retrieved.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    84
  bool has_result() const { return _mixed_start_time > 0.0 && _initial_mark_end_time > 0.0; }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    85
};
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    86
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    87
#endif // SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP