comparison src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp @ 12029:9766f73e770d

8022880: False sharing between PSPromotionManager instances Summary: Pad the PSPromotionManager instances in the manager array. Reviewed-by: brutisso, jmasa
author stefank
date Fri, 31 May 2013 14:32:44 +0200
parents f2110083203d
children 190899198332
comparison
equal deleted inserted replaced
12009:39127bb12d32 12029:9766f73e770d
27 #include "gc_implementation/parallelScavenge/psOldGen.hpp" 27 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
28 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" 28 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
29 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" 29 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
30 #include "gc_implementation/shared/gcTrace.hpp" 30 #include "gc_implementation/shared/gcTrace.hpp"
31 #include "gc_implementation/shared/mutableSpace.hpp" 31 #include "gc_implementation/shared/mutableSpace.hpp"
32 #include "memory/allocation.inline.hpp"
32 #include "memory/memRegion.hpp" 33 #include "memory/memRegion.hpp"
34 #include "memory/padded.inline.hpp"
33 #include "oops/oop.inline.hpp" 35 #include "oops/oop.inline.hpp"
34 #include "oops/oop.psgc.inline.hpp" 36 #include "oops/oop.psgc.inline.hpp"
35 37
36 PSPromotionManager** PSPromotionManager::_manager_array = NULL; 38 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
37 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL; 39 OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
38 PSOldGen* PSPromotionManager::_old_gen = NULL; 40 PSOldGen* PSPromotionManager::_old_gen = NULL;
39 MutableSpace* PSPromotionManager::_young_space = NULL; 41 MutableSpace* PSPromotionManager::_young_space = NULL;
40 42
41 void PSPromotionManager::initialize() { 43 void PSPromotionManager::initialize() {
42 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 44 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
43 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 45 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
44 46
45 _old_gen = heap->old_gen(); 47 _old_gen = heap->old_gen();
46 _young_space = heap->young_gen()->to_space(); 48 _young_space = heap->young_gen()->to_space();
47 49
50 // To prevent false sharing, we pad the PSPromotionManagers
51 // and make sure that the first instance starts at a cache line.
48 assert(_manager_array == NULL, "Attempt to initialize twice"); 52 assert(_manager_array == NULL, "Attempt to initialize twice");
49 _manager_array = NEW_C_HEAP_ARRAY(PSPromotionManager*, ParallelGCThreads+1, mtGC); 53 _manager_array = PaddedArray<PSPromotionManager, mtGC>::create_unfreeable(ParallelGCThreads + 1);
50 guarantee(_manager_array != NULL, "Could not initialize promotion manager"); 54 guarantee(_manager_array != NULL, "Could not initialize promotion manager");
51 55
52 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads); 56 _stack_array_depth = new OopStarTaskQueueSet(ParallelGCThreads);
53 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager"); 57 guarantee(_stack_array_depth != NULL, "Could not initialize promotion manager");
54 58
55 // Create and register the PSPromotionManager(s) for the worker threads. 59 // Create and register the PSPromotionManager(s) for the worker threads.
56 for(uint i=0; i<ParallelGCThreads; i++) { 60 for(uint i=0; i<ParallelGCThreads; i++) {
57 _manager_array[i] = new PSPromotionManager(); 61 stack_array_depth()->register_queue(i, _manager_array[i].claimed_stack_depth());
58 guarantee(_manager_array[i] != NULL, "Could not create PSPromotionManager"); 62 }
59 stack_array_depth()->register_queue(i, _manager_array[i]->claimed_stack_depth());
60 }
61
62 // The VMThread gets its own PSPromotionManager, which is not available 63 // The VMThread gets its own PSPromotionManager, which is not available
63 // for work stealing. 64 // for work stealing.
64 _manager_array[ParallelGCThreads] = new PSPromotionManager();
65 guarantee(_manager_array[ParallelGCThreads] != NULL, "Could not create PSPromotionManager");
66 } 65 }
67 66
68 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { 67 PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) {
69 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); 68 assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range");
70 assert(_manager_array != NULL, "Sanity"); 69 assert(_manager_array != NULL, "Sanity");
71 return _manager_array[index]; 70 return &_manager_array[index];
72 } 71 }
73 72
74 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() { 73 PSPromotionManager* PSPromotionManager::vm_thread_promotion_manager() {
75 assert(_manager_array != NULL, "Sanity"); 74 assert(_manager_array != NULL, "Sanity");
76 return _manager_array[ParallelGCThreads]; 75 return &_manager_array[ParallelGCThreads];
77 } 76 }
78 77
79 void PSPromotionManager::pre_scavenge() { 78 void PSPromotionManager::pre_scavenge() {
80 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 79 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
81 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 80 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");