comparison src/share/vm/gc_implementation/parallelScavenge/psTasks.hpp @ 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 f81a7c0c618d
comparison
equal deleted inserted replaced
4094:3a298e04d914 4095:bca17e38de00
133 133
134 // 134 //
135 // OldToYoungRootsTask 135 // OldToYoungRootsTask
136 // 136 //
137 // This task is used to scan old to young roots in parallel 137 // This task is used to scan old to young roots in parallel
138 //
139 // A GC thread executing this tasks divides the generation (old gen)
140 // into slices and takes a stripe in the slice as its part of the
141 // work.
142 //
143 // +===============+ slice 0
144 // | stripe 0 |
145 // +---------------+
146 // | stripe 1 |
147 // +---------------+
148 // | stripe 2 |
149 // +---------------+
150 // | stripe 3 |
151 // +===============+ slice 1
152 // | stripe 0 |
153 // +---------------+
154 // | stripe 1 |
155 // +---------------+
156 // | stripe 2 |
157 // +---------------+
158 // | stripe 3 |
159 // +===============+ slice 2
160 // ...
161 //
162 // A task is created for each stripe. In this case there are 4 tasks
163 // created. A GC thread first works on its stripe within slice 0
164 // and then moves to its stripe in the next slice until all stripes
165 // exceed the top of the generation. Note that having fewer GC threads
166 // than stripes works because all the tasks are executed so all stripes
167 // will be covered. In this example if 4 tasks have been created to cover
168 // all the stripes and there are only 3 threads, one of the threads will
169 // get the tasks with the 4th stripe. However, there is a dependence in
170 // CardTableExtension::scavenge_contents_parallel() on the number
171 // of tasks created. In scavenge_contents_parallel the distance
172 // to the next stripe is calculated based on the number of tasks.
173 // If the stripe width is ssize, a task's next stripe is at
174 // ssize * number_of_tasks (= slice_stride). In this case after
175 // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1
176 // by adding slice_stride to the start of stripe 0 in slice 0 to get
177 // to the start of stride 0 in slice 1.
138 178
139 class OldToYoungRootsTask : public GCTask { 179 class OldToYoungRootsTask : public GCTask {
140 private: 180 private:
141 PSOldGen* _gen; 181 PSOldGen* _gen;
142 HeapWord* _gen_top; 182 HeapWord* _gen_top;
143 uint _stripe_number; 183 uint _stripe_number;
144 184 uint _stripe_total;
145 public: 185
146 OldToYoungRootsTask(PSOldGen *gen, HeapWord* gen_top, uint stripe_number) : 186 public:
147 _gen(gen), _gen_top(gen_top), _stripe_number(stripe_number) { } 187 OldToYoungRootsTask(PSOldGen *gen,
188 HeapWord* gen_top,
189 uint stripe_number,
190 uint stripe_total) :
191 _gen(gen),
192 _gen_top(gen_top),
193 _stripe_number(stripe_number),
194 _stripe_total(stripe_total) { }
148 195
149 char* name() { return (char *)"old-to-young-roots-task"; } 196 char* name() { return (char *)"old-to-young-roots-task"; }
150 197
151 virtual void do_it(GCTaskManager* manager, uint which); 198 virtual void do_it(GCTaskManager* manager, uint which);
152 }; 199 };