< prev index next >

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 10354 : 8150646: Add support for blocking compiles though whitebox API
Reviewed-by: kvn, ppunegov, simonis, neliasso
Contributed-by: nils.eliasson@oracle.com, volker.simonis@gmail.com
   1 /*
   2  * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 147       if (weight(x) > weight(y)) {
 148         return true;
 149       }
 150     }
 151   return false;
 152 }
 153 
 154 // Is method profiled enough?
 155 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 156   MethodData* mdo = method->method_data();
 157   if (mdo != NULL) {
 158     int i = mdo->invocation_count_delta();
 159     int b = mdo->backedge_count_delta();
 160     return call_predicate_helper<CompLevel_full_profile>(i, b, 1, method);
 161   }
 162   return false;
 163 }
 164 
 165 // Called with the queue locked and with at least one element
 166 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
 167 #if INCLUDE_JVMCI
 168   CompileTask *max_blocking_task = NULL;
 169 #endif
 170   CompileTask *max_task = NULL;
 171   Method* max_method = NULL;
 172   jlong t = os::javaTimeMillis();
 173   // Iterate through the queue and find a method with a maximum rate.
 174   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 175     CompileTask* next_task = task->next();
 176     Method* method = task->method();
 177     update_rate(t, method);
 178     if (max_task == NULL) {
 179       max_task = task;
 180       max_method = method;
 181     } else {
 182       // If a method has been stale for some time, remove it from the queue.
 183       if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {

 184         if (PrintTieredEvents) {
 185           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 186         }
 187         task->log_task_dequeued("stale");
 188         compile_queue->remove_and_mark_stale(task);
 189         method->clear_queued_for_compilation();
 190         task = next_task;
 191         continue;
 192       }
 193 
 194       // Select a method with a higher rate
 195       if (compare_methods(method, max_method)) {
 196         max_task = task;
 197         max_method = method;
 198       }
 199     }
 200 #if INCLUDE_JVMCI
 201     if (UseJVMCICompiler && task->is_blocking()) {
 202       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 203         max_blocking_task = task;
 204       }
 205     }
 206 #endif
 207     task = next_task;
 208   }
 209 
 210 #if INCLUDE_JVMCI
 211   if (UseJVMCICompiler) {
 212     if (max_blocking_task != NULL) {
 213       // In blocking compilation mode, the CompileBroker will make
 214       // compilations submitted by a JVMCI compiler thread non-blocking. These
 215       // compilations should be scheduled after all blocking compilations
 216       // to service non-compiler related compilations sooner and reduce the
 217       // chance of such compilations timing out.
 218       max_task = max_blocking_task;
 219       max_method = max_task->method();
 220     }
 221   }
 222 #endif
 223 
 224   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 225       && is_method_profiled(max_method)) {
 226     max_task->set_comp_level(CompLevel_limited_profile);
 227     if (PrintTieredEvents) {
 228       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 229     }
 230   }
 231 
 232   return max_task;
 233 }
 234 
 235 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 236   double queue_size = CompileBroker::queue_size(level);
 237   int comp_count = compiler_count(level);
 238   double k = queue_size / (feedback_k * comp_count) + 1;
 239 
 240   // Increase C1 compile threshold when the code cache is filled more
 241   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 242   // The main intention is to keep enough free space for C2 compiled code


   1 /*
   2  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 147       if (weight(x) > weight(y)) {
 148         return true;
 149       }
 150     }
 151   return false;
 152 }
 153 
 154 // Is method profiled enough?
 155 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 156   MethodData* mdo = method->method_data();
 157   if (mdo != NULL) {
 158     int i = mdo->invocation_count_delta();
 159     int b = mdo->backedge_count_delta();
 160     return call_predicate_helper<CompLevel_full_profile>(i, b, 1, method);
 161   }
 162   return false;
 163 }
 164 
 165 // Called with the queue locked and with at least one element
 166 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {

 167   CompileTask *max_blocking_task = NULL;

 168   CompileTask *max_task = NULL;
 169   Method* max_method = NULL;
 170   jlong t = os::javaTimeMillis();
 171   // Iterate through the queue and find a method with a maximum rate.
 172   for (CompileTask* task = compile_queue->first(); task != NULL;) {
 173     CompileTask* next_task = task->next();
 174     Method* method = task->method();
 175     update_rate(t, method);
 176     if (max_task == NULL) {
 177       max_task = task;
 178       max_method = method;
 179     } else {
 180       // If a method has been stale for some time, remove it from the queue.
 181       // Blocking tasks don't become stale
 182       if (!task->is_blocking() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
 183         if (PrintTieredEvents) {
 184           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 185         }
 186         task->log_task_dequeued("stale");
 187         compile_queue->remove_and_mark_stale(task);
 188         method->clear_queued_for_compilation();
 189         task = next_task;
 190         continue;
 191       }
 192 
 193       // Select a method with a higher rate
 194       if (compare_methods(method, max_method)) {
 195         max_task = task;
 196         max_method = method;
 197       }
 198     }
 199 
 200     if (task->is_blocking()) {
 201       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 202         max_blocking_task = task;
 203       }
 204     }
 205 
 206     task = next_task;
 207   }
 208 


 209   if (max_blocking_task != NULL) {
 210     // In blocking compilation mode, the CompileBroker will make
 211     // compilations submitted by a JVMCI compiler thread non-blocking. These
 212     // compilations should be scheduled after all blocking compilations
 213     // to service non-compiler related compilations sooner and reduce the
 214     // chance of such compilations timing out.
 215     max_task = max_blocking_task;
 216     max_method = max_task->method();
 217   }


 218 
 219   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 220       && is_method_profiled(max_method)) {
 221     max_task->set_comp_level(CompLevel_limited_profile);
 222     if (PrintTieredEvents) {
 223       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 224     }
 225   }
 226 
 227   return max_task;
 228 }
 229 
 230 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 231   double queue_size = CompileBroker::queue_size(level);
 232   int comp_count = compiler_count(level);
 233   double k = queue_size / (feedback_k * comp_count) + 1;
 234 
 235   // Increase C1 compile threshold when the code cache is filled more
 236   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 237   // The main intention is to keep enough free space for C2 compiled code


< prev index next >