src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc_implementation/parallelScavenge

src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp

Print this page
rev 5803 : 8028391: Make the Min/MaxHeapFreeRatio flags manageable
Summary: Made the flags Min- and MaxHeapFreeRatio manageable, and implemented support for these flags in ParallalGC.
Reviewed-by: sla, mgerdin, brutisso


 512           if (Verbose) {
 513             gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
 514               old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
 515           }
 516         }
 517 
 518 
 519         if (UsePerfData) {
 520           PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
 521           counters->update_old_eden_size(
 522             size_policy->calculated_eden_size_in_bytes());
 523           counters->update_old_promo_size(
 524             size_policy->calculated_promo_size_in_bytes());
 525           counters->update_old_capacity(old_gen->capacity_in_bytes());
 526           counters->update_young_capacity(young_gen->capacity_in_bytes());
 527           counters->update_survived(survived);
 528           counters->update_promoted(promoted);
 529           counters->update_survivor_overflowed(_survivor_overflow);
 530         }
 531 











 532         size_t survivor_limit =
 533           size_policy->max_survivor_size(young_gen->max_size());
 534         _tenuring_threshold =
 535           size_policy->compute_survivor_space_size_and_threshold(
 536                                                            _survivor_overflow,
 537                                                            _tenuring_threshold,
 538                                                            survivor_limit);
 539 
 540        if (PrintTenuringDistribution) {
 541          gclog_or_tty->cr();
 542          gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)",
 543                                 size_policy->calculated_survivor_size_in_bytes(),
 544                                 _tenuring_threshold, MaxTenuringThreshold);
 545        }
 546 
 547         if (UsePerfData) {
 548           PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
 549           counters->update_tenuring_threshold(_tenuring_threshold);
 550           counters->update_survivor_size_counters();
 551         }
 552 
 553         // Do call at minor collections?
 554         // Don't check if the size_policy is ready at this
 555         // level.  Let the size_policy check that internally.
 556         if (UseAdaptiveSizePolicy &&
 557             UseAdaptiveGenerationSizePolicyAtMinorCollection &&
 558             ((gc_cause != GCCause::_java_lang_system_gc) ||
 559               UseAdaptiveSizePolicyWithSystemGC)) {
 560 
 561           // Calculate optimial free space amounts
 562           assert(young_gen->max_size() >
 563             young_gen->from_space()->capacity_in_bytes() +
 564             young_gen->to_space()->capacity_in_bytes(),
 565             "Sizes of space in young gen are out-of-bounds");
 566 
 567           size_t young_live = young_gen->used_in_bytes();
 568           size_t eden_live = young_gen->eden_space()->used_in_bytes();
 569           size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
 570           size_t max_old_gen_size = old_gen->max_gen_size();
 571           size_t max_eden_size = young_gen->max_size() -
 572             young_gen->from_space()->capacity_in_bytes() -
 573             young_gen->to_space()->capacity_in_bytes();
 574 
 575           // Used for diagnostics
 576           size_policy->clear_generation_free_space_flags();
 577 
 578           size_policy->compute_eden_space_size(young_live,
 579                                                eden_live,
 580                                                cur_eden,
 581                                                max_eden_size,
 582                                                false /* not full gc*/);
 583 
 584           size_policy->check_gc_overhead_limit(young_live,
 585                                                eden_live,
 586                                                max_old_gen_size,
 587                                                max_eden_size,
 588                                                false /* not full gc*/,
 589                                                gc_cause,
 590                                                heap->collector_policy());
 591 




 512           if (Verbose) {
 513             gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
 514               old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
 515           }
 516         }
 517 
 518 
 519         if (UsePerfData) {
 520           PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
 521           counters->update_old_eden_size(
 522             size_policy->calculated_eden_size_in_bytes());
 523           counters->update_old_promo_size(
 524             size_policy->calculated_promo_size_in_bytes());
 525           counters->update_old_capacity(old_gen->capacity_in_bytes());
 526           counters->update_young_capacity(young_gen->capacity_in_bytes());
 527           counters->update_survived(survived);
 528           counters->update_promoted(promoted);
 529           counters->update_survivor_overflowed(_survivor_overflow);
 530         }
 531 
 532         size_t max_young_size = young_gen->max_size();
 533 
 534         // Deciding a free ratio in the young generation is tricky, so if
 535         // MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating
 536         // that the old generation size may have been limited because of them) we
 537         // should then limit our young generation size using NewRatio to have it
 538         // follow the old generation size.
 539         if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) {
 540           max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size());
 541         }
 542 
 543         size_t survivor_limit =
 544           size_policy->max_survivor_size(max_young_size);
 545         _tenuring_threshold =
 546           size_policy->compute_survivor_space_size_and_threshold(
 547                                                            _survivor_overflow,
 548                                                            _tenuring_threshold,
 549                                                            survivor_limit);
 550 
 551        if (PrintTenuringDistribution) {
 552          gclog_or_tty->cr();
 553          gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)",
 554                                 size_policy->calculated_survivor_size_in_bytes(),
 555                                 _tenuring_threshold, MaxTenuringThreshold);
 556        }
 557 
 558         if (UsePerfData) {
 559           PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
 560           counters->update_tenuring_threshold(_tenuring_threshold);
 561           counters->update_survivor_size_counters();
 562         }
 563 
 564         // Do call at minor collections?
 565         // Don't check if the size_policy is ready at this
 566         // level.  Let the size_policy check that internally.
 567         if (UseAdaptiveGenerationSizePolicyAtMinorCollection &&

 568             ((gc_cause != GCCause::_java_lang_system_gc) ||
 569               UseAdaptiveSizePolicyWithSystemGC)) {
 570 
 571           // Calculate optimial free space amounts
 572           assert(young_gen->max_size() >
 573             young_gen->from_space()->capacity_in_bytes() +
 574             young_gen->to_space()->capacity_in_bytes(),
 575             "Sizes of space in young gen are out-of-bounds");
 576 
 577           size_t young_live = young_gen->used_in_bytes();
 578           size_t eden_live = young_gen->eden_space()->used_in_bytes();
 579           size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
 580           size_t max_old_gen_size = old_gen->max_gen_size();
 581           size_t max_eden_size = max_young_size -
 582             young_gen->from_space()->capacity_in_bytes() -
 583             young_gen->to_space()->capacity_in_bytes();
 584 
 585           // Used for diagnostics
 586           size_policy->clear_generation_free_space_flags();
 587 
 588           size_policy->compute_eden_space_size(young_live,
 589                                                eden_live,
 590                                                cur_eden,
 591                                                max_eden_size,
 592                                                false /* not full gc*/);
 593 
 594           size_policy->check_gc_overhead_limit(young_live,
 595                                                eden_live,
 596                                                max_old_gen_size,
 597                                                max_eden_size,
 598                                                false /* not full gc*/,
 599                                                gc_cause,
 600                                                heap->collector_policy());
 601 


src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File