comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 889:15c5903cf9e1

6865703: G1: Parallelize hot card cache cleanup Summary: Have the GC worker threads clear the hot card cache in parallel by having each worker thread claim a chunk of the card cache and process the cards in that chunk. The size of the chunks that each thread will claim is determined at VM initialization from the size of the card cache and the number of worker threads. Reviewed-by: jmasa, tonyp
author johnc
date Mon, 03 Aug 2009 12:59:30 -0700
parents 83b687ce3090
children 6cb8e9df7174
comparison
equal deleted inserted replaced
888:59726d16b30d 889:15c5903cf9e1
1635 return _g1_committed.byte_size(); 1635 return _g1_committed.byte_size();
1636 } 1636 }
1637 1637
1638 void G1CollectedHeap::iterate_dirty_card_closure(bool concurrent, 1638 void G1CollectedHeap::iterate_dirty_card_closure(bool concurrent,
1639 int worker_i) { 1639 int worker_i) {
1640 // Clean cards in the hot card cache
1641 concurrent_g1_refine()->clean_up_cache(worker_i, g1_rem_set());
1642
1640 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 1643 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
1641 int n_completed_buffers = 0; 1644 int n_completed_buffers = 0;
1642 while (dcqs.apply_closure_to_completed_buffer(worker_i, 0, true)) { 1645 while (dcqs.apply_closure_to_completed_buffer(worker_i, 0, true)) {
1643 n_completed_buffers++; 1646 n_completed_buffers++;
1644 } 1647 }
1645 g1_policy()->record_update_rs_processed_buffers(worker_i, 1648 g1_policy()->record_update_rs_processed_buffers(worker_i,
1646 (double) n_completed_buffers); 1649 (double) n_completed_buffers);
1647 dcqs.clear_n_completed_buffers(); 1650 dcqs.clear_n_completed_buffers();
1648 // Finish up the queue...
1649 if (worker_i == 0) concurrent_g1_refine()->clean_up_cache(worker_i,
1650 g1_rem_set());
1651 assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!"); 1651 assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!");
1652 } 1652 }
1653 1653
1654 1654
1655 // Computes the sum of the storage used by the various regions. 1655 // Computes the sum of the storage used by the various regions.
4109 void G1CollectedHeap::evacuate_collection_set() { 4109 void G1CollectedHeap::evacuate_collection_set() {
4110 set_evacuation_failed(false); 4110 set_evacuation_failed(false);
4111 4111
4112 g1_rem_set()->prepare_for_oops_into_collection_set_do(); 4112 g1_rem_set()->prepare_for_oops_into_collection_set_do();
4113 concurrent_g1_refine()->set_use_cache(false); 4113 concurrent_g1_refine()->set_use_cache(false);
4114 concurrent_g1_refine()->clear_hot_cache_claimed_index();
4115
4114 int n_workers = (ParallelGCThreads > 0 ? workers()->total_workers() : 1); 4116 int n_workers = (ParallelGCThreads > 0 ? workers()->total_workers() : 1);
4115 set_par_threads(n_workers); 4117 set_par_threads(n_workers);
4116 G1ParTask g1_par_task(this, n_workers, _task_queues); 4118 G1ParTask g1_par_task(this, n_workers, _task_queues);
4117 4119
4118 init_for_evac_failure(NULL); 4120 init_for_evac_failure(NULL);
4141 G1KeepAliveClosure keep_alive(this); 4143 G1KeepAliveClosure keep_alive(this);
4142 JNIHandles::weak_oops_do(&is_alive, &keep_alive); 4144 JNIHandles::weak_oops_do(&is_alive, &keep_alive);
4143 } 4145 }
4144 g1_rem_set()->cleanup_after_oops_into_collection_set_do(); 4146 g1_rem_set()->cleanup_after_oops_into_collection_set_do();
4145 4147
4148 concurrent_g1_refine()->clear_hot_cache();
4146 concurrent_g1_refine()->set_use_cache(true); 4149 concurrent_g1_refine()->set_use_cache(true);
4147 4150
4148 finalize_for_evac_failure(); 4151 finalize_for_evac_failure();
4149 4152
4150 // Must do this before removing self-forwarding pointers, which clears 4153 // Must do this before removing self-forwarding pointers, which clears