< prev index next >

src/hotspot/share/gc/shared/genCollectedHeap.cpp

Print this page
rev 52941 : 8215221: Serial GC misreports young GC time
Reported-by: XXX


 558   }
 559 
 560   GCIdMark gc_id_mark;
 561 
 562   const bool do_clear_all_soft_refs = clear_all_soft_refs ||
 563                           soft_ref_policy()->should_clear_all_soft_refs();
 564 
 565   ClearedAllSoftRefs casr(do_clear_all_soft_refs, soft_ref_policy());
 566 
 567   const size_t metadata_prev_used = MetaspaceUtils::used_bytes();
 568 
 569   print_heap_before_gc();
 570 
 571   {
 572     FlagSetting fl(_is_gc_active, true);
 573 
 574     bool complete = full && (max_generation == OldGen);
 575     bool old_collects_young = complete && !ScavengeBeforeFullGC;
 576     bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
 577 
 578     FormatBuffer<> gc_string("%s", "Pause ");
 579     if (do_young_collection) {
 580       gc_string.append("Young");
 581     } else {
 582       gc_string.append("Full");
 583     }
 584 
 585     GCTraceCPUTime tcpu;
 586     GCTraceTime(Info, gc) t(gc_string, NULL, gc_cause(), true);
 587 
 588     gc_prologue(complete);
 589     increment_total_collections(complete);
 590 
 591     size_t young_prev_used = _young_gen->used();
 592     size_t old_prev_used = _old_gen->used();
 593 
 594     bool run_verification = total_collections() >= VerifyGCStartAt;
 595 
 596     bool prepared_for_verification = false;
 597     bool collected_old = false;
 598 
 599     if (do_young_collection) {
 600       if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) {
 601         prepare_for_verify();
 602         prepared_for_verification = true;
 603       }
 604 


 605       collect_generation(_young_gen,
 606                          full,
 607                          size,
 608                          is_tlab,
 609                          run_verification && VerifyGCLevel <= 0,
 610                          do_clear_all_soft_refs,
 611                          false);
 612 
 613       if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) &&
 614           size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) {
 615         // Allocation request was met by young GC.
 616         size = 0;
 617       }
 618     }
 619 
 620     bool must_restore_marks_for_biased_locking = false;
 621 
 622     if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
 623       if (!complete) {
 624         // The full_collections increment was missed above.
 625         increment_total_full_collections();
 626       }
 627 
 628       if (!prepared_for_verification && run_verification &&
 629           VerifyGCLevel <= 1 && VerifyBeforeGC) {
 630         prepare_for_verify();
 631       }
 632 
 633       if (do_young_collection) {
 634         // We did a young GC. Need a new GC id for the old GC.
 635         GCIdMark gc_id_mark;
 636         GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
 637         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 638       } else {
 639         // No young GC done. Use the same GC id as was set up earlier in this method.

 640         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 641       }
 642 
 643       must_restore_marks_for_biased_locking = true;
 644       collected_old = true;
 645     }
 646 
 647     // Update "complete" boolean wrt what actually transpired --
 648     // for instance, a promotion failure could have led to
 649     // a whole heap collection.
 650     complete = complete || collected_old;
 651 
 652     // Adjust generation sizes.
 653     if (collected_old) {
 654       _old_gen->compute_new_size();
 655     }
 656     _young_gen->compute_new_size();
 657 
 658     if (complete) {
 659       // Delete metaspaces for unloaded class loaders and clean up loader_data graph




 558   }
 559 
 560   GCIdMark gc_id_mark;
 561 
 562   const bool do_clear_all_soft_refs = clear_all_soft_refs ||
 563                           soft_ref_policy()->should_clear_all_soft_refs();
 564 
 565   ClearedAllSoftRefs casr(do_clear_all_soft_refs, soft_ref_policy());
 566 
 567   const size_t metadata_prev_used = MetaspaceUtils::used_bytes();
 568 
 569   print_heap_before_gc();
 570 
 571   {
 572     FlagSetting fl(_is_gc_active, true);
 573 
 574     bool complete = full && (max_generation == OldGen);
 575     bool old_collects_young = complete && !ScavengeBeforeFullGC;
 576     bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab);
 577 







 578     GCTraceCPUTime tcpu;

 579 
 580     gc_prologue(complete);
 581     increment_total_collections(complete);
 582 
 583     size_t young_prev_used = _young_gen->used();
 584     size_t old_prev_used = _old_gen->used();
 585 
 586     bool run_verification = total_collections() >= VerifyGCStartAt;
 587 
 588     bool prepared_for_verification = false;
 589     bool collected_old = false;
 590 
 591     if (do_young_collection) {
 592       if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) {
 593         prepare_for_verify();
 594         prepared_for_verification = true;
 595       }
 596 
 597       GCTraceTime(Info, gc) t("Pause Young", NULL, gc_cause(), true);
 598 
 599       collect_generation(_young_gen,
 600                          full,
 601                          size,
 602                          is_tlab,
 603                          run_verification && VerifyGCLevel <= 0,
 604                          do_clear_all_soft_refs,
 605                          false);
 606 
 607       if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) &&
 608           size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) {
 609         // Allocation request was met by young GC.
 610         size = 0;
 611       }
 612     }
 613 
 614     bool must_restore_marks_for_biased_locking = false;
 615 
 616     if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) {
 617       if (!complete) {
 618         // The full_collections increment was missed above.
 619         increment_total_full_collections();
 620       }
 621 
 622       if (!prepared_for_verification && run_verification &&
 623           VerifyGCLevel <= 1 && VerifyBeforeGC) {
 624         prepare_for_verify();
 625       }
 626 
 627       if (do_young_collection) {
 628         // We did a young GC. Need a new GC id for the old GC.
 629         GCIdMark gc_id_mark;
 630         GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
 631         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 632       } else {
 633         // No young GC done. Use the same GC id as was set up earlier in this method.
 634         GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true);
 635         collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true);
 636       }
 637 
 638       must_restore_marks_for_biased_locking = true;
 639       collected_old = true;
 640     }
 641 
 642     // Update "complete" boolean wrt what actually transpired --
 643     // for instance, a promotion failure could have led to
 644     // a whole heap collection.
 645     complete = complete || collected_old;
 646 
 647     // Adjust generation sizes.
 648     if (collected_old) {
 649       _old_gen->compute_new_size();
 650     }
 651     _young_gen->compute_new_size();
 652 
 653     if (complete) {
 654       // Delete metaspaces for unloaded class loaders and clean up loader_data graph


< prev index next >