< prev index next >

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

Print this page
rev 7696 : 8030646: track collection set membership in one place


1600   _collectionSetChooser->prepare_for_par_region_addition(n_regions, chunk_size);
1601   ParKnownGarbageTask par_known_garbage_task(_collectionSetChooser, chunk_size, n_workers);
1602   _g1->workers()->run_task(&par_known_garbage_task);
1603 
1604   _collectionSetChooser->sort_regions();
1605 
1606   double end_sec = os::elapsedTime();
1607   double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
1608   _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
1609   _cur_mark_stop_world_time_ms += elapsed_time_ms;
1610   _prev_collection_pause_end_ms += elapsed_time_ms;
1611   _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_sec, true);
1612 }
1613 
1614 // Add the heap region at the head of the non-incremental collection set
1615 void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) {
1616   assert(_inc_cset_build_state == Active, "Precondition");
1617   assert(hr->is_old(), "the region should be old");
1618 
1619   assert(!hr->in_collection_set(), "should not already be in the CSet");
1620   hr->set_in_collection_set(true);
1621   hr->set_next_in_collection_set(_collection_set);
1622   _collection_set = hr;
1623   _collection_set_bytes_used_before += hr->used();
1624   _g1->register_old_region_with_in_cset_fast_test(hr);
1625   size_t rs_length = hr->rem_set()->occupied();
1626   _recorded_rs_lengths += rs_length;
1627   _old_cset_region_length += 1;
1628 }
1629 
1630 // Initialize the per-collection-set information
1631 void G1CollectorPolicy::start_incremental_cset_building() {
1632   assert(_inc_cset_build_state == Inactive, "Precondition");
1633 
1634   _inc_cset_head = NULL;
1635   _inc_cset_tail = NULL;
1636   _inc_cset_bytes_used_before = 0;
1637 
1638   _inc_cset_max_finger = 0;
1639   _inc_cset_recorded_rs_lengths = 0;
1640   _inc_cset_recorded_rs_lengths_diffs = 0;
1641   _inc_cset_predicted_elapsed_time_ms = 0.0;
1642   _inc_cset_predicted_elapsed_time_ms_diffs = 0.0;
1643   _inc_cset_build_state = Active;
1644 }


1734 
1735 void G1CollectorPolicy::add_region_to_incremental_cset_common(HeapRegion* hr) {
1736   assert(hr->is_young(), "invariant");
1737   assert(hr->young_index_in_cset() > -1, "should have already been set");
1738   assert(_inc_cset_build_state == Active, "Precondition");
1739 
1740   // We need to clear and set the cached recorded/cached collection set
1741   // information in the heap region here (before the region gets added
1742   // to the collection set). An individual heap region's cached values
1743   // are calculated, aggregated with the policy collection set info,
1744   // and cached in the heap region here (initially) and (subsequently)
1745   // by the Young List sampling code.
1746 
1747   size_t rs_length = hr->rem_set()->occupied();
1748   add_to_incremental_cset_info(hr, rs_length);
1749 
1750   HeapWord* hr_end = hr->end();
1751   _inc_cset_max_finger = MAX2(_inc_cset_max_finger, hr_end);
1752 
1753   assert(!hr->in_collection_set(), "invariant");
1754   hr->set_in_collection_set(true);
1755   assert( hr->next_in_collection_set() == NULL, "invariant");
1756 
1757   _g1->register_young_region_with_in_cset_fast_test(hr);

1758 }
1759 
1760 // Add the region at the RHS of the incremental cset
1761 void G1CollectorPolicy::add_region_to_incremental_cset_rhs(HeapRegion* hr) {
1762   // We should only ever be appending survivors at the end of a pause
1763   assert(hr->is_survivor(), "Logic");
1764 
1765   // Do the 'common' stuff
1766   add_region_to_incremental_cset_common(hr);
1767 
1768   // Now add the region at the right hand side
1769   if (_inc_cset_tail == NULL) {
1770     assert(_inc_cset_head == NULL, "invariant");
1771     _inc_cset_head = hr;
1772   } else {
1773     _inc_cset_tail->set_next_in_collection_set(hr);
1774   }
1775   _inc_cset_tail = hr;
1776 }
1777 




1600   _collectionSetChooser->prepare_for_par_region_addition(n_regions, chunk_size);
1601   ParKnownGarbageTask par_known_garbage_task(_collectionSetChooser, chunk_size, n_workers);
1602   _g1->workers()->run_task(&par_known_garbage_task);
1603 
1604   _collectionSetChooser->sort_regions();
1605 
1606   double end_sec = os::elapsedTime();
1607   double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
1608   _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
1609   _cur_mark_stop_world_time_ms += elapsed_time_ms;
1610   _prev_collection_pause_end_ms += elapsed_time_ms;
1611   _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_sec, true);
1612 }
1613 
1614 // Add the heap region at the head of the non-incremental collection set
1615 void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) {
1616   assert(_inc_cset_build_state == Active, "Precondition");
1617   assert(hr->is_old(), "the region should be old");
1618 
1619   assert(!hr->in_collection_set(), "should not already be in the CSet");
1620   _g1->register_old_region_with_in_cset_fast_test(hr);
1621   hr->set_next_in_collection_set(_collection_set);
1622   _collection_set = hr;
1623   _collection_set_bytes_used_before += hr->used();

1624   size_t rs_length = hr->rem_set()->occupied();
1625   _recorded_rs_lengths += rs_length;
1626   _old_cset_region_length += 1;
1627 }
1628 
1629 // Initialize the per-collection-set information
1630 void G1CollectorPolicy::start_incremental_cset_building() {
1631   assert(_inc_cset_build_state == Inactive, "Precondition");
1632 
1633   _inc_cset_head = NULL;
1634   _inc_cset_tail = NULL;
1635   _inc_cset_bytes_used_before = 0;
1636 
1637   _inc_cset_max_finger = 0;
1638   _inc_cset_recorded_rs_lengths = 0;
1639   _inc_cset_recorded_rs_lengths_diffs = 0;
1640   _inc_cset_predicted_elapsed_time_ms = 0.0;
1641   _inc_cset_predicted_elapsed_time_ms_diffs = 0.0;
1642   _inc_cset_build_state = Active;
1643 }


1733 
1734 void G1CollectorPolicy::add_region_to_incremental_cset_common(HeapRegion* hr) {
1735   assert(hr->is_young(), "invariant");
1736   assert(hr->young_index_in_cset() > -1, "should have already been set");
1737   assert(_inc_cset_build_state == Active, "Precondition");
1738 
1739   // We need to clear and set the cached recorded/cached collection set
1740   // information in the heap region here (before the region gets added
1741   // to the collection set). An individual heap region's cached values
1742   // are calculated, aggregated with the policy collection set info,
1743   // and cached in the heap region here (initially) and (subsequently)
1744   // by the Young List sampling code.
1745 
1746   size_t rs_length = hr->rem_set()->occupied();
1747   add_to_incremental_cset_info(hr, rs_length);
1748 
1749   HeapWord* hr_end = hr->end();
1750   _inc_cset_max_finger = MAX2(_inc_cset_max_finger, hr_end);
1751 
1752   assert(!hr->in_collection_set(), "invariant");



1753   _g1->register_young_region_with_in_cset_fast_test(hr);
1754   assert( hr->next_in_collection_set() == NULL, "invariant");
1755 }
1756 
1757 // Add the region at the RHS of the incremental cset
1758 void G1CollectorPolicy::add_region_to_incremental_cset_rhs(HeapRegion* hr) {
1759   // We should only ever be appending survivors at the end of a pause
1760   assert(hr->is_survivor(), "Logic");
1761 
1762   // Do the 'common' stuff
1763   add_region_to_incremental_cset_common(hr);
1764 
1765   // Now add the region at the right hand side
1766   if (_inc_cset_tail == NULL) {
1767     assert(_inc_cset_head == NULL, "invariant");
1768     _inc_cset_head = hr;
1769   } else {
1770     _inc_cset_tail->set_next_in_collection_set(hr);
1771   }
1772   _inc_cset_tail = hr;
1773 }
1774 


< prev index next >