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