comparison src/share/vm/gc_implementation/g1/vm_operations_g1.hpp @ 1973:631f79e71e90

6974966: G1: unnecessary direct-to-old allocations Summary: This change revamps the slow allocation path of G1. Improvements include the following: a) Allocations directly to old regions are now totally banned. G1 now only allows allocations out of young regions (with the only exception being humongous regions). b) The thread that allocates a new region (which is now guaranteed to be young) does not dirty all its cards. Each thread that successfully allocates out of a young region is now responsible for dirtying the cards that corresponding to the "block" that just got allocated. c) allocate_new_tlab() and mem_allocate() are now implemented differently and TLAB allocations are only done by allocate_new_tlab(). d) If a thread schedules an evacuation pause in order to satisfy an allocation request, it will perform the allocation at the end of the safepoint so that the thread that initiated the GC also gets "first pick" of any space made available by the GC. e) If a thread is unable to allocate a humongous object it will schedule an evacuation pause in case it reclaims enough regions so that the humongous allocation can be satisfied aftewards. f) The G1 policy is more careful to set the young list target length to be the survivor number +1. g) Lots of code tidy up, removal, refactoring to make future changes easier. Reviewed-by: johnc, ysr
author tonyp
date Tue, 24 Aug 2010 17:24:33 -0400
parents f95d63e2154a
children c798c277ddd1
comparison
equal deleted inserted replaced
1972:f95d63e2154a 1973:631f79e71e90
29 29
30 // VM_operations for the G1 collector. 30 // VM_operations for the G1 collector.
31 // VM_GC_Operation: 31 // VM_GC_Operation:
32 // - VM_CGC_Operation 32 // - VM_CGC_Operation
33 // - VM_G1CollectFull 33 // - VM_G1CollectFull
34 // - VM_G1CollectForAllocation 34 // - VM_G1OperationWithAllocRequest
35 // - VM_G1IncCollectionPause 35 // - VM_G1CollectForAllocation
36 // - VM_G1PopRegionCollectionPause 36 // - VM_G1IncCollectionPause
37
38 class VM_G1OperationWithAllocRequest: public VM_GC_Operation {
39 protected:
40 size_t _word_size;
41 HeapWord* _result;
42 bool _pause_succeeded;
43
44 public:
45 VM_G1OperationWithAllocRequest(unsigned int gc_count_before,
46 size_t word_size)
47 : VM_GC_Operation(gc_count_before),
48 _word_size(word_size), _result(NULL), _pause_succeeded(false) { }
49 HeapWord* result() { return _result; }
50 bool pause_succeeded() { return _pause_succeeded; }
51 };
37 52
38 class VM_G1CollectFull: public VM_GC_Operation { 53 class VM_G1CollectFull: public VM_GC_Operation {
39 public: 54 public:
40 VM_G1CollectFull(unsigned int gc_count_before, 55 VM_G1CollectFull(unsigned int gc_count_before,
41 unsigned int full_gc_count_before, 56 unsigned int full_gc_count_before,
42 GCCause::Cause cause) 57 GCCause::Cause cause)
43 : VM_GC_Operation(gc_count_before, full_gc_count_before) { 58 : VM_GC_Operation(gc_count_before, full_gc_count_before) {
44 _gc_cause = cause; 59 _gc_cause = cause;
45 } 60 }
46 ~VM_G1CollectFull() {}
47 virtual VMOp_Type type() const { return VMOp_G1CollectFull; } 61 virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
48 virtual void doit(); 62 virtual void doit();
49 virtual const char* name() const { 63 virtual const char* name() const {
50 return "full garbage-first collection"; 64 return "full garbage-first collection";
51 } 65 }
52 }; 66 };
53 67
54 class VM_G1CollectForAllocation: public VM_GC_Operation { 68 class VM_G1CollectForAllocation: public VM_G1OperationWithAllocRequest {
55 private: 69 public:
56 HeapWord* _res; 70 VM_G1CollectForAllocation(unsigned int gc_count_before,
57 size_t _size; // size of object to be allocated 71 size_t word_size);
58 public:
59 VM_G1CollectForAllocation(size_t size, int gc_count_before)
60 : VM_GC_Operation(gc_count_before) {
61 _size = size;
62 _res = NULL;
63 }
64 ~VM_G1CollectForAllocation() {}
65 virtual VMOp_Type type() const { return VMOp_G1CollectForAllocation; } 72 virtual VMOp_Type type() const { return VMOp_G1CollectForAllocation; }
66 virtual void doit(); 73 virtual void doit();
67 virtual const char* name() const { 74 virtual const char* name() const {
68 return "garbage-first collection to satisfy allocation"; 75 return "garbage-first collection to satisfy allocation";
69 } 76 }
70 HeapWord* result() { return _res; }
71 }; 77 };
72 78
73 class VM_G1IncCollectionPause: public VM_GC_Operation { 79 class VM_G1IncCollectionPause: public VM_G1OperationWithAllocRequest {
74 private: 80 private:
75 bool _should_initiate_conc_mark; 81 bool _should_initiate_conc_mark;
76 double _target_pause_time_ms; 82 double _target_pause_time_ms;
77 unsigned int _full_collections_completed_before; 83 unsigned int _full_collections_completed_before;
78 public: 84 public:
79 VM_G1IncCollectionPause(unsigned int gc_count_before, 85 VM_G1IncCollectionPause(unsigned int gc_count_before,
86 size_t word_size,
80 bool should_initiate_conc_mark, 87 bool should_initiate_conc_mark,
81 double target_pause_time_ms, 88 double target_pause_time_ms,
82 GCCause::Cause cause) 89 GCCause::Cause gc_cause);
83 : VM_GC_Operation(gc_count_before),
84 _full_collections_completed_before(0),
85 _should_initiate_conc_mark(should_initiate_conc_mark),
86 _target_pause_time_ms(target_pause_time_ms) {
87 guarantee(target_pause_time_ms > 0.0,
88 err_msg("target_pause_time_ms = %1.6lf should be positive",
89 target_pause_time_ms));
90
91 _gc_cause = cause;
92 }
93 virtual VMOp_Type type() const { return VMOp_G1IncCollectionPause; } 90 virtual VMOp_Type type() const { return VMOp_G1IncCollectionPause; }
94 virtual void doit(); 91 virtual void doit();
95 virtual void doit_epilogue(); 92 virtual void doit_epilogue();
96 virtual const char* name() const { 93 virtual const char* name() const {
97 return "garbage-first incremental collection pause"; 94 return "garbage-first incremental collection pause";
101 // Concurrent GC stop-the-world operations such as initial and final mark; 98 // Concurrent GC stop-the-world operations such as initial and final mark;
102 // consider sharing these with CMS's counterparts. 99 // consider sharing these with CMS's counterparts.
103 class VM_CGC_Operation: public VM_Operation { 100 class VM_CGC_Operation: public VM_Operation {
104 VoidClosure* _cl; 101 VoidClosure* _cl;
105 const char* _printGCMessage; 102 const char* _printGCMessage;
106 public: 103 public:
107 VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg) : 104 VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg)
108 _cl(cl), 105 : _cl(cl), _printGCMessage(printGCMsg) { }
109 _printGCMessage(printGCMsg)
110 {}
111
112 ~VM_CGC_Operation() {}
113
114 virtual VMOp_Type type() const { return VMOp_CGC_Operation; } 106 virtual VMOp_Type type() const { return VMOp_CGC_Operation; }
115 virtual void doit(); 107 virtual void doit();
116 virtual bool doit_prologue(); 108 virtual bool doit_prologue();
117 virtual void doit_epilogue(); 109 virtual void doit_epilogue();
118 virtual const char* name() const { 110 virtual const char* name() const {