1 /*
2 * Copyright (c) 2001, 2016, 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_VM_GC_G1_CONCURRENTG1REFINE_HPP
26 #define SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP
27
28 #include "memory/allocation.hpp"
29 #include "utilities/globalDefinitions.hpp"
30
31 // Forward decl
32 class CardTableEntryClosure;
33 class ConcurrentG1RefineThread;
34 class G1YoungRemSetSamplingThread;
35 class outputStream;
36 class ThreadClosure;
37
38 class ConcurrentG1Refine: public CHeapObj<mtGC> {
39 G1YoungRemSetSamplingThread* _sample_thread;
40
41 ConcurrentG1RefineThread** _threads;
42 uint _n_worker_threads;
43 /*
44 * The value of the update buffer queue length falls into one of 3 zones:
45 * green, yellow, red. If the value is in [0, green) nothing is
46 * done, the buffers are left unprocessed to enable the caching effect of the
47 * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
48 * threads are gradually activated. In [yellow, red) all threads are
49 * running. If the length becomes red (max queue length) the mutators start
50 * processing the buffers.
51 *
52 * There are some interesting cases (when G1UseAdaptiveConcRefinement
53 * is turned off):
54 * 1) green = yellow = red = 0. In this case the mutator will process all
55 * buffers. Except for those that are created by the deferred updates
56 * machinery during a collection.
57 * 2) green = 0. Means no caching. Can be a good way to minimize the
58 * amount of time spent updating rsets during a collection.
59 */
60 size_t _green_zone;
61 size_t _yellow_zone;
62 size_t _red_zone;
63 size_t _min_yellow_zone_size;
64
65 ConcurrentG1Refine(size_t green_zone,
66 size_t yellow_zone,
67 size_t red_zone,
68 size_t min_yellow_zone_size);
69
70 // Update green/yellow/red zone values based on how well goals are being met.
71 void update_zones(double update_rs_time,
72 size_t update_rs_processed_buffers,
73 double goal_ms);
74
75 // Update thread thresholds to account for updated zone values.
76 void update_thread_thresholds();
77
78 public:
79 ~ConcurrentG1Refine();
80
81 // Returns ConcurrentG1Refine instance if succeeded to create/initialize ConcurrentG1Refine and ConcurrentG1RefineThread.
82 // Otherwise, returns NULL with error code.
83 static ConcurrentG1Refine* create(jint* ecode);
84
85 void stop();
86
87 void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms);
88
89 // Iterate over all concurrent refinement threads
90 void threads_do(ThreadClosure *tc);
91
92 // Iterate over all worker refinement threads
93 void worker_threads_do(ThreadClosure * tc);
94
95 // The RS sampling thread has nothing to do with refinement, but is here for now.
96 G1YoungRemSetSamplingThread * sampling_thread() const { return _sample_thread; }
97
98 static uint thread_num();
99
100 void print_worker_threads_on(outputStream* st) const;
101
102 size_t green_zone() const { return _green_zone; }
103 size_t yellow_zone() const { return _yellow_zone; }
104 size_t red_zone() const { return _red_zone; }
105 };
106
107 #endif // SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP
|
1 /*
2 * Copyright (c) 2001, 2017, 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_VM_GC_G1_G1CONCURRENTREFINE_HPP
26 #define SHARE_VM_GC_G1_G1CONCURRENTREFINE_HPP
27
28 #include "memory/allocation.hpp"
29 #include "utilities/globalDefinitions.hpp"
30
31 // Forward decl
32 class CardTableEntryClosure;
33 class G1ConcurrentRefineThread;
34 class G1YoungRemSetSamplingThread;
35 class outputStream;
36 class ThreadClosure;
37
38 class G1ConcurrentRefine : public CHeapObj<mtGC> {
39 G1YoungRemSetSamplingThread* _sample_thread;
40
41 G1ConcurrentRefineThread** _threads;
42 uint _n_worker_threads;
43 /*
44 * The value of the update buffer queue length falls into one of 3 zones:
45 * green, yellow, red. If the value is in [0, green) nothing is
46 * done, the buffers are left unprocessed to enable the caching effect of the
47 * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
48 * threads are gradually activated. In [yellow, red) all threads are
49 * running. If the length becomes red (max queue length) the mutators start
50 * processing the buffers.
51 *
52 * There are some interesting cases (when G1UseAdaptiveConcRefinement
53 * is turned off):
54 * 1) green = yellow = red = 0. In this case the mutator will process all
55 * buffers. Except for those that are created by the deferred updates
56 * machinery during a collection.
57 * 2) green = 0. Means no caching. Can be a good way to minimize the
58 * amount of time spent updating rsets during a collection.
59 */
60 size_t _green_zone;
61 size_t _yellow_zone;
62 size_t _red_zone;
63 size_t _min_yellow_zone_size;
64
65 G1ConcurrentRefine(size_t green_zone,
66 size_t yellow_zone,
67 size_t red_zone,
68 size_t min_yellow_zone_size);
69
70 // Update green/yellow/red zone values based on how well goals are being met.
71 void update_zones(double update_rs_time,
72 size_t update_rs_processed_buffers,
73 double goal_ms);
74
75 // Update thread thresholds to account for updated zone values.
76 void update_thread_thresholds();
77
78 public:
79 ~G1ConcurrentRefine();
80
81 // Returns a G1ConcurrentRefine instance if succeeded to create/initialize G1ConcurrentRefine and G1ConcurrentRefineThreads.
82 // Otherwise, returns NULL with error code.
83 static G1ConcurrentRefine* create(jint* ecode);
84
85 void stop();
86
87 void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms);
88
89 // Iterate over all concurrent refinement threads
90 void threads_do(ThreadClosure *tc);
91
92 // Iterate over all worker refinement threads
93 void worker_threads_do(ThreadClosure * tc);
94
95 // The RS sampling thread has nothing to do with refinement, but is here for now.
96 G1YoungRemSetSamplingThread * sampling_thread() const { return _sample_thread; }
97
98 static uint thread_num();
99
100 void print_worker_threads_on(outputStream* st) const;
101
102 size_t green_zone() const { return _green_zone; }
103 size_t yellow_zone() const { return _yellow_zone; }
104 size_t red_zone() const { return _red_zone; }
105 };
106
107 #endif // SHARE_VM_GC_G1_G1CONCURRENTREFINE_HPP
|