comparison src/hotspot/share/runtime/compilationPolicy.cpp @ 53254:0451e0a2f1f5

8177899: Tests fail due to code cache exhaustion on machines with many cores Summary: Implemented upper limit on CICompilerCount based on code cache size. Reviewed-by: kvn, mdoerr
author thartmann
date Tue, 30 Oct 2018 09:06:08 +0100
parents db0c3952de52
children 7d3cde494494
comparison
equal deleted inserted replaced
8:c9df985ec968 9:0efd32da6a3f
44 #include "runtime/vframe.hpp" 44 #include "runtime/vframe.hpp"
45 #include "runtime/vm_operations.hpp" 45 #include "runtime/vm_operations.hpp"
46 #include "utilities/events.hpp" 46 #include "utilities/events.hpp"
47 #include "utilities/globalDefinitions.hpp" 47 #include "utilities/globalDefinitions.hpp"
48 48
49 #ifdef COMPILER1
50 #include "c1/c1_Compiler.hpp"
51 #endif
52 #ifdef COMPILER2
53 #include "opto/c2compiler.hpp"
54 #endif
55
49 CompilationPolicy* CompilationPolicy::_policy; 56 CompilationPolicy* CompilationPolicy::_policy;
50 elapsedTimer CompilationPolicy::_accumulated_time; 57 elapsedTimer CompilationPolicy::_accumulated_time;
51 bool CompilationPolicy::_in_vm_startup; 58 bool CompilationPolicy::_in_vm_startup;
52 59
53 // Determine compilation policy based on command line argument 60 // Determine compilation policy based on command line argument
220 if (CICompilerCountPerCPU) { 227 if (CICompilerCountPerCPU) {
221 // Example: if CICompilerCountPerCPU is true, then we get 228 // Example: if CICompilerCountPerCPU is true, then we get
222 // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine. 229 // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.
223 // May help big-app startup time. 230 // May help big-app startup time.
224 _compiler_count = MAX2(log2_intptr(os::active_processor_count())-1,1); 231 _compiler_count = MAX2(log2_intptr(os::active_processor_count())-1,1);
232 // Make sure there is enough space in the code cache to hold all the compiler buffers
233 size_t buffer_size = 1;
234 #ifdef COMPILER1
235 buffer_size = is_client_compilation_mode_vm() ? Compiler::code_buffer_size() : buffer_size;
236 #endif
237 #ifdef COMPILER2
238 buffer_size = is_server_compilation_mode_vm() ? C2Compiler::initial_code_buffer_size() : buffer_size;
239 #endif
240 int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size;
241 if (_compiler_count > max_count) {
242 // Lower the compiler count such that all buffers fit into the code cache
243 _compiler_count = MAX2(max_count, 1);
244 }
225 FLAG_SET_ERGO(intx, CICompilerCount, _compiler_count); 245 FLAG_SET_ERGO(intx, CICompilerCount, _compiler_count);
226 } else { 246 } else {
227 _compiler_count = CICompilerCount; 247 _compiler_count = CICompilerCount;
228 } 248 }
229 } 249 }