Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 6595:aaf61e68b255
6818524: G1: use ergonomic resizing of PLABs
Summary: Employ PLABStats instances to record information about survivor and old PLABs, and use the recorded stats to adjust the sizes of survivor and old PLABS.
Reviewed-by: johnc, ysr
Contributed-by: Brandon Mitchell <brandon@twitter.com>
author | johnc |
---|---|
date | Mon, 06 Aug 2012 12:20:14 -0700 |
parents | a2f7274eb6ef |
children | 7383557659bd |
comparison
equal
deleted
inserted
replaced
6265:ef437ea56651 | 6595:aaf61e68b255 |
---|---|
31 #include "gc_implementation/g1/g1RemSet.hpp" | 31 #include "gc_implementation/g1/g1RemSet.hpp" |
32 #include "gc_implementation/g1/g1MonitoringSupport.hpp" | 32 #include "gc_implementation/g1/g1MonitoringSupport.hpp" |
33 #include "gc_implementation/g1/heapRegionSeq.hpp" | 33 #include "gc_implementation/g1/heapRegionSeq.hpp" |
34 #include "gc_implementation/g1/heapRegionSets.hpp" | 34 #include "gc_implementation/g1/heapRegionSets.hpp" |
35 #include "gc_implementation/shared/hSpaceCounters.hpp" | 35 #include "gc_implementation/shared/hSpaceCounters.hpp" |
36 #include "gc_implementation/parNew/parGCAllocBuffer.hpp" | 36 #include "gc_implementation/shared/parGCAllocBuffer.hpp" |
37 #include "memory/barrierSet.hpp" | 37 #include "memory/barrierSet.hpp" |
38 #include "memory/memRegion.hpp" | 38 #include "memory/memRegion.hpp" |
39 #include "memory/sharedHeap.hpp" | 39 #include "memory/sharedHeap.hpp" |
40 | 40 |
41 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot. | 41 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot. |
276 | 276 |
277 // Alloc region used to satisfy allocation requests by the GC for | 277 // Alloc region used to satisfy allocation requests by the GC for |
278 // survivor objects. | 278 // survivor objects. |
279 SurvivorGCAllocRegion _survivor_gc_alloc_region; | 279 SurvivorGCAllocRegion _survivor_gc_alloc_region; |
280 | 280 |
281 // PLAB sizing policy for survivors. | |
282 PLABStats _survivor_plab_stats; | |
283 | |
281 // Alloc region used to satisfy allocation requests by the GC for | 284 // Alloc region used to satisfy allocation requests by the GC for |
282 // old objects. | 285 // old objects. |
283 OldGCAllocRegion _old_gc_alloc_region; | 286 OldGCAllocRegion _old_gc_alloc_region; |
287 | |
288 // PLAB sizing policy for tenured objects. | |
289 PLABStats _old_plab_stats; | |
290 | |
291 PLABStats* stats_for_purpose(GCAllocPurpose purpose) { | |
292 PLABStats* stats = NULL; | |
293 | |
294 switch (purpose) { | |
295 case GCAllocForSurvived: | |
296 stats = &_survivor_plab_stats; | |
297 break; | |
298 case GCAllocForTenured: | |
299 stats = &_old_plab_stats; | |
300 break; | |
301 default: | |
302 assert(false, "unrecognized GCAllocPurpose"); | |
303 } | |
304 | |
305 return stats; | |
306 } | |
284 | 307 |
285 // The last old region we allocated to during the last GC. | 308 // The last old region we allocated to during the last GC. |
286 // Typically, it is not full so we should re-use it during the next GC. | 309 // Typically, it is not full so we should re-use it during the next GC. |
287 HeapRegion* _retained_old_gc_alloc_region; | 310 HeapRegion* _retained_old_gc_alloc_region; |
288 | 311 |
312 | 335 |
313 // Helper for monitoring and management support. | 336 // Helper for monitoring and management support. |
314 G1MonitoringSupport* _g1mm; | 337 G1MonitoringSupport* _g1mm; |
315 | 338 |
316 // Determines PLAB size for a particular allocation purpose. | 339 // Determines PLAB size for a particular allocation purpose. |
317 static size_t desired_plab_sz(GCAllocPurpose purpose); | 340 size_t desired_plab_sz(GCAllocPurpose purpose); |
318 | 341 |
319 // Outside of GC pauses, the number of bytes used in all regions other | 342 // Outside of GC pauses, the number of bytes used in all regions other |
320 // than the current allocation region. | 343 // than the current allocation region. |
321 size_t _summary_bytes_used; | 344 size_t _summary_bytes_used; |
322 | 345 |
1809 immediate_rs_update(from, p, tid); | 1832 immediate_rs_update(from, p, tid); |
1810 } | 1833 } |
1811 } | 1834 } |
1812 | 1835 |
1813 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { | 1836 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { |
1814 | |
1815 HeapWord* obj = NULL; | 1837 HeapWord* obj = NULL; |
1816 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); | 1838 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); |
1817 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { | 1839 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { |
1818 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); | 1840 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); |
1819 assert(gclab_word_size == alloc_buf->word_sz(), | |
1820 "dynamic resizing is not supported"); | |
1821 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); | 1841 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); |
1822 alloc_buf->retire(false, false); | 1842 alloc_buf->flush_stats_and_retire(_g1h->stats_for_purpose(purpose), |
1843 false /* end_of_gc */, | |
1844 false /* retain */); | |
1823 | 1845 |
1824 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); | 1846 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); |
1825 if (buf == NULL) return NULL; // Let caller handle allocation failure. | 1847 if (buf == NULL) return NULL; // Let caller handle allocation failure. |
1826 // Otherwise. | 1848 // Otherwise. |
1849 alloc_buf->set_word_size(gclab_word_size); | |
1827 alloc_buf->set_buf(buf); | 1850 alloc_buf->set_buf(buf); |
1828 | 1851 |
1829 obj = alloc_buf->allocate(word_sz); | 1852 obj = alloc_buf->allocate(word_sz); |
1830 assert(obj != NULL, "buffer was definitely big enough..."); | 1853 assert(obj != NULL, "buffer was definitely big enough..."); |
1831 } else { | 1854 } else { |
1906 | 1929 |
1907 void retire_alloc_buffers() { | 1930 void retire_alloc_buffers() { |
1908 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { | 1931 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { |
1909 size_t waste = _alloc_buffers[ap]->words_remaining(); | 1932 size_t waste = _alloc_buffers[ap]->words_remaining(); |
1910 add_to_alloc_buffer_waste(waste); | 1933 add_to_alloc_buffer_waste(waste); |
1911 _alloc_buffers[ap]->retire(true, false); | 1934 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), |
1935 true /* end_of_gc */, | |
1936 false /* retain */); | |
1912 } | 1937 } |
1913 } | 1938 } |
1914 | 1939 |
1915 template <class T> void deal_with_reference(T* ref_to_scan) { | 1940 template <class T> void deal_with_reference(T* ref_to_scan) { |
1916 if (has_partial_array_mask(ref_to_scan)) { | 1941 if (has_partial_array_mask(ref_to_scan)) { |