comparison src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp @ 4095:bca17e38de00

6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads Summary: Select number of GC threads dynamically based on heap usage and number of Java threads Reviewed-by: johnc, ysr, jcoomes
author jmasa
date Tue, 09 Aug 2011 10:16:01 -0700
parents f95d63e2154a
children 6d7d0790074d
comparison
equal deleted inserted replaced
4094:3a298e04d914 4095:bca17e38de00
91 st->print("\"%s\" ", name()); 91 st->print("\"%s\" ", name());
92 Thread::print_on(st); 92 Thread::print_on(st);
93 st->cr(); 93 st->cr();
94 } 94 }
95 95
96 // GC workers get tasks from the GCTaskManager and execute
97 // them in this method. If there are no tasks to execute,
98 // the GC workers wait in the GCTaskManager's get_task()
99 // for tasks to be enqueued for execution.
100
96 void GCTaskThread::run() { 101 void GCTaskThread::run() {
97 // Set up the thread for stack overflow support 102 // Set up the thread for stack overflow support
98 this->record_stack_base_and_size(); 103 this->record_stack_base_and_size();
99 this->initialize_thread_local_storage(); 104 this->initialize_thread_local_storage();
100 // Bind yourself to your processor. 105 // Bind yourself to your processor.
122 HandleMark hm_inner; 127 HandleMark hm_inner;
123 ResourceMark rm_inner; 128 ResourceMark rm_inner;
124 for (; /* break */; ) { 129 for (; /* break */; ) {
125 // This will block until there is a task to be gotten. 130 // This will block until there is a task to be gotten.
126 GCTask* task = manager()->get_task(which()); 131 GCTask* task = manager()->get_task(which());
127
128 // In case the update is costly 132 // In case the update is costly
129 if (PrintGCTaskTimeStamps) { 133 if (PrintGCTaskTimeStamps) {
130 timer.update(); 134 timer.update();
131 } 135 }
132 136
133 jlong entry_time = timer.ticks(); 137 jlong entry_time = timer.ticks();
134 char* name = task->name(); 138 char* name = task->name();
135 139
136 task->do_it(manager(), which()); 140 task->do_it(manager(), which());
137 manager()->note_completion(which());
138 141
139 if (PrintGCTaskTimeStamps) { 142 if (!task->is_idle_task()) {
140 assert(_time_stamps != NULL, "Sanity (PrintGCTaskTimeStamps set late?)"); 143 manager()->note_completion(which());
141 144
142 timer.update(); 145 if (PrintGCTaskTimeStamps) {
146 assert(_time_stamps != NULL,
147 "Sanity (PrintGCTaskTimeStamps set late?)");
143 148
144 GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index++); 149 timer.update();
145 150
146 time_stamp->set_name(name); 151 GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index++);
147 time_stamp->set_entry_time(entry_time); 152
148 time_stamp->set_exit_time(timer.ticks()); 153 time_stamp->set_name(name);
154 time_stamp->set_entry_time(entry_time);
155 time_stamp->set_exit_time(timer.ticks());
156 }
157 } else {
158 // idle tasks complete outside the normal accounting
159 // so that a task can complete without waiting for idle tasks.
160 // They have to be terminated separately.
161 IdleGCTask::destroy((IdleGCTask*)task);
162 set_is_working(true);
149 } 163 }
150 164
151 // Check if we should release our inner resources. 165 // Check if we should release our inner resources.
152 if (manager()->should_release_resources(which())) { 166 if (manager()->should_release_resources(which())) {
153 manager()->note_release(which()); 167 manager()->note_release(which());