Mon, 27 May 2013 15:22:59 +0200
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
Summary: Split SystemDictionary and ClassLoaderDataGraph root processing to help load balancing.
Reviewed-by: tschatzl, johnc
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "utilities/growableArray.hpp" |
stefank@2314 | 30 | |
duke@435 | 31 | // |
duke@435 | 32 | // psTasks.hpp is a collection of GCTasks used by the |
duke@435 | 33 | // parallelScavenge collector. |
duke@435 | 34 | // |
duke@435 | 35 | |
duke@435 | 36 | class GCTask; |
duke@435 | 37 | class OopClosure; |
duke@435 | 38 | class OopStack; |
duke@435 | 39 | class ObjectStartArray; |
duke@435 | 40 | class ParallelTaskTerminator; |
duke@435 | 41 | class MutableSpace; |
duke@435 | 42 | class PSOldGen; |
duke@435 | 43 | class Thread; |
duke@435 | 44 | class VMThread; |
duke@435 | 45 | |
duke@435 | 46 | // |
duke@435 | 47 | // ScavengeRootsTask |
duke@435 | 48 | // |
duke@435 | 49 | // This task scans all the roots of a given type. |
duke@435 | 50 | // |
duke@435 | 51 | // |
duke@435 | 52 | |
duke@435 | 53 | class ScavengeRootsTask : public GCTask { |
duke@435 | 54 | public: |
duke@435 | 55 | enum RootType { |
duke@435 | 56 | universe = 1, |
duke@435 | 57 | jni_handles = 2, |
duke@435 | 58 | threads = 3, |
duke@435 | 59 | object_synchronizer = 4, |
duke@435 | 60 | flat_profiler = 5, |
duke@435 | 61 | system_dictionary = 6, |
stefank@5194 | 62 | class_loader_data = 7, |
stefank@5194 | 63 | management = 8, |
stefank@5194 | 64 | jvmti = 9, |
stefank@5194 | 65 | code_cache = 10 |
duke@435 | 66 | }; |
duke@435 | 67 | private: |
duke@435 | 68 | RootType _root_type; |
duke@435 | 69 | public: |
duke@435 | 70 | ScavengeRootsTask(RootType value) : _root_type(value) {} |
duke@435 | 71 | |
duke@435 | 72 | char* name() { return (char *)"scavenge-roots-task"; } |
duke@435 | 73 | |
duke@435 | 74 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 75 | }; |
duke@435 | 76 | |
duke@435 | 77 | // |
duke@435 | 78 | // ThreadRootsTask |
duke@435 | 79 | // |
duke@435 | 80 | // This task scans the roots of a single thread. This task |
duke@435 | 81 | // enables scanning of thread roots in parallel. |
duke@435 | 82 | // |
duke@435 | 83 | |
duke@435 | 84 | class ThreadRootsTask : public GCTask { |
duke@435 | 85 | private: |
duke@435 | 86 | JavaThread* _java_thread; |
duke@435 | 87 | VMThread* _vm_thread; |
duke@435 | 88 | public: |
duke@435 | 89 | ThreadRootsTask(JavaThread* root) : _java_thread(root), _vm_thread(NULL) {} |
duke@435 | 90 | ThreadRootsTask(VMThread* root) : _java_thread(NULL), _vm_thread(root) {} |
duke@435 | 91 | |
duke@435 | 92 | char* name() { return (char *)"thread-roots-task"; } |
duke@435 | 93 | |
duke@435 | 94 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 95 | }; |
duke@435 | 96 | |
duke@435 | 97 | // |
duke@435 | 98 | // StealTask |
duke@435 | 99 | // |
duke@435 | 100 | // This task is used to distribute work to idle threads. |
duke@435 | 101 | // |
duke@435 | 102 | |
duke@435 | 103 | class StealTask : public GCTask { |
duke@435 | 104 | private: |
duke@435 | 105 | ParallelTaskTerminator* const _terminator; |
duke@435 | 106 | public: |
duke@435 | 107 | char* name() { return (char *)"steal-task"; } |
duke@435 | 108 | |
duke@435 | 109 | StealTask(ParallelTaskTerminator* t); |
duke@435 | 110 | |
duke@435 | 111 | ParallelTaskTerminator* terminator() { return _terminator; } |
duke@435 | 112 | |
duke@435 | 113 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 114 | }; |
duke@435 | 115 | |
duke@435 | 116 | // |
duke@435 | 117 | // OldToYoungRootsTask |
duke@435 | 118 | // |
duke@435 | 119 | // This task is used to scan old to young roots in parallel |
jmasa@3294 | 120 | // |
jmasa@3294 | 121 | // A GC thread executing this tasks divides the generation (old gen) |
jmasa@3294 | 122 | // into slices and takes a stripe in the slice as its part of the |
jmasa@3294 | 123 | // work. |
jmasa@3294 | 124 | // |
jmasa@3294 | 125 | // +===============+ slice 0 |
jmasa@3294 | 126 | // | stripe 0 | |
jmasa@3294 | 127 | // +---------------+ |
jmasa@3294 | 128 | // | stripe 1 | |
jmasa@3294 | 129 | // +---------------+ |
jmasa@3294 | 130 | // | stripe 2 | |
jmasa@3294 | 131 | // +---------------+ |
jmasa@3294 | 132 | // | stripe 3 | |
jmasa@3294 | 133 | // +===============+ slice 1 |
jmasa@3294 | 134 | // | stripe 0 | |
jmasa@3294 | 135 | // +---------------+ |
jmasa@3294 | 136 | // | stripe 1 | |
jmasa@3294 | 137 | // +---------------+ |
jmasa@3294 | 138 | // | stripe 2 | |
jmasa@3294 | 139 | // +---------------+ |
jmasa@3294 | 140 | // | stripe 3 | |
jmasa@3294 | 141 | // +===============+ slice 2 |
jmasa@3294 | 142 | // ... |
jmasa@3294 | 143 | // |
jmasa@3294 | 144 | // A task is created for each stripe. In this case there are 4 tasks |
jmasa@3294 | 145 | // created. A GC thread first works on its stripe within slice 0 |
jmasa@3294 | 146 | // and then moves to its stripe in the next slice until all stripes |
jmasa@3294 | 147 | // exceed the top of the generation. Note that having fewer GC threads |
jmasa@3294 | 148 | // than stripes works because all the tasks are executed so all stripes |
jmasa@3294 | 149 | // will be covered. In this example if 4 tasks have been created to cover |
jmasa@3294 | 150 | // all the stripes and there are only 3 threads, one of the threads will |
jmasa@3294 | 151 | // get the tasks with the 4th stripe. However, there is a dependence in |
jmasa@3294 | 152 | // CardTableExtension::scavenge_contents_parallel() on the number |
jmasa@3294 | 153 | // of tasks created. In scavenge_contents_parallel the distance |
jmasa@3294 | 154 | // to the next stripe is calculated based on the number of tasks. |
jmasa@3294 | 155 | // If the stripe width is ssize, a task's next stripe is at |
jmasa@3294 | 156 | // ssize * number_of_tasks (= slice_stride). In this case after |
jmasa@3294 | 157 | // finishing stripe 0 in slice 0, the thread finds the stripe 0 in slice1 |
jmasa@3294 | 158 | // by adding slice_stride to the start of stripe 0 in slice 0 to get |
jmasa@3294 | 159 | // to the start of stride 0 in slice 1. |
duke@435 | 160 | |
duke@435 | 161 | class OldToYoungRootsTask : public GCTask { |
duke@435 | 162 | private: |
duke@435 | 163 | PSOldGen* _gen; |
duke@435 | 164 | HeapWord* _gen_top; |
duke@435 | 165 | uint _stripe_number; |
jmasa@3294 | 166 | uint _stripe_total; |
duke@435 | 167 | |
duke@435 | 168 | public: |
jmasa@3294 | 169 | OldToYoungRootsTask(PSOldGen *gen, |
jmasa@3294 | 170 | HeapWord* gen_top, |
jmasa@3294 | 171 | uint stripe_number, |
jmasa@3294 | 172 | uint stripe_total) : |
jmasa@3294 | 173 | _gen(gen), |
jmasa@3294 | 174 | _gen_top(gen_top), |
jmasa@3294 | 175 | _stripe_number(stripe_number), |
jmasa@3294 | 176 | _stripe_total(stripe_total) { } |
duke@435 | 177 | |
duke@435 | 178 | char* name() { return (char *)"old-to-young-roots-task"; } |
duke@435 | 179 | |
duke@435 | 180 | virtual void do_it(GCTaskManager* manager, uint which); |
duke@435 | 181 | }; |
stefank@2314 | 182 | |
stefank@2314 | 183 | #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSTASKS_HPP |