src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 4616 : fixes fill up of code cache: added command line parameter which defines a
threshold (percentage of used code cache) at which the threshold for
recompilation is increased.


  51     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
  52     count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2;
  53   }
  54 
  55   set_c1_count(MAX2(count / 3, 1));
  56   set_c2_count(MAX2(count - count / 3, 1));
  57 
  58   // Some inlining tuning
  59 #ifdef X86
  60   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  61     FLAG_SET_DEFAULT(InlineSmallCode, 2000);
  62   }
  63 #endif
  64 
  65 #ifdef SPARC
  66   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  67     FLAG_SET_DEFAULT(InlineSmallCode, 2500);
  68   }
  69 #endif
  70 
  71 
  72   set_start_time(os::javaTimeMillis());
  73 }
  74 
  75 // update_rate() is called from select_task() while holding a compile queue lock.
  76 void AdvancedThresholdPolicy::update_rate(jlong t, Method* m) {
  77   JavaThread* THREAD = JavaThread::current();
  78   if (is_old(m)) {
  79     // We don't remove old methods from the queue,
  80     // so we can just zero the rate.
  81     m->set_rate(0, THREAD);
  82     return;
  83   }
  84 
  85   // We don't update the rate if we've just came out of a safepoint.
  86   // delta_s is the time since last safepoint in milliseconds.
  87   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
  88   jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
  89   // How many events were there since the last time?
  90   int event_count = m->invocation_count() + m->backedge_count();
  91   int delta_e = event_count - m->prev_event_count();


 188       }
 189     }
 190     task = next_task;
 191   }
 192 
 193   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 194       && is_method_profiled(max_method)) {
 195     max_task->set_comp_level(CompLevel_limited_profile);
 196     if (PrintTieredEvents) {
 197       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 198     }
 199   }
 200 
 201   return max_task;
 202 }
 203 
 204 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 205   double queue_size = CompileBroker::queue_size(level);
 206   int comp_count = compiler_count(level);
 207   double k = queue_size / (feedback_k * comp_count) + 1;








 208   return k;
 209 }
 210 
 211 // Call and loop predicates determine whether a transition to a higher
 212 // compilation level should be performed (pointers to predicate functions
 213 // are passed to common()).
 214 // Tier?LoadFeedback is basically a coefficient that determines of
 215 // how many methods per compiler thread can be in the queue before
 216 // the threshold values double.
 217 bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level) {
 218   switch(cur_level) {
 219   case CompLevel_none:
 220   case CompLevel_limited_profile: {
 221     double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
 222     return loop_predicate_helper<CompLevel_none>(i, b, k);
 223   }
 224   case CompLevel_full_profile: {
 225     double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
 226     return loop_predicate_helper<CompLevel_full_profile>(i, b, k);
 227   }




  51     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
  52     count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2;
  53   }
  54 
  55   set_c1_count(MAX2(count / 3, 1));
  56   set_c2_count(MAX2(count - count / 3, 1));
  57 
  58   // Some inlining tuning
  59 #ifdef X86
  60   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  61     FLAG_SET_DEFAULT(InlineSmallCode, 2000);
  62   }
  63 #endif
  64 
  65 #ifdef SPARC
  66   if (FLAG_IS_DEFAULT(InlineSmallCode)) {
  67     FLAG_SET_DEFAULT(InlineSmallCode, 2500);
  68   }
  69 #endif
  70 
  71   set_reverse_cmdline_free_ratio();
  72   set_start_time(os::javaTimeMillis());
  73 }
  74 
  75 // update_rate() is called from select_task() while holding a compile queue lock.
  76 void AdvancedThresholdPolicy::update_rate(jlong t, Method* m) {
  77   JavaThread* THREAD = JavaThread::current();
  78   if (is_old(m)) {
  79     // We don't remove old methods from the queue,
  80     // so we can just zero the rate.
  81     m->set_rate(0, THREAD);
  82     return;
  83   }
  84 
  85   // We don't update the rate if we've just came out of a safepoint.
  86   // delta_s is the time since last safepoint in milliseconds.
  87   jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
  88   jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
  89   // How many events were there since the last time?
  90   int event_count = m->invocation_count() + m->backedge_count();
  91   int delta_e = event_count - m->prev_event_count();


 188       }
 189     }
 190     task = next_task;
 191   }
 192 
 193   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 194       && is_method_profiled(max_method)) {
 195     max_task->set_comp_level(CompLevel_limited_profile);
 196     if (PrintTieredEvents) {
 197       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 198     }
 199   }
 200 
 201   return max_task;
 202 }
 203 
 204 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 205   double queue_size = CompileBroker::queue_size(level);
 206   int comp_count = compiler_count(level);
 207   double k = queue_size / (feedback_k * comp_count) + 1;
 208 
 209   double reverse_free_ratio = CodeCache::reverse_free_ratio();
 210   // E.g., 4 means that 25% (1/4) of the code cache is free
 211   if (level != CompLevel_full_optimization)  {
 212     if (reverse_free_ratio > _reverse_cmdline_free_ratio) {
 213       k *= exp(reverse_free_ratio - _reverse_cmdline_free_ratio);
 214     }
 215   }
 216   return k;
 217 }
 218 
 219 // Call and loop predicates determine whether a transition to a higher
 220 // compilation level should be performed (pointers to predicate functions
 221 // are passed to common()).
 222 // Tier?LoadFeedback is basically a coefficient that determines of
 223 // how many methods per compiler thread can be in the queue before
 224 // the threshold values double.
 225 bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level) {
 226   switch(cur_level) {
 227   case CompLevel_none:
 228   case CompLevel_limited_profile: {
 229     double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
 230     return loop_predicate_helper<CompLevel_none>(i, b, k);
 231   }
 232   case CompLevel_full_profile: {
 233     double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
 234     return loop_predicate_helper<CompLevel_full_profile>(i, b, k);
 235   }