Skip to content

Commit

Permalink
Add thread idle indicator (#39206)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39206

Add thread idle indicator to UI, JS and native modules threads to the RN perf monitor.

Changelog:
[Internal] - Add thread idle state to perf monitor

Reviewed By: rshest

Differential Revision: D48673070

fbshipit-source-id: e121eaf2a3149f0d0605681249808fc8dfaa5010
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Sep 13, 2023
1 parent b15a2c3 commit 5a926c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,18 @@ public boolean runOnJSQueueThread(Runnable runnable) {
return Assertions.assertNotNull(mJSMessageQueueThread).runOnQueue(runnable);
}

public @Nullable MessageQueueThread getJSMessageQueueThread() {
return mJSMessageQueueThread;
}

public @Nullable MessageQueueThread getNativeModulesMessageQueueThread() {
return mNativeModulesMessageQueueThread;
}

public @Nullable MessageQueueThread getUiMessageQueueThread() {
return mUiMessageQueueThread;
}

/**
* Passes the given exception to the current {@link JSExceptionHandler} if one exists, rethrowing
* otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@ public interface MessageQueueThread {
*/
@DoNotStrip
void resetPerfStats();

/** Returns true if the message queue is idle */
@DoNotStrip
boolean isIdle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public void run() {
});
}

@DoNotStrip
@Override
public boolean isIdle() {
return mLooper.getQueue().isIdle();
}

private static void assignToPerfStats(MessageQueueThreadPerfStats stats, long wall, long cpu) {
stats.wallTime = wall;
stats.cpuTime = cpu;
Expand Down

0 comments on commit 5a926c5

Please sign in to comment.