1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 #ifndef SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP
26 #define SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP
27
28 #include "utilities/globalDefinitions.hpp"
29 #include "utilities/debug.hpp"
30
31 // Used to track time from the end of initial mark to the first mixed GC.
32 // After calling the initial mark/mixed gc notifications, the result can be
33 // obtained in last_marking_time() once, after which the tracking resets.
34 // Any pauses recorded by add_pause() will be subtracted from that results.
35 class G1InitialMarkToMixedTimeTracker {
36 private:
37 bool _active;
38 double _initial_mark_end_time;
39 double _mixed_start_time;
40 double _total_pause_time;
41
42 double wall_time() const {
43 return _mixed_start_time - _initial_mark_end_time;
44 }
45 public:
46 G1InitialMarkToMixedTimeTracker() { reset(); }
47
48 // Record initial mark pause end, starting the time tracking.
49 void record_initial_mark_end(double end_time) {
50 assert(!_active, "Initial mark out of order.");
51 _initial_mark_end_time = end_time;
52 _active = true;
53 }
54
55 // Record the first mixed gc pause start, ending the time tracking.
56 void record_mixed_gc_start(double start_time) {
57 if (_active) {
58 _mixed_start_time = start_time;
59 _active = false;
60 }
61 }
62
63 double last_marking_time() {
64 assert(has_result(), "Do not have all measurements yet.");
65 double result = (_mixed_start_time - _initial_mark_end_time) - _total_pause_time;
66 reset();
67 return result;
68 }
69
70 void reset() {
71 _active = false;
72 _total_pause_time = 0.0;
73 _initial_mark_end_time = -1.0;
74 _mixed_start_time = -1.0;
75 }
76
77 void add_pause(double time) {
78 if (_active) {
79 _total_pause_time += time;
80 }
81 }
82
83 // Returns whether we have a result that can be retrieved.
84 bool has_result() const { return _mixed_start_time > 0.0 && _initial_mark_end_time > 0.0; }
85 };
86
87 #endif // SHARE_GC_G1_G1INITIALMARKTOMIXEDTIMETRACKER_HPP
|
1 /*
2 * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 #ifndef SHARE_GC_G1_G1CONCURRENTSTARTTOMIXEDTIMETRACKER_HPP
26 #define SHARE_GC_G1_G1CONCURRENTSTARTTOMIXEDTIMETRACKER_HPP
27
28 #include "utilities/debug.hpp"
29 #include "utilities/globalDefinitions.hpp"
30
31 // Used to track time from the end of concurrent start to the first mixed GC.
32 // After calling the concurrent start/mixed gc notifications, the result can be
33 // obtained in last_marking_time() once, after which the tracking resets.
34 // Any pauses recorded by add_pause() will be subtracted from that results.
35 class G1ConcurrentStartToMixedTimeTracker {
36 private:
37 bool _active;
38 double _concurrent_start_end_time;
39 double _mixed_start_time;
40 double _total_pause_time;
41
42 double wall_time() const {
43 return _mixed_start_time - _concurrent_start_end_time;
44 }
45 public:
46 G1ConcurrentStartToMixedTimeTracker() { reset(); }
47
48 // Record concurrent start pause end, starting the time tracking.
49 void record_concurrent_start_end(double end_time) {
50 assert(!_active, "Concurrent start out of order.");
51 _concurrent_start_end_time = end_time;
52 _active = true;
53 }
54
55 // Record the first mixed gc pause start, ending the time tracking.
56 void record_mixed_gc_start(double start_time) {
57 if (_active) {
58 _mixed_start_time = start_time;
59 _active = false;
60 }
61 }
62
63 double last_marking_time() {
64 assert(has_result(), "Do not have all measurements yet.");
65 double result = (_mixed_start_time - _concurrent_start_end_time) - _total_pause_time;
66 reset();
67 return result;
68 }
69
70 void reset() {
71 _active = false;
72 _total_pause_time = 0.0;
73 _concurrent_start_end_time = -1.0;
74 _mixed_start_time = -1.0;
75 }
76
77 void add_pause(double time) {
78 if (_active) {
79 _total_pause_time += time;
80 }
81 }
82
83 // Returns whether we have a result that can be retrieved.
84 bool has_result() const { return _mixed_start_time > 0.0 && _concurrent_start_end_time > 0.0; }
85 };
86
87 #endif // SHARE_GC_G1_G1CONCURRENTSTARTTOMIXEDTIMETRACKER_HPP
|