# HG changeset patch # User Thomas Wuerthinger # Date 1424133804 -3600 # Node ID ac5b08ea9a6aa4a07ccc4628f9a988be5c6336c2 # Parent a5c9756f9649f090c87d0dcf30b5aabbad6c12fe Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override. diff -r a5c9756f9649 -r ac5b08ea9a6a graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Feb 17 01:26:27 2015 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Feb 17 01:43:24 2015 +0100 @@ -98,7 +98,18 @@ } } }); - compileQueue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), factory); + int selectedProcessors = TruffleCompilerOptions.TruffleCompilerThreads.getValue(); + if (selectedProcessors == 0) { + // No manual selection made, check how many processors are available. + int availableProcessors = Runtime.getRuntime().availableProcessors(); + if (availableProcessors >= 4) { + selectedProcessors = 2; + } else if (availableProcessors >= 12) { + selectedProcessors = 4; + } + } + selectedProcessors = Math.max(1, selectedProcessors); + compileQueue = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), factory); } diff -r a5c9756f9649 -r ac5b08ea9a6a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Tue Feb 17 01:26:27 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Tue Feb 17 01:43:24 2015 +0100 @@ -104,6 +104,9 @@ @Option(help = "Enable asynchronous truffle compilation in background thread", type = OptionType.Expert) public static final OptionValue TruffleBackgroundCompilation = new OptionValue<>(true); + @Option(help = "Manually set the number of compiler threads", type = OptionType.Expert) + public static final StableOptionValue TruffleCompilerThreads = new StableOptionValue<>(0); + @Option(help = "Enable inlining across Truffle boundary", type = OptionType.Expert) public static final OptionValue TruffleInlineAcrossTruffleBoundary = new OptionValue<>(false);