Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 1286:ab75c83d7c37
Merge
author | johnc |
---|---|
date | Tue, 02 Mar 2010 13:57:46 -0800 |
parents | a1c410de27e4 |
children | 56507bcd639e |
comparison
equal
deleted
inserted
replaced
1281:7d236a9688c5 | 1286:ab75c83d7c37 |
---|---|
268 _concurrent_mark_init_times_ms->add(0.05); | 268 _concurrent_mark_init_times_ms->add(0.05); |
269 _concurrent_mark_remark_times_ms->add(0.05); | 269 _concurrent_mark_remark_times_ms->add(0.05); |
270 _concurrent_mark_cleanup_times_ms->add(0.20); | 270 _concurrent_mark_cleanup_times_ms->add(0.20); |
271 _tenuring_threshold = MaxTenuringThreshold; | 271 _tenuring_threshold = MaxTenuringThreshold; |
272 | 272 |
273 if (G1UseSurvivorSpaces) { | 273 // if G1FixedSurvivorSpaceSize is 0 which means the size is not |
274 // if G1FixedSurvivorSpaceSize is 0 which means the size is not | 274 // fixed, then _max_survivor_regions will be calculated at |
275 // fixed, then _max_survivor_regions will be calculated at | 275 // calculate_young_list_target_config during initialization |
276 // calculate_young_list_target_config during initialization | 276 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; |
277 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; | |
278 } else { | |
279 _max_survivor_regions = 0; | |
280 } | |
281 | 277 |
282 initialize_all(); | 278 initialize_all(); |
283 } | 279 } |
284 | 280 |
285 // Increment "i", mod "len" | 281 // Increment "i", mod "len" |
294 vm_exit_during_initialization("Invalid survivor ratio specified"); | 290 vm_exit_during_initialization("Invalid survivor ratio specified"); |
295 } | 291 } |
296 CollectorPolicy::initialize_flags(); | 292 CollectorPolicy::initialize_flags(); |
297 } | 293 } |
298 | 294 |
295 // The easiest way to deal with the parsing of the NewSize / | |
296 // MaxNewSize / etc. parameteres is to re-use the code in the | |
297 // TwoGenerationCollectorPolicy class. This is similar to what | |
298 // ParallelScavenge does with its GenerationSizer class (see | |
299 // ParallelScavengeHeap::initialize()). We might change this in the | |
300 // future, but it's a good start. | |
301 class G1YoungGenSizer : public TwoGenerationCollectorPolicy { | |
302 size_t size_to_region_num(size_t byte_size) { | |
303 return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); | |
304 } | |
305 | |
306 public: | |
307 G1YoungGenSizer() { | |
308 initialize_flags(); | |
309 initialize_size_info(); | |
310 } | |
311 | |
312 size_t min_young_region_num() { | |
313 return size_to_region_num(_min_gen0_size); | |
314 } | |
315 size_t initial_young_region_num() { | |
316 return size_to_region_num(_initial_gen0_size); | |
317 } | |
318 size_t max_young_region_num() { | |
319 return size_to_region_num(_max_gen0_size); | |
320 } | |
321 }; | |
322 | |
299 void G1CollectorPolicy::init() { | 323 void G1CollectorPolicy::init() { |
300 // Set aside an initial future to_space. | 324 // Set aside an initial future to_space. |
301 _g1 = G1CollectedHeap::heap(); | 325 _g1 = G1CollectedHeap::heap(); |
302 size_t regions = Universe::heap()->capacity() / HeapRegion::GrainBytes; | |
303 | 326 |
304 assert(Heap_lock->owned_by_self(), "Locking discipline."); | 327 assert(Heap_lock->owned_by_self(), "Locking discipline."); |
305 | |
306 if (G1SteadyStateUsed < 50) { | |
307 vm_exit_during_initialization("G1SteadyStateUsed must be at least 50%."); | |
308 } | |
309 | 328 |
310 initialize_gc_policy_counters(); | 329 initialize_gc_policy_counters(); |
311 | 330 |
312 if (G1Gen) { | 331 if (G1Gen) { |
313 _in_young_gc_mode = true; | 332 _in_young_gc_mode = true; |
314 | 333 |
315 if (G1YoungGenSize == 0) { | 334 G1YoungGenSizer sizer; |
335 size_t initial_region_num = sizer.initial_young_region_num(); | |
336 | |
337 if (UseAdaptiveSizePolicy) { | |
316 set_adaptive_young_list_length(true); | 338 set_adaptive_young_list_length(true); |
317 _young_list_fixed_length = 0; | 339 _young_list_fixed_length = 0; |
318 } else { | 340 } else { |
319 set_adaptive_young_list_length(false); | 341 set_adaptive_young_list_length(false); |
320 _young_list_fixed_length = (G1YoungGenSize / HeapRegion::GrainBytes); | 342 _young_list_fixed_length = initial_region_num; |
321 } | 343 } |
322 _free_regions_at_end_of_collection = _g1->free_regions(); | 344 _free_regions_at_end_of_collection = _g1->free_regions(); |
323 _scan_only_regions_at_end_of_collection = 0; | 345 _scan_only_regions_at_end_of_collection = 0; |
324 calculate_young_list_min_length(); | 346 calculate_young_list_min_length(); |
325 guarantee( _young_list_min_length == 0, "invariant, not enough info" ); | 347 guarantee( _young_list_min_length == 0, "invariant, not enough info" ); |
453 | 475 |
454 void G1CollectorPolicy::calculate_young_list_target_config(size_t rs_lengths) { | 476 void G1CollectorPolicy::calculate_young_list_target_config(size_t rs_lengths) { |
455 guarantee( adaptive_young_list_length(), "pre-condition" ); | 477 guarantee( adaptive_young_list_length(), "pre-condition" ); |
456 | 478 |
457 double start_time_sec = os::elapsedTime(); | 479 double start_time_sec = os::elapsedTime(); |
458 size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1MinReservePercent); | 480 size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1ReservePercent); |
459 min_reserve_perc = MIN2((size_t) 50, min_reserve_perc); | 481 min_reserve_perc = MIN2((size_t) 50, min_reserve_perc); |
460 size_t reserve_regions = | 482 size_t reserve_regions = |
461 (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0); | 483 (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0); |
462 | 484 |
463 if (full_young_gcs() && _free_regions_at_end_of_collection > 0) { | 485 if (full_young_gcs() && _free_regions_at_end_of_collection > 0) { |
1108 // do that for any other surv rate groups | 1130 // do that for any other surv rate groups |
1109 _short_lived_surv_rate_group->stop_adding_regions(); | 1131 _short_lived_surv_rate_group->stop_adding_regions(); |
1110 size_t short_lived_so_length = _young_list_so_prefix_length; | 1132 size_t short_lived_so_length = _young_list_so_prefix_length; |
1111 _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length); | 1133 _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length); |
1112 tag_scan_only(short_lived_so_length); | 1134 tag_scan_only(short_lived_so_length); |
1113 | 1135 _survivors_age_table.clear(); |
1114 if (G1UseSurvivorSpaces) { | |
1115 _survivors_age_table.clear(); | |
1116 } | |
1117 | 1136 |
1118 assert( verify_young_ages(), "region age verification" ); | 1137 assert( verify_young_ages(), "region age verification" ); |
1119 } | 1138 } |
1120 | 1139 |
1121 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) { | 1140 void G1CollectorPolicy::tag_scan_only(size_t short_lived_scan_only_length) { |
1430 last_pause_included_initial_mark = _should_initiate_conc_mark; | 1449 last_pause_included_initial_mark = _should_initiate_conc_mark; |
1431 if (last_pause_included_initial_mark) | 1450 if (last_pause_included_initial_mark) |
1432 record_concurrent_mark_init_end_pre(0.0); | 1451 record_concurrent_mark_init_end_pre(0.0); |
1433 | 1452 |
1434 size_t min_used_targ = | 1453 size_t min_used_targ = |
1435 (_g1->capacity() / 100) * (G1SteadyStateUsed - G1SteadyStateUsedDelta); | 1454 (_g1->capacity() / 100) * InitiatingHeapOccupancyPercent; |
1436 | 1455 |
1437 if (cur_used_bytes > min_used_targ) { | 1456 if (cur_used_bytes > min_used_targ) { |
1438 if (cur_used_bytes <= _prev_collection_pause_used_at_end_bytes) { | 1457 if (cur_used_bytes <= _prev_collection_pause_used_at_end_bytes) { |
1439 } else if (!_g1->mark_in_progress() && !_last_full_young_gc) { | 1458 } else if (!_g1->mark_in_progress() && !_last_full_young_gc) { |
1440 _should_initiate_conc_mark = true; | 1459 _should_initiate_conc_mark = true; |
1914 _scan_only_regions_at_end_of_collection = _g1->young_list_length(); | 1933 _scan_only_regions_at_end_of_collection = _g1->young_list_length(); |
1915 calculate_young_list_min_length(); | 1934 calculate_young_list_min_length(); |
1916 calculate_young_list_target_config(); | 1935 calculate_young_list_target_config(); |
1917 | 1936 |
1918 // Note that _mmu_tracker->max_gc_time() returns the time in seconds. | 1937 // Note that _mmu_tracker->max_gc_time() returns the time in seconds. |
1919 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSUpdatePauseFractionPercent / 100.0; | 1938 double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; |
1920 adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms); | 1939 adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms); |
1921 | 1940 |
1922 // </NEW PREDICTION> | 1941 // </NEW PREDICTION> |
1923 | 1942 |
1924 _target_pause_time_ms = -1.0; | 1943 _target_pause_time_ms = -1.0; |
1930 double update_rs_processed_buffers, | 1949 double update_rs_processed_buffers, |
1931 double goal_ms) { | 1950 double goal_ms) { |
1932 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | 1951 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
1933 ConcurrentG1Refine *cg1r = G1CollectedHeap::heap()->concurrent_g1_refine(); | 1952 ConcurrentG1Refine *cg1r = G1CollectedHeap::heap()->concurrent_g1_refine(); |
1934 | 1953 |
1935 if (G1AdaptiveConcRefine) { | 1954 if (G1UseAdaptiveConcRefinement) { |
1936 const int k_gy = 3, k_gr = 6; | 1955 const int k_gy = 3, k_gr = 6; |
1937 const double inc_k = 1.1, dec_k = 0.9; | 1956 const double inc_k = 1.1, dec_k = 0.9; |
1938 | 1957 |
1939 int g = cg1r->green_zone(); | 1958 int g = cg1r->green_zone(); |
1940 if (update_rs_time > goal_ms) { | 1959 if (update_rs_time > goal_ms) { |
2605 } | 2624 } |
2606 | 2625 |
2607 // Calculates survivor space parameters. | 2626 // Calculates survivor space parameters. |
2608 void G1CollectorPolicy::calculate_survivors_policy() | 2627 void G1CollectorPolicy::calculate_survivors_policy() |
2609 { | 2628 { |
2610 if (!G1UseSurvivorSpaces) { | |
2611 return; | |
2612 } | |
2613 if (G1FixedSurvivorSpaceSize == 0) { | 2629 if (G1FixedSurvivorSpaceSize == 0) { |
2614 _max_survivor_regions = _young_list_target_length / SurvivorRatio; | 2630 _max_survivor_regions = _young_list_target_length / SurvivorRatio; |
2615 } else { | 2631 } else { |
2616 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; | 2632 _max_survivor_regions = G1FixedSurvivorSpaceSize / HeapRegion::GrainBytes; |
2617 } | 2633 } |
2626 | 2642 |
2627 bool | 2643 bool |
2628 G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t | 2644 G1CollectorPolicy_BestRegionsFirst::should_do_collection_pause(size_t |
2629 word_size) { | 2645 word_size) { |
2630 assert(_g1->regions_accounted_for(), "Region leakage!"); | 2646 assert(_g1->regions_accounted_for(), "Region leakage!"); |
2631 // Initiate a pause when we reach the steady-state "used" target. | |
2632 size_t used_hard = (_g1->capacity() / 100) * G1SteadyStateUsed; | |
2633 size_t used_soft = | |
2634 MAX2((_g1->capacity() / 100) * (G1SteadyStateUsed - G1SteadyStateUsedDelta), | |
2635 used_hard/2); | |
2636 size_t used = _g1->used(); | |
2637 | |
2638 double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; | 2647 double max_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; |
2639 | 2648 |
2640 size_t young_list_length = _g1->young_list_length(); | 2649 size_t young_list_length = _g1->young_list_length(); |
2641 size_t young_list_max_length = _young_list_target_length; | 2650 size_t young_list_max_length = _young_list_target_length; |
2642 if (G1FixedEdenSize) { | 2651 if (G1FixedEdenSize) { |
2865 | 2874 |
2866 // Add the heap region to the collection set and return the conservative | 2875 // Add the heap region to the collection set and return the conservative |
2867 // estimate of the number of live bytes. | 2876 // estimate of the number of live bytes. |
2868 void G1CollectorPolicy:: | 2877 void G1CollectorPolicy:: |
2869 add_to_collection_set(HeapRegion* hr) { | 2878 add_to_collection_set(HeapRegion* hr) { |
2870 if (G1PrintRegions) { | 2879 if (G1PrintHeapRegions) { |
2871 gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], " | 2880 gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], " |
2872 "top "PTR_FORMAT", young %s", | 2881 "top "PTR_FORMAT", young %s", |
2873 hr->hrs_index(), hr->bottom(), hr->end(), | 2882 hr->hrs_index(), hr->bottom(), hr->end(), |
2874 hr->top(), (hr->is_young()) ? "YES" : "NO"); | 2883 hr->top(), (hr->is_young()) ? "YES" : "NO"); |
2875 } | 2884 } |