Mercurial > hg > graal-compiler
changeset 19447:ac5b08ea9a6a
Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 17 Feb 2015 01:43:24 +0100 |
parents | a5c9756f9649 |
children | d786fa19dc47 |
files | graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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<Runnable>(), 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<Runnable>(), factory); }
--- 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<Boolean> TruffleBackgroundCompilation = new OptionValue<>(true); + @Option(help = "Manually set the number of compiler threads", type = OptionType.Expert) + public static final StableOptionValue<Integer> TruffleCompilerThreads = new StableOptionValue<>(0); + @Option(help = "Enable inlining across Truffle boundary", type = OptionType.Expert) public static final OptionValue<Boolean> TruffleInlineAcrossTruffleBoundary = new OptionValue<>(false);