mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
PY-90883 inline FUS type-engine timing wrappers to fix StackOverflowError
(cherry picked from commit aa216ae0370dc1e6d60870f073fe9d7a9d74d1df) IJ-MR-213683 (cherry picked from commit 498fbb0c04142eaaea437a8d75f8338dc773d05c) IJ-CR-216837 GitOrigin-RevId: fcf78e2e7e7ac3db6b378f076f0635935daf3f95
This commit is contained in:
committed by
intellij-monorepo-bot
parent
728b88f9c3
commit
4775df4b44
+17
-6
@@ -10,6 +10,7 @@ import com.jetbrains.python.psi.types.engine.PyTypeEngine
|
||||
import org.HdrHistogram.Recorder
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.measureTimedValue
|
||||
|
||||
@@ -78,28 +79,38 @@ class PyTypeEvaluationAggregatesCollector : ApplicationUsagesCollector() {
|
||||
}
|
||||
}
|
||||
|
||||
fun recordPyCharmTypeEngineTime(block: () -> PyType?): PyType? {
|
||||
inline fun recordPyCharmTypeEngineTime(block: () -> PyType?): PyType? {
|
||||
val (result, duration) = measureTimedValue {
|
||||
block()
|
||||
}
|
||||
val clampedDuration = duration.coerceAtMost(MAX_TRACKABLE_DURATION)
|
||||
getOrCreateRecorder(PYCHARM_TYPE_ENGINE).recordValue(clampedDuration.inWholeMilliseconds)
|
||||
recordPyCharmDuration(duration)
|
||||
return result
|
||||
}
|
||||
|
||||
fun recordHybridTypeEngineTime(typeEngine: PyTypeEngine, block: () -> PyType?): PyType? {
|
||||
inline fun recordHybridTypeEngineTime(typeEngine: PyTypeEngine, block: () -> PyType?): PyType? {
|
||||
val (result, duration) = measureTimedValue {
|
||||
block()
|
||||
}
|
||||
recordHybridDuration(typeEngine, duration)
|
||||
return result
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal fun recordPyCharmDuration(duration: Duration) {
|
||||
val clampedDuration = duration.coerceAtMost(MAX_TRACKABLE_DURATION)
|
||||
getOrCreateRecorder(PYCHARM_TYPE_ENGINE).recordValue(clampedDuration.inWholeMilliseconds)
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal fun recordHybridDuration(typeEngine: PyTypeEngine, duration: Duration) {
|
||||
val recorderName = typeEngine.name.lowercase()
|
||||
// Only record metrics for registered external type engines
|
||||
if (recorderName !in EXTERNAL_TYPE_ENGINES) {
|
||||
LOG.error("Unknown type engine name '${typeEngine.name}' (normalized: '$recorderName'). Expected one of: ${EXTERNAL_TYPE_ENGINES.joinToString()}")
|
||||
return result
|
||||
return
|
||||
}
|
||||
val clampedDuration = duration.coerceAtMost(MAX_TRACKABLE_DURATION)
|
||||
getOrCreateRecorder(recorderName).recordValue(clampedDuration.inWholeMilliseconds)
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user