IR: an option to automatically select the number of lowering threads
This commit is contained in:
+4
-3
@@ -115,11 +115,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
var doNotClearBindingContext: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xir-threads-for-file-lowerings",
|
||||
value = "-Xparallel-backend-threads",
|
||||
description = "When using the IR backend, run lowerings by file in N parallel threads.\n" +
|
||||
"Default value is 1"
|
||||
"0 means use a thread per processor core.\n" +
|
||||
"Default value is 1"
|
||||
)
|
||||
var threadsForFileLowerings: String by FreezableVar("1")
|
||||
var parallelBackendThreads: String by FreezableVar("1")
|
||||
|
||||
@Argument(value = "-Xmodule-path", valueDescription = "<path>", description = "Paths where to find Java 9+ modules")
|
||||
var javaModulePath: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@@ -292,7 +292,9 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
|
||||
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
|
||||
|
||||
put(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS, arguments.threadsForFileLowerings.toIntOrNull() ?: 1)
|
||||
val nThreadsRaw = arguments.parallelBackendThreads.toIntOrNull() ?: 1
|
||||
val nThreads = if (nThreadsRaw == 0) Runtime.getRuntime().availableProcessors() else nThreadsRaw
|
||||
put(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS, nThreads)
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
|
||||
|
||||
@@ -52,7 +52,7 @@ object CommonConfigurationKeys {
|
||||
val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create<Boolean>("fir extended checkers")
|
||||
|
||||
@JvmField
|
||||
val THREADS_FOR_FILE_LOWERINGS =
|
||||
val PARALLEL_BACKEND_THREADS =
|
||||
CompilerConfigurationKey.create<Int>("When using the IR backend, run lowerings by file in N parallel threads")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ private class PerformByIrFilePhase<Context : CommonBackendContext>(
|
||||
context: Context,
|
||||
input: IrModuleFragment
|
||||
): IrModuleFragment {
|
||||
val nThreads = context.configuration.get(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS) ?: 1
|
||||
val nThreads = context.configuration.get(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS) ?: 1
|
||||
return if (nThreads > 1)
|
||||
invokeParallel(phaseConfig, phaserState, context, input, nThreads)
|
||||
else
|
||||
|
||||
+4
-3
@@ -90,6 +90,9 @@ where advanced options include:
|
||||
-Xno-receiver-assertions Don't generate not-null assertion for extension receiver arguments of platform types
|
||||
-Xno-reset-jar-timestamps Do not reset jar entry timestamps to a fixed date
|
||||
-Xno-unified-null-checks Use pre-1.4 exception types in null checks instead of java.lang.NPE. See KT-22275 for more details
|
||||
-Xparallel-backend-threads When using the IR backend, run lowerings by file in N parallel threads.
|
||||
0 means use a thread per processor core.
|
||||
Default value is 1
|
||||
-Xprofile=<profilerPath:command:outputDir>
|
||||
Debug option: Run compiler with async profiler, save snapshots to outputDir, command is passed to async-profiler on start
|
||||
You'll have to provide async-profiler.jar on classpath to use this
|
||||
@@ -122,9 +125,6 @@ where advanced options include:
|
||||
Suppress deprecation warning about deprecated JVM target versions
|
||||
-Xsuppress-missing-builtins-error
|
||||
Suppress the "cannot access built-in declaration" error (useful with -no-stdlib)
|
||||
-Xir-threads-for-file-lowerings
|
||||
When using the IR backend, run lowerings by file in N parallel threads.
|
||||
Default value is 1
|
||||
-Xuse-ir Use the IR backend
|
||||
-Xuse-javac Use javac for Java source and class files analysis
|
||||
-Xuse-old-backend Use the old JVM backend
|
||||
@@ -193,3 +193,4 @@ where advanced options include:
|
||||
|
||||
Advanced options are non-standard and may be changed or removed without any notice.
|
||||
OK
|
||||
|
||||
|
||||
Reference in New Issue
Block a user