Instrument async method call batch preprocessing

Summary:
NativeModule async method calls are queued up on the JS side, and flushed to C++ on every Native -> JS call. Before we execute the batch of async NativeModule method calls, we convert it (a JS object) from a `jsi::Value` to a `folly::dynamic` object in `JSIExecutor::callNativeModules`. Then, in `JsToNativeBridge::callNativeModules`, we convert this `folly::dynamic` object into an `std::vector<MethodCall>`, before finally looping over these `MethodCall`s and invoking each NativeModule async method call.

The markers I'm adding in this diff measure this `jsi::Value -> folly::dynamic -> std::vector<MethodCall>` pre-processing.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D21435455

fbshipit-source-id: 4c5a9e2b73c1a2a49d7a8f224a0d30afe3a0c79c
This commit is contained in:
Ramanpreet Nara
2020-05-13 20:28:17 -07:00
committed by Facebook GitHub Bot
parent 9f310a2b15
commit bf0e516086
2 changed files with 9 additions and 1 deletions
+6 -1
View File
@@ -8,6 +8,7 @@
#include "NativeToJsBridge.h"
#include <ReactCommon/CallInvoker.h>
#include <ReactCommon/NativeModulePerfLogger.h>
#include <folly/MoveWrapper.h>
#include <folly/json.h>
#include <glog/logging.h>
@@ -55,10 +56,14 @@ class JsToNativeBridge : public react::ExecutorDelegate {
m_batchHadNativeModuleOrTurboModuleCalls =
m_batchHadNativeModuleOrTurboModuleCalls || !calls.empty();
std::vector<MethodCall> methodCalls = parseMethodCalls(std::move(calls));
NativeModulePerfLogger::getInstance().asyncMethodCallBatchPreprocessEnd(
(int)methodCalls.size());
// An exception anywhere in here stops processing of the batch. This
// was the behavior of the Android bridge, and since exception handling
// terminates the whole bridge, there's not much point in continuing.
for (auto &call : parseMethodCalls(std::move(calls))) {
for (auto &call : methodCalls) {
m_registry->callNativeMethod(
call.moduleId, call.methodId, std::move(call.arguments), call.callId);
}