add some markers to breakdown ReactInstanceManager.processPackages

Reviewed By: alexeylang

Differential Revision: D4469884

fbshipit-source-id: 891a37aaf2fc472b2614e551c3564075a1a43484
This commit is contained in:
Aaron Chiu 2017-01-26 18:09:10 -08:00 committed by Facebook Github Bot
parent a83af44a59
commit 0bfb426877
4 changed files with 46 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.devsupport.HMRClient;
import com.facebook.react.devsupport.JSCHeapCapture;
@ -46,6 +47,8 @@ import com.facebook.systrace.Systrace;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_START;
/**
* Package defining core framework modules (e.g. UIManager). It should be used for modules that
@ -68,7 +71,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M
JSCSamplingProfiler.class,
}
)
/* package */ class CoreModulesPackage extends LazyReactPackage {
/* package */ class CoreModulesPackage extends LazyReactPackage implements ReactPackageLogger {
private final ReactInstanceManager mReactInstanceManager;
private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler;
@ -198,8 +201,14 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M
@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
ReactMarker.logMarker(
ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START);
// This has to be done via reflection or we break open source.
return LazyReactPackage.getReactModuleInfoProviderViaReflection(this);
ReactModuleInfoProvider reactModuleInfoProvider =
LazyReactPackage.getReactModuleInfoProviderViaReflection(this);
ReactMarker.logMarker(
ReactMarkerConstants.CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END);
return reactModuleInfoProvider;
}
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
@ -218,4 +227,14 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
}
}
@Override
public void startProcessPackage() {
ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_START);
}
@Override
public void endProcessPackage() {
ReactMarker.logMarker(PROCESS_CORE_REACT_PACKAGE_END);
}
}

View File

@ -965,6 +965,9 @@ public class ReactInstanceManager {
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
.arg("className", reactPackage.getClass().getSimpleName())
.flush();
if (reactPackage instanceof ReactPackageLogger) {
((ReactPackageLogger) reactPackage).startProcessPackage();
}
if (mLazyNativeModulesEnabled && reactPackage instanceof LazyReactPackage) {
LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
ReactModuleInfoProvider instance = lazyReactPackage.getReactModuleInfoProvider();
@ -987,6 +990,9 @@ public class ReactInstanceManager {
for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
jsModulesBuilder.add(jsModuleClass);
}
if (reactPackage instanceof ReactPackageLogger) {
((ReactPackageLogger) reactPackage).endProcessPackage();
}
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}

View File

@ -0,0 +1,12 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.react;
/**
* Interface for the bridge to call for TTI start and end markers.
*/
public interface ReactPackageLogger {
void startProcessPackage();
void endProcessPackage();
}

View File

@ -7,6 +7,7 @@ package com.facebook.react.bridge;
*/
public class ReactMarkerConstants {
// TODO convert to ints so we don't have to do String compares
public static final String CREATE_REACT_CONTEXT_START = "CREATE_REACT_CONTEXT_START";
public static final String CREATE_REACT_CONTEXT_END = "CREATE_REACT_CONTEXT_END";
public static final String PROCESS_PACKAGES_START = "PROCESS_PACKAGES_START";
@ -35,4 +36,10 @@ public class ReactMarkerConstants {
"CREATE_UI_MANAGER_MODULE_CONSTANTS_END";
public static final String CREATE_MODULE_START = "CREATE_MODULE_START";
public static final String CREATE_MODULE_END = "CREATE_MODULE_END";
public static final String PROCESS_CORE_REACT_PACKAGE_START = "PROCESS_CORE_REACT_PACKAGE_START";
public static final String PROCESS_CORE_REACT_PACKAGE_END = "PROCESS_CORE_REACT_PACKAGE_END";
public static final String CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START =
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_START";
public static final String CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END =
"CORE_REACT_PACKAGE_GET_REACT_MODULE_INFO_PROVIDER_END";
}