< prev index next >
src/hotspot/share/compiler/compileBroker.cpp
Print this page
rev 52328 : 8213086: Compiler thread creation should be bounded by available space in memory and Code Cache
Reviewed-by: kvn
@@ -892,47 +892,53 @@
void CompileBroker::possibly_add_compiler_threads() {
EXCEPTION_MARK;
julong available_memory = os::available_memory();
+ // If SegmentedCodeCache is off, both values refer to the single heap (with type CodeBlobType::All).
+ size_t available_cc_np = CodeCache::unallocated_capacity(CodeBlobType::MethodNonProfiled),
+ available_cc_p = CodeCache::unallocated_capacity(CodeBlobType::MethodProfiled);
+
// Only do attempt to start additional threads if the lock is free.
if (!CompileThread_lock->try_lock()) return;
if (_c2_compile_queue != NULL) {
int old_c2_count = _compilers[1]->num_compiler_threads();
- int new_c2_count = MIN3(_c2_count,
+ int new_c2_count = MIN4(_c2_count,
_c2_compile_queue->size() / 2,
- (int)(available_memory / 200*M));
+ (int)(available_memory / (200*M)),
+ (int)(available_cc_np / (128*K)));
for (int i = old_c2_count; i < new_c2_count; i++) {
JavaThread *ct = make_thread(compiler2_object(i), _c2_compile_queue, _compilers[1], true, CHECK);
if (ct == NULL) break;
_compilers[1]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
ResourceMark rm;
MutexLocker mu(Threads_lock);
- tty->print_cr("Added compiler thread %s (available memory: %dMB)",
- ct->get_thread_name(), (int)(available_memory/M));
+ tty->print_cr("Added compiler thread %s (available memory: %dMB, available non-profiled code cache: %dMB)",
+ ct->get_thread_name(), (int)(available_memory/M), (int)(available_cc_np/M));
}
}
}
if (_c1_compile_queue != NULL) {
int old_c1_count = _compilers[0]->num_compiler_threads();
- int new_c1_count = MIN3(_c1_count,
+ int new_c1_count = MIN4(_c1_count,
_c1_compile_queue->size() / 4,
- (int)(available_memory / 100*M));
+ (int)(available_memory / (100*M)),
+ (int)(available_cc_p / (128*K)));
for (int i = old_c1_count; i < new_c1_count; i++) {
JavaThread *ct = make_thread(compiler1_object(i), _c1_compile_queue, _compilers[0], true, CHECK);
if (ct == NULL) break;
_compilers[0]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
ResourceMark rm;
MutexLocker mu(Threads_lock);
- tty->print_cr("Added compiler thread %s (available memory: %dMB)",
- ct->get_thread_name(), (int)(available_memory/M));
+ tty->print_cr("Added compiler thread %s (available memory: %dMB, available profiled code cache: %dMB)",
+ ct->get_thread_name(), (int)(available_memory/M), (int)(available_cc_p/M));
}
}
}
CompileThread_lock->unlock();
< prev index next >