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 G1ConcurrentRefine;
34 class G1ConcurrentRefineThread;
35 class outputStream;
36 class ThreadClosure;
37
38 // Helper class for refinement thread management. Used to start, stop and
39 // iterate over them.
40 class G1ConcurrentRefineThreadControl VALUE_OBJ_CLASS_SPEC {
41 G1ConcurrentRefine* _cg1r;
42
43 G1ConcurrentRefineThread** _threads;
44 uint _num_max_threads;
45 public:
46 G1ConcurrentRefineThreadControl();
47 ~G1ConcurrentRefineThreadControl();
48
49 void initialize(G1ConcurrentRefine* cg1r, uint num_max_threads);
50
51 // If there is a "successor" thread that can be activated given the current id,
52 // activate it.
53 void maybe_activate_next(uint cur_worker_id);
54
55 void print_on(outputStream* st) const;
56 void worker_threads_do(ThreadClosure* tc);
57 void stop();
58 };
59
60 // Controls refinement threads and their activation based on the number of completed
61 // buffers currently available in the global dirty card queue.
62 // Refinement threads pick work from the queue based on these thresholds. They are activated
63 // gradually based on the amount of work to do.
64 // Refinement thread n activates thread n+1 if the instance of this class determines there
65 // is enough work available. Threads deactivate themselves if the current amount of
66 // completed buffers falls below their individual threshold.
67 class G1ConcurrentRefine : public CHeapObj<mtGC> {
68 G1ConcurrentRefineThreadControl _thread_control;
69 /*
84 * amount of time spent updating remembered sets during a collection.
85 */
86 size_t _green_zone;
87 size_t _yellow_zone;
88 size_t _red_zone;
89 size_t _min_yellow_zone_size;
90
91 G1ConcurrentRefine(size_t green_zone,
92 size_t yellow_zone,
93 size_t red_zone,
94 size_t min_yellow_zone_size);
95
96 // Update green/yellow/red zone values based on how well goals are being met.
97 void update_zones(double update_rs_time,
98 size_t update_rs_processed_buffers,
99 double goal_ms);
100
101 static uint worker_id_offset();
102 void maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers);
103
104 public:
105 ~G1ConcurrentRefine();
106
107 // Returns a G1ConcurrentRefine instance if succeeded to create/initialize the
108 // G1ConcurrentRefine instance. Otherwise, returns NULL with error code.
109 static G1ConcurrentRefine* create(jint* ecode);
110
111 void stop();
112
113 // Adjust refinement thresholds based on work done during the pause and the goal time.
114 void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms);
115
116 size_t activation_threshold(uint worker_id) const;
117 size_t deactivation_threshold(uint worker_id) const;
118 // Perform a single refinement step. Called by the refinement threads when woken up.
119 bool do_refinement_step(uint worker_id);
120
121 // Iterate over all concurrent refinement threads applying the given closure.
122 void threads_do(ThreadClosure *tc);
123
|
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 G1ConcurrentRefine;
34 class G1ConcurrentRefineThread;
35 class outputStream;
36 class ThreadClosure;
37
38 // Helper class for refinement thread management. Used to start, stop and
39 // iterate over them.
40 class G1ConcurrentRefineThreadControl VALUE_OBJ_CLASS_SPEC {
41 G1ConcurrentRefine* _cr;
42
43 G1ConcurrentRefineThread** _threads;
44 uint _num_max_threads;
45
46 // Create the refinement thread for the given worker id.
47 // If initializing is true, ignore InjectGCWorkerCreationFailure.
48 G1ConcurrentRefineThread* create_refinement_thread(uint worker_id, bool initializing);
49 public:
50 G1ConcurrentRefineThreadControl();
51 ~G1ConcurrentRefineThreadControl();
52
53 jint initialize(G1ConcurrentRefine* cr, uint num_max_threads);
54
55 // If there is a "successor" thread that can be activated given the current id,
56 // activate it.
57 void maybe_activate_next(uint cur_worker_id);
58
59 void print_on(outputStream* st) const;
60 void worker_threads_do(ThreadClosure* tc);
61 void stop();
62 };
63
64 // Controls refinement threads and their activation based on the number of completed
65 // buffers currently available in the global dirty card queue.
66 // Refinement threads pick work from the queue based on these thresholds. They are activated
67 // gradually based on the amount of work to do.
68 // Refinement thread n activates thread n+1 if the instance of this class determines there
69 // is enough work available. Threads deactivate themselves if the current amount of
70 // completed buffers falls below their individual threshold.
71 class G1ConcurrentRefine : public CHeapObj<mtGC> {
72 G1ConcurrentRefineThreadControl _thread_control;
73 /*
88 * amount of time spent updating remembered sets during a collection.
89 */
90 size_t _green_zone;
91 size_t _yellow_zone;
92 size_t _red_zone;
93 size_t _min_yellow_zone_size;
94
95 G1ConcurrentRefine(size_t green_zone,
96 size_t yellow_zone,
97 size_t red_zone,
98 size_t min_yellow_zone_size);
99
100 // Update green/yellow/red zone values based on how well goals are being met.
101 void update_zones(double update_rs_time,
102 size_t update_rs_processed_buffers,
103 double goal_ms);
104
105 static uint worker_id_offset();
106 void maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers);
107
108 jint initialize();
109 public:
110 ~G1ConcurrentRefine();
111
112 // Returns a G1ConcurrentRefine instance if succeeded to create/initialize the
113 // G1ConcurrentRefine instance. Otherwise, returns NULL with error code.
114 static G1ConcurrentRefine* create(jint* ecode);
115
116 void stop();
117
118 // Adjust refinement thresholds based on work done during the pause and the goal time.
119 void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms);
120
121 size_t activation_threshold(uint worker_id) const;
122 size_t deactivation_threshold(uint worker_id) const;
123 // Perform a single refinement step. Called by the refinement threads when woken up.
124 bool do_refinement_step(uint worker_id);
125
126 // Iterate over all concurrent refinement threads applying the given closure.
127 void threads_do(ThreadClosure *tc);
128
|