Skip to content

Commit

Permalink
Decrease the number of cores available for Swift compilation if SKIE …
Browse files Browse the repository at this point in the history
…runs concurrently with the Kotlin compiler.
  • Loading branch information
FilipDolnik committed Apr 4, 2024
1 parent bab436c commit 68f3450
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class CompileSwiftPhase(

private val isDebug = konanConfig.debug
private val isLibraryEvolutionEnabled = SkieConfigurationFlag.Build_SwiftLibraryEvolution in skieConfiguration.enabledConfigurationFlags
private val isParallelSwiftCompilationEnabled = SkieConfigurationFlag.Build_ParallelSwiftCompilation in skieConfiguration.enabledConfigurationFlags
private val isConcurrentSkieCompilationEnabled = SkieConfigurationFlag.Build_ConcurrentSkieCompilation in skieConfiguration.enabledConfigurationFlags

context(SirPhase.Context)
override suspend fun execute() {
Expand Down Expand Up @@ -206,9 +208,17 @@ class CompileSwiftPhase(
}

private val parallelizationArgument: String
get() = if (SkieConfigurationFlag.Build_ParallelSwiftCompilation in skieConfiguration.enabledConfigurationFlags) {
"-j${Runtime.getRuntime().availableProcessors()}"
} else {
"-j1"
get() {
val numberOfAvailableProcessors = if (isParallelSwiftCompilationEnabled) {
if (isConcurrentSkieCompilationEnabled) {
(Runtime.getRuntime().availableProcessors() - 1).coerceAtLeast(1)
} else {
Runtime.getRuntime().availableProcessors()
}
} else {
1
}

return "-j$numberOfAvailableProcessors"
}
}

0 comments on commit 68f3450

Please sign in to comment.