< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp

Print this page




  75   int sleep = ShenandoahControlIntervalMin;
  76 
  77   double last_shrink_time = os::elapsedTime();
  78   double last_sleep_adjust_time = os::elapsedTime();
  79 
  80   // Shrink period avoids constantly polling regions for shrinking.
  81   // Having a period 10x lower than the delay would mean we hit the
  82   // shrinking with lag of less than 1/10-th of true delay.
  83   // ShenandoahUncommitDelay is in msecs, but shrink_period is in seconds.
  84   double shrink_period = (double)ShenandoahUncommitDelay / 1000 / 10;
  85 
  86   ShenandoahCollectorPolicy* policy = heap->shenandoah_policy();
  87   ShenandoahHeuristics* heuristics = heap->heuristics();
  88   while (!in_graceful_shutdown() && !should_terminate()) {
  89     // Figure out if we have pending requests.
  90     bool alloc_failure_pending = _alloc_failure_gc.is_set();
  91     bool explicit_gc_requested = _gc_requested.is_set() &&  is_explicit_gc(_requested_gc_cause);
  92     bool implicit_gc_requested = _gc_requested.is_set() && !is_explicit_gc(_requested_gc_cause);
  93 
  94     // This control loop iteration have seen this much allocations.
  95     size_t allocs_seen = Atomic::xchg<size_t>(0, &_allocs_seen);
  96 
  97     // Choose which GC mode to run in. The block below should select a single mode.
  98     GCMode mode = none;
  99     GCCause::Cause cause = GCCause::_last_gc_cause;
 100     ShenandoahHeap::ShenandoahDegenPoint degen_point = ShenandoahHeap::_degenerated_unset;
 101 
 102     if (alloc_failure_pending) {
 103       // Allocation failure takes precedence: we have to deal with it first thing
 104       log_info(gc)("Trigger: Handle Allocation Failure");
 105 
 106       cause = GCCause::_allocation_failure;
 107 
 108       // Consume the degen point, and seed it with default value
 109       degen_point = _degen_point;
 110       _degen_point = ShenandoahHeap::_degenerated_outside_cycle;
 111 
 112       if (ShenandoahDegeneratedGC && heuristics->should_degenerate_cycle()) {
 113         heuristics->record_allocation_failure_gc();
 114         policy->record_alloc_failure_to_degenerated(degen_point);
 115         mode = stw_degenerated;


 576     ShenandoahHeap::heap()->monitoring_support()->update_counters();
 577   }
 578 }
 579 
 580 void ShenandoahControlThread::notify_heap_changed() {
 581   // This is called from allocation path, and thus should be fast.
 582 
 583   // Update monitoring counters when we took a new region. This amortizes the
 584   // update costs on slow path.
 585   if (_do_counters_update.is_unset()) {
 586     _do_counters_update.set();
 587   }
 588   // Notify that something had changed.
 589   if (_heap_changed.is_unset()) {
 590     _heap_changed.set();
 591   }
 592 }
 593 
 594 void ShenandoahControlThread::pacing_notify_alloc(size_t words) {
 595   assert(ShenandoahPacing, "should only call when pacing is enabled");
 596   Atomic::add(words, &_allocs_seen);
 597 }
 598 
 599 void ShenandoahControlThread::set_forced_counters_update(bool value) {
 600   _force_counters_update.set_cond(value);
 601 }
 602 
 603 void ShenandoahControlThread::print() const {
 604   print_on(tty);
 605 }
 606 
 607 void ShenandoahControlThread::print_on(outputStream* st) const {
 608   st->print("Shenandoah Concurrent Thread");
 609   Thread::print_on(st);
 610   st->cr();
 611 }
 612 
 613 void ShenandoahControlThread::start() {
 614   create_and_start();
 615 }
 616 


  75   int sleep = ShenandoahControlIntervalMin;
  76 
  77   double last_shrink_time = os::elapsedTime();
  78   double last_sleep_adjust_time = os::elapsedTime();
  79 
  80   // Shrink period avoids constantly polling regions for shrinking.
  81   // Having a period 10x lower than the delay would mean we hit the
  82   // shrinking with lag of less than 1/10-th of true delay.
  83   // ShenandoahUncommitDelay is in msecs, but shrink_period is in seconds.
  84   double shrink_period = (double)ShenandoahUncommitDelay / 1000 / 10;
  85 
  86   ShenandoahCollectorPolicy* policy = heap->shenandoah_policy();
  87   ShenandoahHeuristics* heuristics = heap->heuristics();
  88   while (!in_graceful_shutdown() && !should_terminate()) {
  89     // Figure out if we have pending requests.
  90     bool alloc_failure_pending = _alloc_failure_gc.is_set();
  91     bool explicit_gc_requested = _gc_requested.is_set() &&  is_explicit_gc(_requested_gc_cause);
  92     bool implicit_gc_requested = _gc_requested.is_set() && !is_explicit_gc(_requested_gc_cause);
  93 
  94     // This control loop iteration have seen this much allocations.
  95     size_t allocs_seen = Atomic::xchg(&_allocs_seen, (size_t)0);
  96 
  97     // Choose which GC mode to run in. The block below should select a single mode.
  98     GCMode mode = none;
  99     GCCause::Cause cause = GCCause::_last_gc_cause;
 100     ShenandoahHeap::ShenandoahDegenPoint degen_point = ShenandoahHeap::_degenerated_unset;
 101 
 102     if (alloc_failure_pending) {
 103       // Allocation failure takes precedence: we have to deal with it first thing
 104       log_info(gc)("Trigger: Handle Allocation Failure");
 105 
 106       cause = GCCause::_allocation_failure;
 107 
 108       // Consume the degen point, and seed it with default value
 109       degen_point = _degen_point;
 110       _degen_point = ShenandoahHeap::_degenerated_outside_cycle;
 111 
 112       if (ShenandoahDegeneratedGC && heuristics->should_degenerate_cycle()) {
 113         heuristics->record_allocation_failure_gc();
 114         policy->record_alloc_failure_to_degenerated(degen_point);
 115         mode = stw_degenerated;


 576     ShenandoahHeap::heap()->monitoring_support()->update_counters();
 577   }
 578 }
 579 
 580 void ShenandoahControlThread::notify_heap_changed() {
 581   // This is called from allocation path, and thus should be fast.
 582 
 583   // Update monitoring counters when we took a new region. This amortizes the
 584   // update costs on slow path.
 585   if (_do_counters_update.is_unset()) {
 586     _do_counters_update.set();
 587   }
 588   // Notify that something had changed.
 589   if (_heap_changed.is_unset()) {
 590     _heap_changed.set();
 591   }
 592 }
 593 
 594 void ShenandoahControlThread::pacing_notify_alloc(size_t words) {
 595   assert(ShenandoahPacing, "should only call when pacing is enabled");
 596   Atomic::add(&_allocs_seen, words);
 597 }
 598 
 599 void ShenandoahControlThread::set_forced_counters_update(bool value) {
 600   _force_counters_update.set_cond(value);
 601 }
 602 
 603 void ShenandoahControlThread::print() const {
 604   print_on(tty);
 605 }
 606 
 607 void ShenandoahControlThread::print_on(outputStream* st) const {
 608   st->print("Shenandoah Concurrent Thread");
 609   Thread::print_on(st);
 610   st->cr();
 611 }
 612 
 613 void ShenandoahControlThread::start() {
 614   create_and_start();
 615 }
 616 
< prev index next >