[K/N] Prevent unmarked objects from appearing during concurrent weak processing

Merge-request: KT-MR-11614
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
This commit is contained in:
Aleksei.Glushko
2023-08-26 16:00:12 +00:00
committed by Space Team
parent 3013e3549c
commit 0d04e170b1
21 changed files with 452 additions and 178 deletions
@@ -53,10 +53,16 @@ public class RootSetStatistics(
* @property startTimeNs Time, when garbage collector run is started, meausered by [kotlin.system.getTimeNanos].
* @property endTimeNs Time, when garbage collector run is ended, measured by [kotlin.system.getTimeNanos].
* After this point, most of the memory is reclaimed, and a new garbage collector run can start.
* @property pauseStartTimeNs Time, when mutator threads are suspended, mesured by [kotlin.system.getTimeNanos].
* @property pauseEndTimeNs Time, when mutator threads are unsuspended, mesured by [kotlin.system.getTimeNanos].
* @property firstPauseRequestTimeNs Time, when the garbage collector thread requested suspension of mutator threads for the first time,
* mesured by [kotlin.system.getTimeNanos].
* @property firstPauseStartTimeNs Time, when mutator threads are suspended for the first time, mesured by [kotlin.system.getTimeNanos].
* @property firstPauseEndTimeNs Time, when mutator threads are unsuspended for the first time, mesured by [kotlin.system.getTimeNanos].
* @property secondPauseRequestTimeNs Time, when the garbage collector thread requested suspension of mutator threads for the second time,
* mesured by [kotlin.system.getTimeNanos].
* @property secondPauseStartTimeNs Time, when mutator threads are suspended for the second time, mesured by [kotlin.system.getTimeNanos].
* @property secondPauseEndTimeNs Time, when mutator threads are unsuspended for the second time, mesured by [kotlin.system.getTimeNanos].
* @property postGcCleanupTimeNs Time, when all memory is reclaimed, measured by [kotlin.system.getTimeNanos].
* If null, memory reclamation is still in progress.
* If null, memory reclamation is still in progress.
* @property rootSet The number of objects in each root set pool. Check [RootSetStatistics] doc for details.
* @property memoryUsageAfter Memory usage at the start of garbage collector run, separated by memory pools.
* The set of memory pools depends on the collector implementation.
@@ -74,8 +80,12 @@ public class GCInfo(
val epoch: Long,
val startTimeNs: Long,
val endTimeNs: Long,
val pauseStartTimeNs: Long,
val pauseEndTimeNs: Long,
val firstPauseRequestTimeNs: Long,
val firstPauseStartTimeNs: Long,
val firstPauseEndTimeNs: Long,
val secondPauseRequestTimeNs: Long?,
val secondPauseStartTimeNs: Long?,
val secondPauseEndTimeNs: Long?,
val postGcCleanupTimeNs: Long?,
val rootSet: RootSetStatistics,
val memoryUsageBefore: Map<String, MemoryUsage>,
@@ -89,8 +99,12 @@ public class GCInfo(
info.epoch,
info.startTimeNs,
info.endTimeNs,
info.pauseStartTimeNs,
info.pauseEndTimeNs,
info.firstPauseRequestTimeNs,
info.firstPauseStartTimeNs,
info.firstPauseEndTimeNs,
info.secondPauseRequestTimeNs,
info.secondPauseStartTimeNs,
info.secondPauseEndTimeNs,
info.postGcCleanupTimeNs,
info.rootSet.let {
RootSetStatistics(
@@ -71,8 +71,14 @@ public class RootSetStatistics(
* @property startTimeNs Time, when garbage collector run is started, meausered by [kotlin.system.getTimeNanos].
* @property endTimeNs Time, when garbage collector run is ended, measured by [kotlin.system.getTimeNanos].
* After this point, most of the memory is reclaimed, and a new garbage collector run can start.
* @property pauseStartTimeNs Time, when mutator threads are suspended, mesured by [kotlin.system.getTimeNanos].
* @property pauseEndTimeNs Time, when mutator threads are unsuspended, mesured by [kotlin.system.getTimeNanos].
* @property firstPauseRequestTimeNs Time, when the garbage collector thread requested suspension of mutator threads for the first time,
* mesured by [kotlin.system.getTimeNanos].
* @property firstPauseStartTimeNs Time, when mutator threads are suspended for the first time, mesured by [kotlin.system.getTimeNanos].
* @property firstPauseEndTimeNs Time, when mutator threads are unsuspended for the first time, mesured by [kotlin.system.getTimeNanos].
* @property secondPauseRequestTimeNs Time, when the garbage collector thread requested suspension of mutator threads for the second time,
* mesured by [kotlin.system.getTimeNanos].
* @property secondPauseStartTimeNs Time, when mutator threads are suspended for the second time, mesured by [kotlin.system.getTimeNanos].
* @property secondPauseEndTimeNs Time, when mutator threads are unsuspended for the second time, mesured by [kotlin.system.getTimeNanos].
* @property postGcCleanupTimeNs Time, when all memory is reclaimed, measured by [kotlin.system.getTimeNanos].
* If null, memory reclamation is still in progress.
* @property rootSet The number of objects in each root set pool. Check [RootSetStatistics] doc for details.
@@ -93,8 +99,12 @@ public class GCInfo(
val epoch: Long,
val startTimeNs: Long,
val endTimeNs: Long,
val pauseStartTimeNs: Long,
val pauseEndTimeNs: Long,
val firstPauseRequestTimeNs: Long,
val firstPauseStartTimeNs: Long,
val firstPauseEndTimeNs: Long,
val secondPauseRequestTimeNs: Long?,
val secondPauseStartTimeNs: Long?,
val secondPauseEndTimeNs: Long?,
val postGcCleanupTimeNs: Long?,
val rootSet: RootSetStatistics,
val markedCount: Long,
@@ -116,8 +126,12 @@ private class GCInfoBuilder() {
var epoch: Long? = null
var startTimeNs: Long? = null
var endTimeNs: Long? = null
var pauseStartTimeNs: Long? = null
var pauseEndTimeNs: Long? = null
var firstPauseRequestTimeNs: Long? = null
var firstPauseStartTimeNs: Long? = null
var firstPauseEndTimeNs: Long? = null
var secondPauseRequestTimeNs: Long? = null
var secondPauseStartTimeNs: Long? = null
var secondPauseEndTimeNs: Long? = null
var postGcCleanupTimeNs: Long? = null
var rootSet: RootSetStatistics? = null
var markedCount: Long? = null
@@ -140,14 +154,34 @@ private class GCInfoBuilder() {
endTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setPauseStartTime")
private fun setPauseStartTime(value: Long) {
pauseStartTimeNs = value
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setFirstPauseRequestTime")
private fun setFirstPauseRequestTime(value: Long) {
firstPauseRequestTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setPauseEndTime")
private fun setPauseEndTime(value: Long) {
pauseEndTimeNs = value
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setFirstPauseStartTime")
private fun setFirstPauseStartTime(value: Long) {
firstPauseStartTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setFirstPauseEndTime")
private fun setFirstPauseEndTime(value: Long) {
firstPauseEndTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setSecondPauseRequestTime")
private fun setSecondPauseRequestTime(value: Long) {
secondPauseRequestTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setSecondPauseStartTime")
private fun setSecondPauseStartTime(value: Long) {
secondPauseStartTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setSecondPauseEndTime")
private fun setSecondPauseEndTime(value: Long) {
secondPauseEndTimeNs = value
}
@ExportForCppRuntime("Kotlin_Internal_GC_GCInfoBuilder_setPostGcCleanupTime")
@@ -191,8 +225,12 @@ private class GCInfoBuilder() {
epoch ?: return null,
startTimeNs ?: return null,
endTimeNs ?: return null,
pauseStartTimeNs ?: return null,
pauseEndTimeNs ?: return null,
firstPauseRequestTimeNs ?: return null,
firstPauseStartTimeNs ?: return null,
firstPauseEndTimeNs ?: return null,
secondPauseRequestTimeNs,
secondPauseStartTimeNs,
secondPauseEndTimeNs,
postGcCleanupTimeNs,
rootSet ?: return null,
markedCount ?: return null,