< prev index next >

src/share/vm/runtime/advancedThresholdPolicy.cpp

Print this page
rev 8983 : 8222670: pathological case of JIT recompilation and code cache bloat
Summary: Prevent downgraded compilation tasks from recompiling.
Reviewed-by: thartmann, sgehwolf, phh, andrew
   1 /*
   2  * Copyright (c) 2010, 2013, 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  *


 179         if (PrintTieredEvents) {
 180           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 181         }
 182         compile_queue->remove_and_mark_stale(task);
 183         method->clear_queued_for_compilation();
 184         task = next_task;
 185         continue;
 186       }
 187 
 188       // Select a method with a higher rate
 189       if (compare_methods(method, max_method)) {
 190         max_task = task;
 191         max_method = method;
 192       }
 193     }
 194     task = next_task;
 195   }
 196 
 197   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 198       && is_method_profiled(max_method)) {










 199     max_task->set_comp_level(CompLevel_limited_profile);
 200     if (PrintTieredEvents) {
 201       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 202     }
 203   }
 204 
 205   return max_task;
 206 }
 207 
 208 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 209   double queue_size = CompileBroker::queue_size(level);
 210   int comp_count = compiler_count(level);
 211   double k = queue_size / (feedback_k * comp_count) + 1;
 212 
 213   // Increase C1 compile threshold when the code cache is filled more
 214   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 215   // The main intention is to keep enough free space for C2 compiled code
 216   // to achieve peak performance if the code cache is under stress.
 217   if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization))  {
 218     double current_reverse_free_ratio = CodeCache::reverse_free_ratio();


   1 /*
   2  * Copyright (c) 2010, 2019, 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  *


 179         if (PrintTieredEvents) {
 180           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
 181         }
 182         compile_queue->remove_and_mark_stale(task);
 183         method->clear_queued_for_compilation();
 184         task = next_task;
 185         continue;
 186       }
 187 
 188       // Select a method with a higher rate
 189       if (compare_methods(method, max_method)) {
 190         max_task = task;
 191         max_method = method;
 192       }
 193     }
 194     task = next_task;
 195   }
 196 
 197   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
 198       && is_method_profiled(max_method)) {
 199 
 200     if (CompileBroker::compilation_is_complete(max_method, max_task->osr_bci(), CompLevel_limited_profile)) {
 201       if (PrintTieredEvents) {
 202         print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 203       }
 204       compile_queue->remove_and_mark_stale(max_task);
 205       max_method->clear_queued_for_compilation();
 206       return NULL;
 207     }
 208 
 209     max_task->set_comp_level(CompLevel_limited_profile);
 210     if (PrintTieredEvents) {
 211       print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
 212     }
 213   }
 214 
 215   return max_task;
 216 }
 217 
 218 double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
 219   double queue_size = CompileBroker::queue_size(level);
 220   int comp_count = compiler_count(level);
 221   double k = queue_size / (feedback_k * comp_count) + 1;
 222 
 223   // Increase C1 compile threshold when the code cache is filled more
 224   // than specified by IncreaseFirstTierCompileThresholdAt percentage.
 225   // The main intention is to keep enough free space for C2 compiled code
 226   // to achieve peak performance if the code cache is under stress.
 227   if ((TieredStopAtLevel == CompLevel_full_optimization) && (level != CompLevel_full_optimization))  {
 228     double current_reverse_free_ratio = CodeCache::reverse_free_ratio();


< prev index next >