Add more performance logs and Systrace events for RAM and bridge startup
Summary: Add more performance logs and Systrace events for RAM and bridge startup. Reviewed By: javache Differential Revision: D3126321 fb-gh-sync-id: bb059f1f0302b751c6bf97bbe6bdbaf0aba27e21 fbshipit-source-id: bb059f1f0302b751c6bf97bbe6bdbaf0aba27e21
This commit is contained in:
parent
b5106a8fca
commit
ef8ad82a62
|
@ -482,6 +482,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
|||
|
||||
- (void)didFinishLoading
|
||||
{
|
||||
RCTPerformanceLoggerEnd(RCTPLBridgeStartup);
|
||||
_loading = NO;
|
||||
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
||||
for (dispatch_block_t call in _pendingCalls) {
|
||||
|
|
|
@ -111,6 +111,7 @@ static RCTBridge *RCTCurrentBridgeInstance = nil;
|
|||
launchOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
RCTPerformanceLoggerStart(RCTPLBridgeStartup);
|
||||
RCTPerformanceLoggerStart(RCTPLTTI);
|
||||
|
||||
_delegate = delegate;
|
||||
|
@ -126,6 +127,7 @@ static RCTBridge *RCTCurrentBridgeInstance = nil;
|
|||
launchOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
RCTPerformanceLoggerStart(RCTPLBridgeStartup);
|
||||
RCTPerformanceLoggerStart(RCTPLTTI);
|
||||
|
||||
_bundleURL = bundleURL;
|
||||
|
|
|
@ -14,12 +14,17 @@
|
|||
typedef NS_ENUM(NSUInteger, RCTPLTag) {
|
||||
RCTPLScriptDownload = 0,
|
||||
RCTPLScriptExecution,
|
||||
RCTPLRAMBundleLoad,
|
||||
RCTPLRAMStartupCodeSize,
|
||||
RCTPLRAMNativeRequiresCount,
|
||||
RCTPLRAMNativeRequiresSize,
|
||||
RCTPLNativeModuleInit,
|
||||
RCTPLNativeModuleMainThread,
|
||||
RCTPLNativeModulePrepareConfig,
|
||||
RCTPLNativeModuleInjectConfig,
|
||||
RCTPLNativeModuleMainThreadUsesCount,
|
||||
RCTPLJSCExecutorSetup,
|
||||
RCTPLBridgeStartup,
|
||||
RCTPLTTI,
|
||||
RCTPLBundleSize,
|
||||
RCTPLSize
|
||||
|
@ -45,6 +50,11 @@ RCT_EXTERN void RCTPerformanceLoggerEnd(RCTPLTag tag);
|
|||
*/
|
||||
RCT_EXTERN void RCTPerformanceLoggerSet(RCTPLTag tag, int64_t value);
|
||||
|
||||
/**
|
||||
* Adds given value to the current value for a metric with given tag.
|
||||
*/
|
||||
RCT_EXTERN void RCTPerformanceLoggerAdd(RCTPLTag tag, int64_t value);
|
||||
|
||||
/**
|
||||
* Starts an additional measurement for a metric with given tag.
|
||||
* It doesn't override previous measurement, instead it'll append a new value
|
||||
|
|
|
@ -48,6 +48,12 @@ void RCTPerformanceLoggerSet(RCTPLTag tag, int64_t value)
|
|||
RCTPLData[tag][1] = value;
|
||||
}
|
||||
|
||||
void RCTPerformanceLoggerAdd(RCTPLTag tag, int64_t value)
|
||||
{
|
||||
RCTPLData[tag][0] = 0;
|
||||
RCTPLData[tag][1] += value;
|
||||
}
|
||||
|
||||
void RCTPerformanceLoggerAppendStart(RCTPLTag tag)
|
||||
{
|
||||
RCTPLData[tag][0] = CACurrentMediaTime() * 1000;
|
||||
|
@ -65,28 +71,12 @@ void RCTPerformanceLoggerAppendEnd(RCTPLTag tag)
|
|||
|
||||
NSArray<NSNumber *> *RCTPerformanceLoggerOutput(void)
|
||||
{
|
||||
return @[
|
||||
@(RCTPLData[RCTPLScriptDownload][0]),
|
||||
@(RCTPLData[RCTPLScriptDownload][1]),
|
||||
@(RCTPLData[RCTPLScriptExecution][0]),
|
||||
@(RCTPLData[RCTPLScriptExecution][1]),
|
||||
@(RCTPLData[RCTPLNativeModuleInit][0]),
|
||||
@(RCTPLData[RCTPLNativeModuleInit][1]),
|
||||
@(RCTPLData[RCTPLNativeModuleMainThread][0]),
|
||||
@(RCTPLData[RCTPLNativeModuleMainThread][1]),
|
||||
@(RCTPLData[RCTPLNativeModulePrepareConfig][0]),
|
||||
@(RCTPLData[RCTPLNativeModulePrepareConfig][1]),
|
||||
@(RCTPLData[RCTPLNativeModuleInjectConfig][0]),
|
||||
@(RCTPLData[RCTPLNativeModuleInjectConfig][1]),
|
||||
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][0]),
|
||||
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][1]),
|
||||
@(RCTPLData[RCTPLJSCExecutorSetup][0]),
|
||||
@(RCTPLData[RCTPLJSCExecutorSetup][1]),
|
||||
@(RCTPLData[RCTPLTTI][0]),
|
||||
@(RCTPLData[RCTPLTTI][1]),
|
||||
@(RCTPLData[RCTPLBundleSize][0]),
|
||||
@(RCTPLData[RCTPLBundleSize][1]),
|
||||
];
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
for (NSUInteger index = 0; index < RCTPLSize; index++) {
|
||||
[result addObject:@(RCTPLData[index][0])];
|
||||
[result addObject:@(RCTPLData[index][1])];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NSArray *RCTPerformanceLoggerLabels(void)
|
||||
|
@ -97,12 +87,17 @@ NSArray *RCTPerformanceLoggerLabels(void)
|
|||
labels = @[
|
||||
@"ScriptDownload",
|
||||
@"ScriptExecution",
|
||||
@"RAMBundleLoad",
|
||||
@"RAMStartupCodeSize",
|
||||
@"RAMNativeRequiresCount",
|
||||
@"RAMNativeRequiresSize",
|
||||
@"NativeModuleInit",
|
||||
@"NativeModuleMainThread",
|
||||
@"NativeModulePrepareConfig",
|
||||
@"NativeModuleInjectConfig",
|
||||
@"NativeModuleMainThreadUsesCount",
|
||||
@"JSCExecutorSetup",
|
||||
@"BridgeStartup",
|
||||
@"RootViewTTI",
|
||||
@"BundleSize",
|
||||
];
|
||||
|
|
|
@ -678,6 +678,8 @@ static int readBundle(FILE *fd, size_t offset, size_t length, void *ptr) {
|
|||
|
||||
- (void)registerNativeRequire
|
||||
{
|
||||
RCTPerformanceLoggerSet(RCTPLRAMNativeRequiresCount, 0);
|
||||
RCTPerformanceLoggerSet(RCTPLRAMNativeRequiresSize, 0);
|
||||
__weak RCTJSCExecutor *weakSelf = self;
|
||||
[self addSynchronousHookWithName:@"nativeRequire" usingBlock:^(NSString *moduleName) {
|
||||
RCTJSCExecutor *strongSelf = weakSelf;
|
||||
|
@ -685,6 +687,7 @@ static int readBundle(FILE *fd, size_t offset, size_t length, void *ptr) {
|
|||
return;
|
||||
}
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, [@"nativeRequire_" stringByAppendingString:moduleName], nil);
|
||||
ModuleData *data = (ModuleData *)CFDictionaryGetValue(strongSelf->_jsModules, moduleName.UTF8String);
|
||||
char bytes[data->length];
|
||||
if (readBundle(strongSelf->_bundle, data->offset, data->length, bytes) != 0) {
|
||||
|
@ -697,6 +700,10 @@ static int readBundle(FILE *fd, size_t offset, size_t length, void *ptr) {
|
|||
|
||||
CFDictionaryRemoveValue(strongSelf->_jsModules, moduleName.UTF8String);
|
||||
JSStringRelease(code);
|
||||
RCT_PROFILE_END_EVENT(0, @"js_call", nil);
|
||||
|
||||
RCTPerformanceLoggerAdd(RCTPLRAMNativeRequiresCount, 1);
|
||||
RCTPerformanceLoggerAdd(RCTPLRAMNativeRequiresSize, data->length);
|
||||
|
||||
if (!result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
@ -709,6 +716,7 @@ static int readBundle(FILE *fd, size_t offset, size_t length, void *ptr) {
|
|||
|
||||
- (NSData *)loadRAMBundle:(NSURL *)sourceURL error:(NSError **)error
|
||||
{
|
||||
RCTPerformanceLoggerStart(RCTPLRAMBundleLoad);
|
||||
_bundle = fopen(sourceURL.path.UTF8String, "r");
|
||||
if (!_bundle) {
|
||||
if (error) {
|
||||
|
@ -793,6 +801,8 @@ static int readBundle(FILE *fd, size_t offset, size_t length, void *ptr) {
|
|||
free(startupCode);
|
||||
return nil;
|
||||
}
|
||||
RCTPerformanceLoggerEnd(RCTPLRAMBundleLoad);
|
||||
RCTPerformanceLoggerSet(RCTPLRAMStartupCodeSize, startupData->length);
|
||||
return [NSData dataWithBytesNoCopy:startupCode length:startupData->length freeWhenDone:YES];
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,8 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
|
|||
|
||||
+ (void)reload
|
||||
{
|
||||
[RCTProfilingBridge() reload];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification
|
||||
object:NULL];
|
||||
}
|
||||
|
||||
+ (void)toggle:(UIButton *)target
|
||||
|
|
Loading…
Reference in New Issue