[K/N] Enable custom allocator by default ^KT-55364
This commit is contained in:
committed by
Space Team
parent
1e09e8663c
commit
da1fde2477
@@ -21,6 +21,7 @@ private enum class TestProperty(shortName: String) {
|
|||||||
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
||||||
GC_TYPE("gcType"),
|
GC_TYPE("gcType"),
|
||||||
GC_SCHEDULER("gcScheduler"),
|
GC_SCHEDULER("gcScheduler"),
|
||||||
|
ALLOCATOR("alloc"),
|
||||||
CACHE_MODE("cacheMode"),
|
CACHE_MODE("cacheMode"),
|
||||||
EXECUTION_TIMEOUT("executionTimeout"),
|
EXECUTION_TIMEOUT("executionTimeout"),
|
||||||
SANITIZER("sanitizer"),
|
SANITIZER("sanitizer"),
|
||||||
@@ -168,6 +169,7 @@ fun Project.nativeTest(
|
|||||||
compute(USE_THREAD_STATE_CHECKER)
|
compute(USE_THREAD_STATE_CHECKER)
|
||||||
compute(GC_TYPE)
|
compute(GC_TYPE)
|
||||||
compute(GC_SCHEDULER)
|
compute(GC_SCHEDULER)
|
||||||
|
compute(ALLOCATOR)
|
||||||
compute(CACHE_MODE)
|
compute(CACHE_MODE)
|
||||||
compute(EXECUTION_TIMEOUT)
|
compute(EXECUTION_TIMEOUT)
|
||||||
compute(SANITIZER)
|
compute(SANITIZER)
|
||||||
|
|||||||
+9
@@ -229,6 +229,9 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
private val shouldCoverLibraries = !configuration.getList(KonanConfigKeys.LIBRARIES_TO_COVER).isNullOrEmpty()
|
private val shouldCoverLibraries = !configuration.getList(KonanConfigKeys.LIBRARIES_TO_COVER).isNullOrEmpty()
|
||||||
|
|
||||||
private val defaultAllocationMode get() = when {
|
private val defaultAllocationMode get() = when {
|
||||||
|
gc == GC.PARALLEL_MARK_CONCURRENT_SWEEP && sanitizer == null -> {
|
||||||
|
AllocationMode.CUSTOM
|
||||||
|
}
|
||||||
target.supportsMimallocAllocator() && sanitizer == null -> {
|
target.supportsMimallocAllocator() && sanitizer == null -> {
|
||||||
AllocationMode.MIMALLOC
|
AllocationMode.MIMALLOC
|
||||||
}
|
}
|
||||||
@@ -240,6 +243,9 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
null -> defaultAllocationMode
|
null -> defaultAllocationMode
|
||||||
AllocationMode.STD -> AllocationMode.STD
|
AllocationMode.STD -> AllocationMode.STD
|
||||||
AllocationMode.MIMALLOC -> {
|
AllocationMode.MIMALLOC -> {
|
||||||
|
if (sanitizer != null) {
|
||||||
|
configuration.report(CompilerMessageSeverity.STRONG_WARNING, "Sanitizers are useful only with the std allocator")
|
||||||
|
}
|
||||||
if (target.supportsMimallocAllocator()) {
|
if (target.supportsMimallocAllocator()) {
|
||||||
AllocationMode.MIMALLOC
|
AllocationMode.MIMALLOC
|
||||||
} else {
|
} else {
|
||||||
@@ -249,6 +255,9 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AllocationMode.CUSTOM -> {
|
AllocationMode.CUSTOM -> {
|
||||||
|
if (sanitizer != null) {
|
||||||
|
configuration.report(CompilerMessageSeverity.STRONG_WARNING, "Sanitizers are useful only with the std allocator")
|
||||||
|
}
|
||||||
if (gc == GC.PARALLEL_MARK_CONCURRENT_SWEEP) {
|
if (gc == GC.PARALLEL_MARK_CONCURRENT_SWEEP) {
|
||||||
AllocationMode.CUSTOM
|
AllocationMode.CUSTOM
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3135,6 +3135,7 @@ standaloneTest("stress_gc_allocations") {
|
|||||||
(project.testTarget != "watchos_simulator_arm64") &&
|
(project.testTarget != "watchos_simulator_arm64") &&
|
||||||
!isNoopGC &&
|
!isNoopGC &&
|
||||||
!isAggressiveGC && // TODO: Investigate why too slow
|
!isAggressiveGC && // TODO: Investigate why too slow
|
||||||
|
!runtimeAssertionsPanic && // New allocator with assertions makes this test very slow
|
||||||
(project.testTarget != "mingw_x64") // TODO: Fix on mingw.
|
(project.testTarget != "mingw_x64") // TODO: Fix on mingw.
|
||||||
source = "runtime/memory/stress_gc_allocations.kt"
|
source = "runtime/memory/stress_gc_allocations.kt"
|
||||||
flags = ['-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
flags = ['-tr', '-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||||
|
|||||||
+1
@@ -63,6 +63,7 @@ internal enum class ClassLevelProperty(shortName: String) {
|
|||||||
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
||||||
GC_TYPE("gcType"),
|
GC_TYPE("gcType"),
|
||||||
GC_SCHEDULER("gcScheduler"),
|
GC_SCHEDULER("gcScheduler"),
|
||||||
|
ALLOCATOR("alloc"),
|
||||||
CACHE_MODE("cacheMode"),
|
CACHE_MODE("cacheMode"),
|
||||||
EXECUTION_TIMEOUT("executionTimeout"),
|
EXECUTION_TIMEOUT("executionTimeout"),
|
||||||
SANITIZER("sanitizer"),
|
SANITIZER("sanitizer"),
|
||||||
|
|||||||
+6
@@ -163,6 +163,8 @@ private object NativeTestSupport {
|
|||||||
|
|
||||||
val gcScheduler = computeGCScheduler(enforcedProperties)
|
val gcScheduler = computeGCScheduler(enforcedProperties)
|
||||||
|
|
||||||
|
val allocator = computeAllocator(enforcedProperties)
|
||||||
|
|
||||||
val nativeHome = getOrCreateTestProcessSettings().get<KotlinNativeHome>()
|
val nativeHome = getOrCreateTestProcessSettings().get<KotlinNativeHome>()
|
||||||
|
|
||||||
val distribution = Distribution(nativeHome.dir.path)
|
val distribution = Distribution(nativeHome.dir.path)
|
||||||
@@ -183,6 +185,7 @@ private object NativeTestSupport {
|
|||||||
output += threadStateChecker
|
output += threadStateChecker
|
||||||
output += gcType
|
output += gcType
|
||||||
output += gcScheduler
|
output += gcScheduler
|
||||||
|
output += allocator
|
||||||
output += nativeTargets
|
output += nativeTargets
|
||||||
output += sanitizer
|
output += sanitizer
|
||||||
output += CacheMode::class to cacheMode
|
output += CacheMode::class to cacheMode
|
||||||
@@ -228,6 +231,9 @@ private object NativeTestSupport {
|
|||||||
private fun computeGCScheduler(enforcedProperties: EnforcedProperties): GCScheduler =
|
private fun computeGCScheduler(enforcedProperties: EnforcedProperties): GCScheduler =
|
||||||
ClassLevelProperty.GC_SCHEDULER.readValue(enforcedProperties, GCScheduler.values(), default = GCScheduler.UNSPECIFIED)
|
ClassLevelProperty.GC_SCHEDULER.readValue(enforcedProperties, GCScheduler.values(), default = GCScheduler.UNSPECIFIED)
|
||||||
|
|
||||||
|
private fun computeAllocator(enforcedProperties: EnforcedProperties): Allocator =
|
||||||
|
ClassLevelProperty.ALLOCATOR.readValue(enforcedProperties, Allocator.values(), default = Allocator.UNSPECIFIED)
|
||||||
|
|
||||||
private fun computeNativeTargets(enforcedProperties: EnforcedProperties, hostManager: HostManager): KotlinNativeTargets {
|
private fun computeNativeTargets(enforcedProperties: EnforcedProperties, hostManager: HostManager): KotlinNativeTargets {
|
||||||
val hostTarget = HostManager.host
|
val hostTarget = HostManager.host
|
||||||
return KotlinNativeTargets(
|
return KotlinNativeTargets(
|
||||||
|
|||||||
+4
@@ -132,6 +132,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
|||||||
private val sanitizer: Sanitizer,
|
private val sanitizer: Sanitizer,
|
||||||
private val gcType: GCType,
|
private val gcType: GCType,
|
||||||
private val gcScheduler: GCScheduler,
|
private val gcScheduler: GCScheduler,
|
||||||
|
private val allocator: Allocator,
|
||||||
private val pipelineType: PipelineType,
|
private val pipelineType: PipelineType,
|
||||||
freeCompilerArgs: TestCompilerArgs,
|
freeCompilerArgs: TestCompilerArgs,
|
||||||
override val sourceModules: Collection<TestModule>,
|
override val sourceModules: Collection<TestModule>,
|
||||||
@@ -193,6 +194,7 @@ internal class LibraryCompilation(
|
|||||||
sanitizer = settings.get(),
|
sanitizer = settings.get(),
|
||||||
gcType = settings.get(),
|
gcType = settings.get(),
|
||||||
gcScheduler = settings.get(),
|
gcScheduler = settings.get(),
|
||||||
|
allocator = settings.get(),
|
||||||
pipelineType = settings.get(),
|
pipelineType = settings.get(),
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
sourceModules = sourceModules,
|
sourceModules = sourceModules,
|
||||||
@@ -226,6 +228,7 @@ internal class ObjCFrameworkCompilation(
|
|||||||
sanitizer = settings.get(),
|
sanitizer = settings.get(),
|
||||||
gcType = settings.get(),
|
gcType = settings.get(),
|
||||||
gcScheduler = settings.get(),
|
gcScheduler = settings.get(),
|
||||||
|
allocator = settings.get(),
|
||||||
pipelineType = settings.getStageDependentPipelineType(),
|
pipelineType = settings.getStageDependentPipelineType(),
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
sourceModules = sourceModules,
|
sourceModules = sourceModules,
|
||||||
@@ -310,6 +313,7 @@ internal class ExecutableCompilation(
|
|||||||
sanitizer = settings.get(),
|
sanitizer = settings.get(),
|
||||||
gcType = settings.get(),
|
gcType = settings.get(),
|
||||||
gcScheduler = settings.get(),
|
gcScheduler = settings.get(),
|
||||||
|
allocator = settings.get(),
|
||||||
pipelineType = settings.getStageDependentPipelineType(),
|
pipelineType = settings.getStageDependentPipelineType(),
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
sourceModules = sourceModules,
|
sourceModules = sourceModules,
|
||||||
|
|||||||
+9
@@ -166,6 +166,15 @@ internal enum class GCScheduler(val compilerFlag: String?) {
|
|||||||
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum class Allocator(val compilerFlag: String?) {
|
||||||
|
UNSPECIFIED(null),
|
||||||
|
STD("-Xallocator=std"),
|
||||||
|
MIMALLOC("-Xallocator=mimalloc"),
|
||||||
|
CUSTOM("-Xallocator=custom");
|
||||||
|
|
||||||
|
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current project's directories.
|
* Current project's directories.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user