< prev index next >

src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 8048 : 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
Summary: Allow partial use of large pages for auxiliary data structures in G1.
Reviewed-by: jmasa
rev 8049 : imported patch 8058354-stefank-review
rev 8050 : imported patch 8058354-more-stefank-review
rev 8051 : imported patch 8058354-more-more-stefank-review


1799   assert(n_rem_sets > 0, "Invariant.");
1800 
1801   _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
1802   _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(uint, n_queues, mtGC);
1803   _evacuation_failed_info_array = NEW_C_HEAP_ARRAY(EvacuationFailedInfo, n_queues, mtGC);
1804 
1805   for (int i = 0; i < n_queues; i++) {
1806     RefToScanQueue* q = new RefToScanQueue();
1807     q->initialize();
1808     _task_queues->register_queue(i, q);
1809     ::new (&_evacuation_failed_info_array[i]) EvacuationFailedInfo();
1810   }
1811   clear_cset_start_regions();
1812 
1813   // Initialize the G1EvacuationFailureALot counters and flags.
1814   NOT_PRODUCT(reset_evacuation_should_fail();)
1815 
1816   guarantee(_task_queues != NULL, "task_queues allocation failure.");
1817 }
1818 



















1819 jint G1CollectedHeap::initialize() {
1820   CollectedHeap::pre_initialize();
1821   os::enable_vtime();
1822 
1823   G1Log::init();
1824 
1825   // Necessary to satisfy locking discipline assertions.
1826 
1827   MutexLocker x(Heap_lock);
1828 
1829   // We have to initialize the printer before committing the heap, as
1830   // it will be used then.
1831   _hr_printer.set_active(G1PrintHeapRegions);
1832 
1833   // While there are no constraints in the GC code that HeapWordSize
1834   // be any particular value, there are multiple other areas in the
1835   // system which believe this to be true (e.g. oop->object_size in some
1836   // cases incorrectly returns the size in wordSize units rather than
1837   // HeapWordSize).
1838   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");


1866   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
1867                                                  heap_alignment);
1868 
1869   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
1870 
1871   // Create the barrier set for the entire reserved region.
1872   G1SATBCardTableLoggingModRefBS* bs
1873     = new G1SATBCardTableLoggingModRefBS(reserved_region());
1874   bs->initialize();
1875   assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
1876   set_barrier_set(bs);
1877 
1878   // Also create a G1 rem set.
1879   _g1_rem_set = new G1RemSet(this, g1_barrier_set());
1880 
1881   // Carve out the G1 part of the heap.
1882 
1883   ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1884   G1RegionToSpaceMapper* heap_storage =
1885     G1RegionToSpaceMapper::create_mapper(g1_rs,

1886                                          UseLargePages ? os::large_page_size() : os::vm_page_size(),
1887                                          HeapRegion::GrainBytes,
1888                                          1,
1889                                          mtJavaHeap);
1890   heap_storage->set_mapping_changed_listener(&_listener);
1891 
1892   // Reserve space for the block offset table. We do not support automatic uncommit
1893   // for the card table at this time. BOT only.
1894   ReservedSpace bot_rs(G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize));
1895   G1RegionToSpaceMapper* bot_storage =
1896     G1RegionToSpaceMapper::create_mapper(bot_rs,
1897                                          os::vm_page_size(),
1898                                          HeapRegion::GrainBytes,
1899                                          G1BlockOffsetSharedArray::N_bytes,
1900                                          mtGC);
1901 
1902   ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1903   G1RegionToSpaceMapper* cardtable_storage =
1904     G1RegionToSpaceMapper::create_mapper(cardtable_rs,
1905                                          os::vm_page_size(),
1906                                          HeapRegion::GrainBytes,
1907                                          G1BlockOffsetSharedArray::N_bytes,
1908                                          mtGC);
1909 
1910   // Reserve space for the card counts table.
1911   ReservedSpace card_counts_rs(G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize));
1912   G1RegionToSpaceMapper* card_counts_storage =
1913     G1RegionToSpaceMapper::create_mapper(card_counts_rs,
1914                                          os::vm_page_size(),
1915                                          HeapRegion::GrainBytes,
1916                                          G1BlockOffsetSharedArray::N_bytes,
1917                                          mtGC);
1918 
1919   // Reserve space for prev and next bitmap.
1920   size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());
1921 
1922   ReservedSpace prev_bitmap_rs(ReservedSpace::allocation_align_size_up(bitmap_size));
1923   G1RegionToSpaceMapper* prev_bitmap_storage =
1924     G1RegionToSpaceMapper::create_mapper(prev_bitmap_rs,
1925                                          os::vm_page_size(),
1926                                          HeapRegion::GrainBytes,
1927                                          CMBitMap::mark_distance(),
1928                                          mtGC);
1929 
1930   ReservedSpace next_bitmap_rs(ReservedSpace::allocation_align_size_up(bitmap_size));
1931   G1RegionToSpaceMapper* next_bitmap_storage =
1932     G1RegionToSpaceMapper::create_mapper(next_bitmap_rs,
1933                                          os::vm_page_size(),
1934                                          HeapRegion::GrainBytes,
1935                                          CMBitMap::mark_distance(),
1936                                          mtGC);
1937 
1938   _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1939   g1_barrier_set()->initialize(cardtable_storage);
1940    // Do later initialization work for concurrent refinement.
1941   _cg1r->init(card_counts_storage);
1942 
1943   // 6843694 - ensure that the maximum region index can fit
1944   // in the remembered set structures.
1945   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1946   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1947 
1948   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1949   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1950   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1951             "too many cards per region");
1952 
1953   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1954 
1955   _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
1956 




1799   assert(n_rem_sets > 0, "Invariant.");
1800 
1801   _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
1802   _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(uint, n_queues, mtGC);
1803   _evacuation_failed_info_array = NEW_C_HEAP_ARRAY(EvacuationFailedInfo, n_queues, mtGC);
1804 
1805   for (int i = 0; i < n_queues; i++) {
1806     RefToScanQueue* q = new RefToScanQueue();
1807     q->initialize();
1808     _task_queues->register_queue(i, q);
1809     ::new (&_evacuation_failed_info_array[i]) EvacuationFailedInfo();
1810   }
1811   clear_cset_start_regions();
1812 
1813   // Initialize the G1EvacuationFailureALot counters and flags.
1814   NOT_PRODUCT(reset_evacuation_should_fail();)
1815 
1816   guarantee(_task_queues != NULL, "task_queues allocation failure.");
1817 }
1818 
1819 G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* description,
1820                                                                  size_t size,
1821                                                                  size_t translation_factor) {
1822   // Allocate a new reserved space, preferring to use large pages.
1823   ReservedSpace rs(size, true);
1824   G1RegionToSpaceMapper* result  =
1825     G1RegionToSpaceMapper::create_mapper(rs,
1826                                          size,
1827                                          rs.alignment(),
1828                                          HeapRegion::GrainBytes,
1829                                          translation_factor,
1830                                          mtGC);
1831   if (TracePageSizes) {
1832     gclog_or_tty->print_cr("G1 '%s': pg_sz=" SIZE_FORMAT " base=" PTR_FORMAT " size=" SIZE_FORMAT " alignment=" SIZE_FORMAT " reqsize=" SIZE_FORMAT,
1833                            description, rs.alignment(), p2i(rs.base()), rs.size(), rs.alignment(), size);
1834   }
1835   return result;
1836 }
1837 
1838 jint G1CollectedHeap::initialize() {
1839   CollectedHeap::pre_initialize();
1840   os::enable_vtime();
1841 
1842   G1Log::init();
1843 
1844   // Necessary to satisfy locking discipline assertions.
1845 
1846   MutexLocker x(Heap_lock);
1847 
1848   // We have to initialize the printer before committing the heap, as
1849   // it will be used then.
1850   _hr_printer.set_active(G1PrintHeapRegions);
1851 
1852   // While there are no constraints in the GC code that HeapWordSize
1853   // be any particular value, there are multiple other areas in the
1854   // system which believe this to be true (e.g. oop->object_size in some
1855   // cases incorrectly returns the size in wordSize units rather than
1856   // HeapWordSize).
1857   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");


1885   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
1886                                                  heap_alignment);
1887 
1888   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
1889 
1890   // Create the barrier set for the entire reserved region.
1891   G1SATBCardTableLoggingModRefBS* bs
1892     = new G1SATBCardTableLoggingModRefBS(reserved_region());
1893   bs->initialize();
1894   assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
1895   set_barrier_set(bs);
1896 
1897   // Also create a G1 rem set.
1898   _g1_rem_set = new G1RemSet(this, g1_barrier_set());
1899 
1900   // Carve out the G1 part of the heap.
1901 
1902   ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1903   G1RegionToSpaceMapper* heap_storage =
1904     G1RegionToSpaceMapper::create_mapper(g1_rs,
1905                                          g1_rs.size(),
1906                                          UseLargePages ? os::large_page_size() : os::vm_page_size(),
1907                                          HeapRegion::GrainBytes,
1908                                          1,
1909                                          mtJavaHeap);
1910   heap_storage->set_mapping_changed_listener(&_listener);
1911 
1912   // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps.


1913   G1RegionToSpaceMapper* bot_storage =
1914     create_aux_memory_mapper("Block offset table",
1915                              G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
1916                              G1BlockOffsetSharedArray::N_bytes);


1917 
1918   ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1919   G1RegionToSpaceMapper* cardtable_storage =
1920     create_aux_memory_mapper("Card table",
1921                              G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize),
1922                              G1BlockOffsetSharedArray::N_bytes);


1923 


1924   G1RegionToSpaceMapper* card_counts_storage =
1925     create_aux_memory_mapper("Card counts table",
1926                              G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
1927                              G1BlockOffsetSharedArray::N_bytes);


1928 

1929   size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());


1930   G1RegionToSpaceMapper* prev_bitmap_storage =
1931     create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::mark_distance());






1932   G1RegionToSpaceMapper* next_bitmap_storage =
1933     create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::mark_distance());




1934 
1935   _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1936   g1_barrier_set()->initialize(cardtable_storage);
1937    // Do later initialization work for concurrent refinement.
1938   _cg1r->init(card_counts_storage);
1939 
1940   // 6843694 - ensure that the maximum region index can fit
1941   // in the remembered set structures.
1942   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1943   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1944 
1945   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1946   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1947   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1948             "too many cards per region");
1949 
1950   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1951 
1952   _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
1953 


< prev index next >