Skip to content

Commit

Permalink
Introduce NativeModulePerfLogger
Browse files Browse the repository at this point in the history
Summary:
## Description
This diff introduces `NativeModulePerfLogger`, its BUCK, Cocoapod, android-ndk targets. This diff also wires up those targets into the React Native bridge and TurboModules targets, so that we get signal on if the code compiles.

This diff also introduces `TurboModulePerfLogger`, which is a namespace that holds the `NativeModulePerfLogger` that'll do perf-logging for TurboModules.

## How will perflogging work on iOS?
1. Each application will, during React Native initialization, create a NativeModule perf logger.
2. If TurboModules are enabled, we'll call `TurboModulePerfLogger::setInstance(perfLogger)`. If TurboModules are disabled, we'll call `NativeModulePerfLogger::setInstance(perfLogger)`.
3. TurboModules, when they're created and used, will log events via `TurboModulePerfLogger::getInstance()`. NativeModules (i.e: bridge modules), when they're created and used, will log events via the `NativeModulePerfLogger::getInstance()`.

> **Note:** The NativeModule system will log events for non-TurboModules as well. Maybe we should log events for only NativeModules that conform to the `TurboModule` interface, when TurboModules are disabled. This'll ensure a fair comparison between the two systems.

## How will perflogging work on Android?
Please see the subsequent diff.

allow-large-files

Changelog:
[Both][Added] - Introduce `NativeModulePerfLogger`

Reviewed By: PeteTheHeat

Differential Revision: D21318053

fbshipit-source-id: 6ddf5b5a80bdc4076d2dd6588067e2b0ec8c2c6b
  • Loading branch information
RSNara authored and facebook-github-bot committed May 14, 2020
1 parent c3a3d42 commit 0486640
Show file tree
Hide file tree
Showing 14 changed files with 488 additions and 2 deletions.
27 changes: 25 additions & 2 deletions RNTester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/ARTHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -107,6 +108,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/CoreModulesHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -115,13 +117,15 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/Default (1000.0.0):
- Folly (= 2020.01.13.00)
- glog
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/DevSupport (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -132,6 +136,7 @@ PODS:
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-jsinspector (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTActionSheetHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -140,6 +145,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTAnimationHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -148,6 +154,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTBlobHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -156,6 +163,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTImageHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -164,6 +172,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTLinkingHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -172,6 +181,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTNetworkHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -180,6 +190,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTPushNotificationHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -188,6 +199,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTSettingsHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -196,6 +208,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTTextHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -204,6 +217,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTVibrationHeaders (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -212,6 +226,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-Core/RCTWebSocket (1000.0.0):
- Folly (= 2020.01.13.00)
Expand All @@ -220,6 +235,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsiexecutor (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- Yoga
- React-CoreModules (1000.0.0):
- FBReactNativeSpec (= 1000.0.0)
Expand Down Expand Up @@ -255,6 +271,7 @@ PODS:
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-jsinspector (1000.0.0)
- React-perflogger (1000.0.0)
- React-RCTActionSheet (1000.0.0):
- React-Core/RCTActionSheetHeaders (= 1000.0.0)
- React-RCTAnimation (1000.0.0):
Expand Down Expand Up @@ -329,6 +346,7 @@ PODS:
- React-Core (= 1000.0.0)
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- ReactCommon/turbomodule/samples (1000.0.0):
- DoubleConversion
- Folly (= 2020.01.13.00)
Expand All @@ -337,6 +355,7 @@ PODS:
- React-Core (= 1000.0.0)
- React-cxxreact (= 1000.0.0)
- React-jsi (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- ReactCommon/turbomodule/core (= 1000.0.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -380,6 +399,7 @@ DEPENDENCIES:
- React-jsi (from `../ReactCommon/jsi`)
- React-jsiexecutor (from `../ReactCommon/jsiexecutor`)
- React-jsinspector (from `../ReactCommon/jsinspector`)
- React-perflogger (from `../ReactCommon/perflogger`)
- React-RCTActionSheet (from `../Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../Libraries/NativeAnimation`)
- React-RCTBlob (from `../Libraries/Blob`)
Expand Down Expand Up @@ -444,6 +464,8 @@ EXTERNAL SOURCES:
:path: "../ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../ReactCommon/jsinspector"
React-perflogger:
:path: "../ReactCommon/perflogger"
React-RCTActionSheet:
:path: "../Libraries/ActionSheetIOS"
React-RCTAnimation:
Expand Down Expand Up @@ -495,12 +517,13 @@ SPEC CHECKSUMS:
React: cafb3c2321f7df55ce90dbf29d513799a79e4418
React-ART: df0460bdff42ef039e28ee3ffd41f50b75644788
React-callinvoker: 0dada022d38b73e6e15b33e2a96476153f79bbf6
React-Core: 08c69f013e6fd654ea8f9fd84bbd66780a54d886
React-Core: d85e4563acbfbb6e6be7414a813ad55d05d675df
React-CoreModules: d13d148c851af5780f864be74bc2165140923dc7
React-cxxreact: b43a94e679b307660de530a3af872ab4c7d9925d
React-jsi: fe94132da767bfc4801968c2a12abae43e9a833e
React-jsiexecutor: 55eff40b2e0696e7a979016e321793ec8b28a2ac
React-jsinspector: 7fbf9b42b58b02943a0d89b0ba9fff0070f2de98
React-perflogger: d32d3423e466a825ef2e9934fe9d62b149e5d9f8
React-RCTActionSheet: 51c43beeb74ef41189e87fe9823e53ebf6210359
React-RCTAnimation: 9d09196c641c1ebfef3a4e9ae670bcda5fadb420
React-RCTBlob: 715489626cf44d28ee51e5277a4d559167351696
Expand All @@ -513,7 +536,7 @@ SPEC CHECKSUMS:
React-RCTText: 6c01963d3e562109f5548262b09b1b2bc260dd60
React-RCTVibration: d42d73dafd9f63cf758656ee743aa80c566798ff
React-runtimeexecutor: 60dd6204a13f68a1aa1118870edcc604a791df2b
ReactCommon: 39e00b754f5e1628804fab28f44146d06280f700
ReactCommon: 511b4a9ea129c129c6dbc982942007d195903a9a
Yoga: f7fa200d8c49f97b54c9421079e781fb900b5cae
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

Expand Down
1 change: 1 addition & 0 deletions React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Pod::Spec.new do |s|

s.dependency "Folly", folly_version
s.dependency "React-cxxreact", version
s.dependency "React-perflogger", version
s.dependency "React-jsi", version
s.dependency "React-jsiexecutor", version
s.dependency "Yoga"
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/react/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ $(call import-module,cxxreact)
$(call import-module,jsi)
$(call import-module,jsiexecutor)
$(call import-module,callinvoker)
$(call import-module,perflogger)
$(call import-module,hermes)
$(call import-module,runtimeexecutor)

Expand Down
1 change: 1 addition & 0 deletions ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Pod::Spec.new do |s|

s.subspec "turbomodule" do |ss|
ss.dependency "React-callinvoker", version
ss.dependency "React-perflogger", version
ss.dependency "React-Core", version
ss.dependency "React-cxxreact", version
ss.dependency "React-jsi", version
Expand Down
5 changes: 5 additions & 0 deletions ReactCommon/perflogger/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Checks: '>
clang-diagnostic-*,
'
...
25 changes: 25 additions & 0 deletions ReactCommon/perflogger/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Header search path for all source files in this module.
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ReactCommon

# Header search path for modules that depend on this module
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall

# Name of this module.
LOCAL_MODULE := perflogger

# Compile all local c++ files under ./ReactCommon
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp)

# Build the files in this directory as a shared library
include $(BUILD_STATIC_LIBRARY)
35 changes: 35 additions & 0 deletions ReactCommon/perflogger/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "rn_xplat_cxx_library", "subdir_glob")

rn_xplat_cxx_library(
name = "perflogger",
srcs = glob(["**/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob(
[
("ReactCommon", "*.h"),
],
prefix = "ReactCommon",
),
compiler_flags = [
"-fexceptions",
"-frtti",
"-std=c++14",
"-Wall",
"-Wno-global-constructors",
],
fbandroid_labels = [
"supermodule:android/default/public.react_native.infra",
],
fbobjc_labels = [
"supermodule:ios/default/public.react_native.infra",
],
platforms = (ANDROID, APPLE),
preferred_linkage = "static",
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
visibility = [
"PUBLIC",
],
)
34 changes: 34 additions & 0 deletions ReactCommon/perflogger/React-perflogger.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

require "json"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']

source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
source[:commit] = `git rev-parse HEAD`.strip
else
source[:tag] = "v#{version}"
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2020.01.13.00'
boost_compiler_flags = '-Wno-documentation'

Pod::Spec.new do |s|
s.name = "React-perflogger"
s.version = version
s.summary = "-" # TODO
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "10.0", :tvos => "10.0" }
s.source = source
s.source_files = "**/*.{cpp,h}"
s.header_dir = "ReactCommon"
end
Loading

0 comments on commit 0486640

Please sign in to comment.