src/share/vm/runtime/advancedThresholdPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 10435 : 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  *


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

 197         if (PrintTieredEvents) {
 198           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 199         }
 200         task->log_task_dequeued("stale");
 201         compile_queue->remove_and_mark_stale(task);
 202         method->clear_queued_for_compilation();
 203         task = next_task;
 204         continue;
 205       }
 206 
 207       // Select a method with a higher rate
 208       if (compare_methods(method, max_method)) {
 209         max_task = task;
 210         max_method = method;
 211       }
 212     }
 213 #if INCLUDE_JVMCI
 214     if (UseJVMCICompiler && task->is_blocking()) {
 215       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
 216         max_blocking_task = task;
 217       }
 218     }
 219 #endif
 220     task = next_task;
 221   }
 222 
 223 #if INCLUDE_JVMCI
 224   if (UseJVMCICompiler) {
 225     if (max_blocking_task != NULL) {
 226       // In blocking compilation mode, the CompileBroker will make
 227       // compilations submitted by a JVMCI compiler thread non-blocking. These
 228       // compilations should be scheduled after all blocking compilations
 229       // to service non-compiler related compilations sooner and reduce the
 230       // chance of such compilations timing out.
 231       max_task = max_blocking_task;
 232       max_method = max_task->method();
 233     }
 234   }
 235 #endif
 236 
 237   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 238       && is_method_profiled(max_method)) {
 239     max_task->set_comp_level(CompLevel_limited_profile);
 240     if (PrintTieredEvents) {
 241       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 242     }
 243   }
 244 
 245   return max_task;
 246 }
 247 
 248 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 249   double queue_size = CompileBroker::queue_size(level);
 250   int comp_count = compiler_count(level);
 251   double k = queue_size / (feedback_k * comp_count) + 1;
 252 
 253   // Increase C1 compile threshold when the code cache is filled more
 254   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 255   // 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  *


 160       if (weight(x) > weight(y)) {
 161         return true;
 162       }
 163     }
 164   return false;
 165 }
 166 
 167 // Is method profiled enough?
 168 bool AdvancedThresholdPolicy::is_method_profiled(Method* method) {
 169   MethodData* mdo = method->method_data();
 170   if (mdo != NULL) {
 171     int i = mdo->invocation_count_delta();
 172     int b = mdo->backedge_count_delta();
 173     return call_predicate_helper<CompLevel_full_profile>(i, b, 1, method);
 174   }
 175   return false;
 176 }
 177 
 178 // Called with the queue locked and with at least one element
 179 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {

 180   CompileTask *max_blocking_task = NULL;

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


 222   if (max_blocking_task != NULL) {
 223     // In blocking compilation mode, the CompileBroker will make
 224     // compilations submitted by a JVMCI compiler thread non-blocking. These
 225     // compilations should be scheduled after all blocking compilations
 226     // to service non-compiler related compilations sooner and reduce the
 227     // chance of such compilations timing out.
 228     max_task = max_blocking_task;
 229     max_method = max_task->method();
 230   }


 231 
 232   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 233       && is_method_profiled(max_method)) {
 234     max_task->set_comp_level(CompLevel_limited_profile);
 235     if (PrintTieredEvents) {
 236       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 237     }
 238   }
 239 
 240   return max_task;
 241 }
 242 
 243 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 244   double queue_size = CompileBroker::queue_size(level);
 245   int comp_count = compiler_count(level);
 246   double k = queue_size / (feedback_k * comp_count) + 1;
 247 
 248   // Increase C1 compile threshold when the code cache is filled more
 249   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 250   // The main intention is to keep enough free space for C2 compiled code


src/share/vm/runtime/advancedThresholdPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File