43 #include "gc/g1/heapRegion.inline.hpp"
44 #include "gc/g1/heapRegionRemSet.hpp"
45 #include "gc/shared/concurrentGCBreakpoints.hpp"
46 #include "gc/shared/gcPolicyCounters.hpp"
47 #include "logging/log.hpp"
48 #include "runtime/arguments.hpp"
49 #include "runtime/java.hpp"
50 #include "runtime/mutexLocker.hpp"
51 #include "utilities/debug.hpp"
52 #include "utilities/growableArray.hpp"
53 #include "utilities/pair.hpp"
54
55 G1Policy::G1Policy(STWGCTimer* gc_timer) :
56 _predictor(G1ConfidencePercent / 100.0),
57 _analytics(new G1Analytics(&_predictor)),
58 _remset_tracker(),
59 _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
60 _ihop_control(create_ihop_control(&_predictor)),
61 _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
62 _full_collection_start_sec(0.0),
63 _collection_pause_end_millis(os::javaTimeNanos() / NANOSECS_PER_MILLISEC),
64 _young_list_target_length(0),
65 _young_list_fixed_length(0),
66 _young_list_max_length(0),
67 _eden_surv_rate_group(new G1SurvRateGroup()),
68 _survivor_surv_rate_group(new G1SurvRateGroup()),
69 _reserve_factor((double) G1ReservePercent / 100.0),
70 _reserve_regions(0),
71 _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
72 _free_regions_at_end_of_collection(0),
73 _rs_length(0),
74 _rs_length_prediction(0),
75 _pending_cards_at_gc_start(0),
76 _old_gen_alloc_tracker(),
77 _concurrent_start_to_mixed(),
78 _collection_set(NULL),
79 _g1h(NULL),
80 _phase_times_timer(gc_timer),
81 _phase_times(NULL),
82 _mark_remark_start_sec(0),
83 _mark_cleanup_start_sec(0),
630 // This may happen if there are duplicate cards in different log buffers.
631 if (logged_dirty_cards > scan_heap_roots_cards) {
632 return all_cards_processing_time + average_time_ms(G1GCPhaseTimes::MergeLB);
633 }
634 return (all_cards_processing_time * logged_dirty_cards / scan_heap_roots_cards) + average_time_ms(G1GCPhaseTimes::MergeLB);
635 }
636
637 // Anything below that is considered to be zero
638 #define MIN_TIMER_GRANULARITY 0.0000001
639
640 void G1Policy::record_collection_pause_end(double pause_time_ms) {
641 G1GCPhaseTimes* p = phase_times();
642
643 double end_time_sec = os::elapsedTime();
644
645 PauseKind this_pause = young_gc_pause_kind();
646
647 bool update_stats = !_g1h->evacuation_failed();
648
649 record_pause(this_pause, end_time_sec - pause_time_ms / 1000.0, end_time_sec);
650
651 _collection_pause_end_millis = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
652
653 if (is_concurrent_start_pause(this_pause)) {
654 record_concurrent_mark_init_end(0.0);
655 } else {
656 maybe_start_marking();
657 }
658
659 double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms());
660 if (app_time_ms < MIN_TIMER_GRANULARITY) {
661 // This usually happens due to the timer not having the required
662 // granularity. Some Linuxes are the usual culprits.
663 // We'll just set it to something (arbitrarily) small.
664 app_time_ms = 1.0;
665 }
666
667 if (update_stats) {
668 // We maintain the invariant that all objects allocated by mutator
669 // threads will be allocated out of eden regions. So, we can use
670 // the eden region number allocated since the previous GC to
671 // calculate the application's allocate rate. The only exception
|
43 #include "gc/g1/heapRegion.inline.hpp"
44 #include "gc/g1/heapRegionRemSet.hpp"
45 #include "gc/shared/concurrentGCBreakpoints.hpp"
46 #include "gc/shared/gcPolicyCounters.hpp"
47 #include "logging/log.hpp"
48 #include "runtime/arguments.hpp"
49 #include "runtime/java.hpp"
50 #include "runtime/mutexLocker.hpp"
51 #include "utilities/debug.hpp"
52 #include "utilities/growableArray.hpp"
53 #include "utilities/pair.hpp"
54
55 G1Policy::G1Policy(STWGCTimer* gc_timer) :
56 _predictor(G1ConfidencePercent / 100.0),
57 _analytics(new G1Analytics(&_predictor)),
58 _remset_tracker(),
59 _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
60 _ihop_control(create_ihop_control(&_predictor)),
61 _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
62 _full_collection_start_sec(0.0),
63 _young_list_target_length(0),
64 _young_list_fixed_length(0),
65 _young_list_max_length(0),
66 _eden_surv_rate_group(new G1SurvRateGroup()),
67 _survivor_surv_rate_group(new G1SurvRateGroup()),
68 _reserve_factor((double) G1ReservePercent / 100.0),
69 _reserve_regions(0),
70 _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
71 _free_regions_at_end_of_collection(0),
72 _rs_length(0),
73 _rs_length_prediction(0),
74 _pending_cards_at_gc_start(0),
75 _old_gen_alloc_tracker(),
76 _concurrent_start_to_mixed(),
77 _collection_set(NULL),
78 _g1h(NULL),
79 _phase_times_timer(gc_timer),
80 _phase_times(NULL),
81 _mark_remark_start_sec(0),
82 _mark_cleanup_start_sec(0),
629 // This may happen if there are duplicate cards in different log buffers.
630 if (logged_dirty_cards > scan_heap_roots_cards) {
631 return all_cards_processing_time + average_time_ms(G1GCPhaseTimes::MergeLB);
632 }
633 return (all_cards_processing_time * logged_dirty_cards / scan_heap_roots_cards) + average_time_ms(G1GCPhaseTimes::MergeLB);
634 }
635
636 // Anything below that is considered to be zero
637 #define MIN_TIMER_GRANULARITY 0.0000001
638
639 void G1Policy::record_collection_pause_end(double pause_time_ms) {
640 G1GCPhaseTimes* p = phase_times();
641
642 double end_time_sec = os::elapsedTime();
643
644 PauseKind this_pause = young_gc_pause_kind();
645
646 bool update_stats = !_g1h->evacuation_failed();
647
648 record_pause(this_pause, end_time_sec - pause_time_ms / 1000.0, end_time_sec);
649
650 if (is_concurrent_start_pause(this_pause)) {
651 record_concurrent_mark_init_end(0.0);
652 } else {
653 maybe_start_marking();
654 }
655
656 double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms());
657 if (app_time_ms < MIN_TIMER_GRANULARITY) {
658 // This usually happens due to the timer not having the required
659 // granularity. Some Linuxes are the usual culprits.
660 // We'll just set it to something (arbitrarily) small.
661 app_time_ms = 1.0;
662 }
663
664 if (update_stats) {
665 // We maintain the invariant that all objects allocated by mutator
666 // threads will be allocated out of eden regions. So, we can use
667 // the eden region number allocated since the previous GC to
668 // calculate the application's allocate rate. The only exception
|