mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Deprecate MessageQueueThreadPerfStats (#52470)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52470 These metrics are not actively consumed and are highly noisy. Changelog: [Android][Removed] Deprecated MessageQueueThreadPerfStats API and replaced with stub. Reviewed By: cortinico Differential Revision: D77867087 fbshipit-source-id: 8bf7423ad60cb3bb21a5dbe94771d5a71832633d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ead669ade3
commit
3bf5cb3d0e
@@ -1561,28 +1561,26 @@ public abstract interface class com/facebook/react/bridge/queue/MessageQueueThre
|
||||
public abstract fun assertIsOnThread ()V
|
||||
public abstract fun assertIsOnThread (Ljava/lang/String;)V
|
||||
public abstract fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
|
||||
public abstract fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
|
||||
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
|
||||
public abstract fun isIdle ()Z
|
||||
public abstract fun isOnThread ()Z
|
||||
public abstract fun quitSynchronous ()V
|
||||
public abstract fun resetPerfStats ()V
|
||||
public fun resetPerfStats ()V
|
||||
public abstract fun runOnQueue (Ljava/lang/Runnable;)Z
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/queue/MessageQueueThreadImpl : com/facebook/react/bridge/queue/MessageQueueThread {
|
||||
public static final field Companion Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl$Companion;
|
||||
public synthetic fun <init> (Ljava/lang/String;Landroid/os/Looper;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;Landroid/os/Looper;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun assertIsOnThread ()V
|
||||
public fun assertIsOnThread (Ljava/lang/String;)V
|
||||
public fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
|
||||
public static final fun create (Lcom/facebook/react/bridge/queue/MessageQueueThreadSpec;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;)Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl;
|
||||
public final fun getLooper ()Landroid/os/Looper;
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
|
||||
public fun isIdle ()Z
|
||||
public fun isOnThread ()Z
|
||||
public fun quitSynchronous ()V
|
||||
public fun resetPerfStats ()V
|
||||
public fun runOnQueue (Ljava/lang/Runnable;)Z
|
||||
}
|
||||
|
||||
|
||||
+2
-8
@@ -108,14 +108,8 @@ public abstract class ReactContext extends ContextWrapper {
|
||||
mInteropModuleRegistry = new InteropModuleRegistry();
|
||||
}
|
||||
|
||||
public void resetPerfStats() {
|
||||
if (mNativeModulesMessageQueueThread != null) {
|
||||
mNativeModulesMessageQueueThread.resetPerfStats();
|
||||
}
|
||||
if (mJSMessageQueueThread != null) {
|
||||
mJSMessageQueueThread.resetPerfStats();
|
||||
}
|
||||
}
|
||||
@Deprecated(since = "MessageQueueThread perf stats are no longer collected")
|
||||
public void resetPerfStats() {}
|
||||
|
||||
public void setJSExceptionHandler(@Nullable JSExceptionHandler jSExceptionHandler) {
|
||||
mJSExceptionHandler = jSExceptionHandler;
|
||||
|
||||
+5
-2
@@ -55,13 +55,16 @@ public interface MessageQueueThread {
|
||||
* Returns the perf counters taken when the framework was started. This method is intended to be
|
||||
* used for instrumentation purposes.
|
||||
*/
|
||||
public fun getPerfStats(): MessageQueueThreadPerfStats?
|
||||
@Deprecated("MessageQueueThread perf stats are no longer collected")
|
||||
@Suppress("DEPRECATION")
|
||||
public fun getPerfStats(): MessageQueueThreadPerfStats? = null
|
||||
|
||||
/**
|
||||
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is
|
||||
* intended to be used for instrumentation purposes.
|
||||
*/
|
||||
public fun resetPerfStats()
|
||||
@Deprecated("MessageQueueThread perf stats are no longer collected")
|
||||
public fun resetPerfStats(): Unit = Unit
|
||||
|
||||
/**
|
||||
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is
|
||||
|
||||
+5
-30
@@ -9,8 +9,6 @@ package com.facebook.react.bridge.queue
|
||||
|
||||
import android.os.Looper
|
||||
import android.os.Process
|
||||
import android.os.SystemClock
|
||||
import android.util.Pair
|
||||
import com.facebook.common.logging.FLog
|
||||
import com.facebook.proguard.annotations.DoNotStripAny
|
||||
import com.facebook.react.bridge.AssertionException
|
||||
@@ -29,7 +27,6 @@ private constructor(
|
||||
public val name: String,
|
||||
public val looper: Looper,
|
||||
exceptionHandler: QueueThreadExceptionHandler,
|
||||
private val stats: MessageQueueThreadPerfStats? = null
|
||||
) : MessageQueueThread {
|
||||
private val handler = MessageQueueThreadHandler(looper, exceptionHandler)
|
||||
private val assertionErrorMessage = "Expected to be called from the '$name' thread!"
|
||||
@@ -105,27 +102,9 @@ private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPerfStats(): MessageQueueThreadPerfStats? = stats
|
||||
|
||||
override fun resetPerfStats() {
|
||||
assignToPerfStats(stats, -1, -1)
|
||||
runOnQueue {
|
||||
val wallTime = SystemClock.uptimeMillis()
|
||||
val cpuTime = SystemClock.currentThreadTimeMillis()
|
||||
assignToPerfStats(stats, wallTime, cpuTime)
|
||||
}
|
||||
}
|
||||
|
||||
public override fun isIdle(): Boolean = looper.queue.isIdle
|
||||
|
||||
public companion object {
|
||||
private fun assignToPerfStats(stats: MessageQueueThreadPerfStats?, wall: Long, cpu: Long) {
|
||||
stats?.let { s ->
|
||||
s.wallTime = wall
|
||||
s.cpuTime = cpu
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Throws(RuntimeException::class)
|
||||
public fun create(
|
||||
@@ -160,27 +139,23 @@ private constructor(
|
||||
stackSize: Long,
|
||||
exceptionHandler: QueueThreadExceptionHandler
|
||||
): MessageQueueThreadImpl {
|
||||
val dataFuture = SimpleSettableFuture<Pair<Looper?, MessageQueueThreadPerfStats>>()
|
||||
val looperFuture = SimpleSettableFuture<Looper?>()
|
||||
val bgThread =
|
||||
Thread(
|
||||
null,
|
||||
{
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY)
|
||||
Looper.prepare()
|
||||
val stats = MessageQueueThreadPerfStats()
|
||||
val wallTime = SystemClock.uptimeMillis()
|
||||
val cpuTime = SystemClock.currentThreadTimeMillis()
|
||||
assignToPerfStats(stats, wallTime, cpuTime)
|
||||
dataFuture.set(Pair(Looper.myLooper(), stats))
|
||||
looperFuture.set(Looper.myLooper())
|
||||
Looper.loop()
|
||||
},
|
||||
"mqt_$name",
|
||||
stackSize)
|
||||
bgThread.start()
|
||||
|
||||
val pair = dataFuture.getOrThrow()
|
||||
val looper = pair?.first ?: throw RuntimeException("Looper not found for thread")
|
||||
return MessageQueueThreadImpl(name, looper, exceptionHandler, pair.second)
|
||||
val looper =
|
||||
looperFuture.getOrThrow() ?: throw RuntimeException("Looper not found for thread")
|
||||
return MessageQueueThreadImpl(name, looper, exceptionHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -8,6 +8,7 @@
|
||||
package com.facebook.react.bridge.queue
|
||||
|
||||
/** This class holds perf counters' values at the beginning of an RN startup. */
|
||||
@Deprecated("MessageQueueThread perf stats are no longer collected")
|
||||
public class MessageQueueThreadPerfStats {
|
||||
@JvmField public var wallTime: Long = 0
|
||||
@JvmField public var cpuTime: Long = 0
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ private constructor(
|
||||
public const val DEFAULT_STACK_SIZE_BYTES: Long = 0
|
||||
|
||||
@JvmStatic
|
||||
@Deprecated("Use newBackgroundThreadSpec")
|
||||
public fun newUIBackgroundTreadSpec(name: String): MessageQueueThreadSpec =
|
||||
MessageQueueThreadSpec(ThreadType.NEW_BACKGROUND, name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user