Skip to content

Commit f2ef809

Browse files
mhaessigshipilev
andcommitted
8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce
Co-authored-by: Aleksey Shipilev <[email protected]> Reviewed-by: kvn, shade
1 parent 1fa0905 commit f2ef809

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/hotspot/share/compiler/compilationPolicy.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,15 @@ void CompilationPolicy::initialize() {
571571
#ifdef COMPILER2
572572
c2_size = C2Compiler::initial_code_buffer_size();
573573
#endif
574-
size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3);
575-
size_t max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / buffer_size;
574+
size_t buffer_size = 0;
575+
if (c1_only) {
576+
buffer_size = c1_size;
577+
} else if (c2_only) {
578+
buffer_size = c2_size;
579+
} else {
580+
buffer_size = c1_size / 3 + 2 * c2_size / 3;
581+
}
582+
size_t max_count = (NonNMethodCodeHeapSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / buffer_size;
576583
if ((size_t)count > max_count) {
577584
// Lower the compiler count such that all buffers fit into the code cache
578585
count = MAX2((int)max_count, min_count);
@@ -591,7 +598,7 @@ void CompilationPolicy::initialize() {
591598
count = 3;
592599
FLAG_SET_ERGO(CICompilerCount, count);
593600
}
594-
#endif
601+
#endif // _LP64
595602

596603
if (c1_only) {
597604
// No C2 compiler threads are needed

0 commit comments

Comments
 (0)