Skip to content

Commit 3bf5cb3

Browse files
javachefacebook-github-bot
authored andcommitted
Deprecate MessageQueueThreadPerfStats (#52470)
Summary: Pull Request resolved: #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
1 parent ead669a commit 3bf5cb3

6 files changed

Lines changed: 17 additions & 45 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,28 +1561,26 @@ public abstract interface class com/facebook/react/bridge/queue/MessageQueueThre
15611561
public abstract fun assertIsOnThread ()V
15621562
public abstract fun assertIsOnThread (Ljava/lang/String;)V
15631563
public abstract fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
1564-
public abstract fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
1564+
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
15651565
public abstract fun isIdle ()Z
15661566
public abstract fun isOnThread ()Z
15671567
public abstract fun quitSynchronous ()V
1568-
public abstract fun resetPerfStats ()V
1568+
public fun resetPerfStats ()V
15691569
public abstract fun runOnQueue (Ljava/lang/Runnable;)Z
15701570
}
15711571

15721572
public final class com/facebook/react/bridge/queue/MessageQueueThreadImpl : com/facebook/react/bridge/queue/MessageQueueThread {
15731573
public static final field Companion Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl$Companion;
1574-
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
1574+
public synthetic fun <init> (Ljava/lang/String;Landroid/os/Looper;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
15751575
public fun assertIsOnThread ()V
15761576
public fun assertIsOnThread (Ljava/lang/String;)V
15771577
public fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
15781578
public static final fun create (Lcom/facebook/react/bridge/queue/MessageQueueThreadSpec;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;)Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl;
15791579
public final fun getLooper ()Landroid/os/Looper;
15801580
public final fun getName ()Ljava/lang/String;
1581-
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
15821581
public fun isIdle ()Z
15831582
public fun isOnThread ()Z
15841583
public fun quitSynchronous ()V
1585-
public fun resetPerfStats ()V
15861584
public fun runOnQueue (Ljava/lang/Runnable;)Z
15871585
}
15881586

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,8 @@ protected void initializeInteropModules() {
108108
mInteropModuleRegistry = new InteropModuleRegistry();
109109
}
110110

111-
public void resetPerfStats() {
112-
if (mNativeModulesMessageQueueThread != null) {
113-
mNativeModulesMessageQueueThread.resetPerfStats();
114-
}
115-
if (mJSMessageQueueThread != null) {
116-
mJSMessageQueueThread.resetPerfStats();
117-
}
118-
}
111+
@Deprecated(since = "MessageQueueThread perf stats are no longer collected")
112+
public void resetPerfStats() {}
119113

120114
public void setJSExceptionHandler(@Nullable JSExceptionHandler jSExceptionHandler) {
121115
mJSExceptionHandler = jSExceptionHandler;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThread.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ public interface MessageQueueThread {
5555
* Returns the perf counters taken when the framework was started. This method is intended to be
5656
* used for instrumentation purposes.
5757
*/
58-
public fun getPerfStats(): MessageQueueThreadPerfStats?
58+
@Deprecated("MessageQueueThread perf stats are no longer collected")
59+
@Suppress("DEPRECATION")
60+
public fun getPerfStats(): MessageQueueThreadPerfStats? = null
5961

6062
/**
6163
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is
6264
* intended to be used for instrumentation purposes.
6365
*/
64-
public fun resetPerfStats()
66+
@Deprecated("MessageQueueThread perf stats are no longer collected")
67+
public fun resetPerfStats(): Unit = Unit
6568

6669
/**
6770
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadImpl.kt

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ package com.facebook.react.bridge.queue
99

1010
import android.os.Looper
1111
import android.os.Process
12-
import android.os.SystemClock
13-
import android.util.Pair
1412
import com.facebook.common.logging.FLog
1513
import com.facebook.proguard.annotations.DoNotStripAny
1614
import com.facebook.react.bridge.AssertionException
@@ -29,7 +27,6 @@ private constructor(
2927
public val name: String,
3028
public val looper: Looper,
3129
exceptionHandler: QueueThreadExceptionHandler,
32-
private val stats: MessageQueueThreadPerfStats? = null
3330
) : MessageQueueThread {
3431
private val handler = MessageQueueThreadHandler(looper, exceptionHandler)
3532
private val assertionErrorMessage = "Expected to be called from the '$name' thread!"
@@ -105,27 +102,9 @@ private constructor(
105102
}
106103
}
107104

108-
override fun getPerfStats(): MessageQueueThreadPerfStats? = stats
109-
110-
override fun resetPerfStats() {
111-
assignToPerfStats(stats, -1, -1)
112-
runOnQueue {
113-
val wallTime = SystemClock.uptimeMillis()
114-
val cpuTime = SystemClock.currentThreadTimeMillis()
115-
assignToPerfStats(stats, wallTime, cpuTime)
116-
}
117-
}
118-
119105
public override fun isIdle(): Boolean = looper.queue.isIdle
120106

121107
public companion object {
122-
private fun assignToPerfStats(stats: MessageQueueThreadPerfStats?, wall: Long, cpu: Long) {
123-
stats?.let { s ->
124-
s.wallTime = wall
125-
s.cpuTime = cpu
126-
}
127-
}
128-
129108
@JvmStatic
130109
@Throws(RuntimeException::class)
131110
public fun create(
@@ -160,27 +139,23 @@ private constructor(
160139
stackSize: Long,
161140
exceptionHandler: QueueThreadExceptionHandler
162141
): MessageQueueThreadImpl {
163-
val dataFuture = SimpleSettableFuture<Pair<Looper?, MessageQueueThreadPerfStats>>()
142+
val looperFuture = SimpleSettableFuture<Looper?>()
164143
val bgThread =
165144
Thread(
166145
null,
167146
{
168147
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY)
169148
Looper.prepare()
170-
val stats = MessageQueueThreadPerfStats()
171-
val wallTime = SystemClock.uptimeMillis()
172-
val cpuTime = SystemClock.currentThreadTimeMillis()
173-
assignToPerfStats(stats, wallTime, cpuTime)
174-
dataFuture.set(Pair(Looper.myLooper(), stats))
149+
looperFuture.set(Looper.myLooper())
175150
Looper.loop()
176151
},
177152
"mqt_$name",
178153
stackSize)
179154
bgThread.start()
180155

181-
val pair = dataFuture.getOrThrow()
182-
val looper = pair?.first ?: throw RuntimeException("Looper not found for thread")
183-
return MessageQueueThreadImpl(name, looper, exceptionHandler, pair.second)
156+
val looper =
157+
looperFuture.getOrThrow() ?: throw RuntimeException("Looper not found for thread")
158+
return MessageQueueThreadImpl(name, looper, exceptionHandler)
184159
}
185160
}
186161
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadPerfStats.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.facebook.react.bridge.queue
99

1010
/** This class holds perf counters' values at the beginning of an RN startup. */
11+
@Deprecated("MessageQueueThread perf stats are no longer collected")
1112
public class MessageQueueThreadPerfStats {
1213
@JvmField public var wallTime: Long = 0
1314
@JvmField public var cpuTime: Long = 0

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadSpec.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private constructor(
2626
public const val DEFAULT_STACK_SIZE_BYTES: Long = 0
2727

2828
@JvmStatic
29+
@Deprecated("Use newBackgroundThreadSpec")
2930
public fun newUIBackgroundTreadSpec(name: String): MessageQueueThreadSpec =
3031
MessageQueueThreadSpec(ThreadType.NEW_BACKGROUND, name)
3132

0 commit comments

Comments
 (0)