Fabric: Systraces are back

Summary:
It's better to comment `DWITH_FBSYSTRACE` out in BUCK files instead of removing them from the code.
I'll publish the BUCK changes as separate diff for simpler backout in the future.

Reviewed By: mdvacca

Differential Revision: D14019272

fbshipit-source-id: 8b322b5c115efe33c15929e008b97a05220813df
This commit is contained in:
Valentin Shergin 2019-02-11 15:51:34 -08:00 committed by Facebook Github Bot
parent 78be6efda9
commit 77838b5504
8 changed files with 56 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "RootShadowNode.h"
#include <react/components/view/conversions.h>
#include <react/debug/SystraceSection.h>
namespace facebook {
namespace react {
@ -15,6 +16,7 @@ namespace react {
const char RootComponentName[] = "RootView";
void RootShadowNode::layout() {
SystraceSection s("RootShadowNode::layout");
ensureUnsealed();
layout(getProps()->layoutContext);

View File

@ -14,6 +14,7 @@
#include <react/core/LayoutConstraints.h>
#include <react/core/LayoutContext.h>
#include <react/debug/DebugStringConvertibleItem.h>
#include <react/debug/SystraceSection.h>
#include <yoga/Yoga.h>
namespace facebook {
@ -116,6 +117,7 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
yogaConfig_.pointScaleFactor = layoutContext.pointScaleFactor;
{
SystraceSection s("YogaLayoutableShadowNode::YGNodeCalculateLayout");
YGNodeCalculateLayout(
&yogaNode_, YGUndefined, YGUndefined, YGDirectionInherit);
@ -157,6 +159,7 @@ YGNode *YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
YGNode *oldYogaNode,
YGNode *parentYogaNode,
int childIndex) {
SystraceSection s("YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector");
// At this point it is garanteed that all shadow nodes associated with yoga
// nodes are `YogaLayoutableShadowNode` subclasses.
@ -175,6 +178,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
SystraceSection s(
"YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector");
auto shadowNodeRawPtr =
static_cast<YogaLayoutableShadowNode *>(yogaNode->getContext());

View File

@ -10,6 +10,7 @@
#include <folly/dynamic.h>
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
#include <react/debug/SystraceSection.h>
#include "RawEvent.h"
@ -64,6 +65,8 @@ void EventEmitter::dispatchEvent(
const std::string &type,
const ValueFactory &payloadFactory,
const EventPriority &priority) const {
SystraceSection s("EventEmitter::dispatchEvent");
auto eventDispatcher = eventDispatcher_.lock();
if (!eventDispatcher) {
return;

View File

@ -7,6 +7,7 @@
#include <better/map.h>
#include <react/core/LayoutableShadowNode.h>
#include <react/debug/SystraceSection.h>
#include "ShadowView.h"
namespace facebook {
@ -215,6 +216,8 @@ static void calculateShadowViewMutations(
ShadowViewMutationList calculateShadowViewMutations(
const ShadowNode &oldRootShadowNode,
const ShadowNode &newRootShadowNode) {
SystraceSection s("calculateShadowViewMutations");
// Root shadow nodes must have same tag.
assert(oldRootShadowNode.getTag() == newRootShadowNode.getTag());

View File

@ -8,6 +8,7 @@
#include <jsi/jsi.h>
#include <react/core/LayoutContext.h>
#include <react/debug/SystraceSection.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/TimeUtils.h>
#include <react/uimanager/UIManager.h>
@ -69,6 +70,8 @@ void Scheduler::startSurface(
const folly::dynamic &initialProps,
const LayoutConstraints &layoutConstraints,
const LayoutContext &layoutContext) const {
SystraceSection s("Scheduler::startSurface");
auto shadowTree =
std::make_unique<ShadowTree>(surfaceId, layoutConstraints, layoutContext);
shadowTree->setDelegate(this);
@ -86,7 +89,9 @@ void Scheduler::startSurface(
void Scheduler::renderTemplateToSurface(
SurfaceId surfaceId,
const std::string &uiTemplate) {
SystraceSection s("Scheduler::renderTemplateToSurface");
long commitStartTime = getTime();
try {
if (uiTemplate.size() == 0) {
return;
@ -118,6 +123,8 @@ void Scheduler::renderTemplateToSurface(
}
void Scheduler::stopSurface(SurfaceId surfaceId) const {
SystraceSection s("Scheduler::stopSurface");
long commitStartTime = getTime();
shadowTreeRegistry_.visit(
surfaceId, [commitStartTime](const ShadowTree &shadowTree) {
@ -147,6 +154,8 @@ Size Scheduler::measureSurface(
SurfaceId surfaceId,
const LayoutConstraints &layoutConstraints,
const LayoutContext &layoutContext) const {
SystraceSection s("Scheduler::measureSurface");
long commitStartTime = getTime();
Size size;
@ -168,6 +177,8 @@ void Scheduler::constraintSurfaceLayout(
SurfaceId surfaceId,
const LayoutConstraints &layoutConstraints,
const LayoutContext &layoutContext) const {
SystraceSection s("Scheduler::constraintSurfaceLayout");
long commitStartTime = getTime();
shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree &shadowTree) {
@ -196,6 +207,8 @@ void Scheduler::shadowTreeDidCommit(
const ShadowViewMutationList &mutations,
long commitStartTime,
long layoutTime) const {
SystraceSection s("Scheduler::shadowTreeDidCommit");
if (delegate_) {
delegate_->schedulerDidFinishTransaction(
shadowTree.getSurfaceId(), mutations, commitStartTime, layoutTime);
@ -208,6 +221,8 @@ void Scheduler::uiManagerDidFinishTransaction(
SurfaceId surfaceId,
const SharedShadowNodeUnsharedList &rootChildNodes,
long startCommitTime) {
SystraceSection s("Scheduler::uiManagerDidFinishTransaction");
shadowTreeRegistry_.visit(surfaceId, [&](const ShadowTree &shadowTree) {
shadowTree.commit(
[&](const SharedRootShadowNode &oldRootShadowNode) {
@ -221,6 +236,8 @@ void Scheduler::uiManagerDidFinishTransaction(
void Scheduler::uiManagerDidCreateShadowNode(
const SharedShadowNode &shadowNode) {
SystraceSection s("Scheduler::uiManagerDidCreateShadowNode");
if (delegate_) {
auto layoutableShadowNode =
dynamic_cast<const LayoutableShadowNode *>(shadowNode.get());

View File

@ -7,6 +7,7 @@
#include <react/core/LayoutContext.h>
#include <react/core/LayoutPrimitives.h>
#include <react/debug/SystraceSection.h>
#include <react/mounting/Differentiator.h>
#include <react/mounting/ShadowViewMutation.h>
#include <react/uimanager/TimeUtils.h>
@ -115,6 +116,8 @@ void ShadowTree::commit(
ShadowTreeCommitTransaction transaction,
long commitStartTime,
int *revision) const {
SystraceSection s("ShadowTree::commit");
int attempts = 0;
while (true) {
@ -133,6 +136,8 @@ bool ShadowTree::tryCommit(
ShadowTreeCommitTransaction transaction,
long commitStartTime,
int *revision) const {
SystraceSection s("ShadowTree::tryCommit");
SharedRootShadowNode oldRootShadowNode;
{
@ -192,6 +197,8 @@ bool ShadowTree::tryCommit(
void ShadowTree::emitLayoutEvents(
const ShadowViewMutationList &mutations) const {
SystraceSection s("ShadowTree::emitLayoutEvents");
for (const auto &mutation : mutations) {
// Only `Insert` and `Update` mutations can affect layout metrics.
if (mutation.type != ShadowViewMutation::Insert &&

View File

@ -3,6 +3,7 @@
#include "UIManager.h"
#include <react/core/ShadowNodeFragment.h>
#include <react/debug/SystraceSection.h>
#include <react/uimanager/TimeUtils.h>
namespace facebook {
@ -14,6 +15,8 @@ SharedShadowNode UIManager::createNode(
SurfaceId surfaceId,
const RawProps &rawProps,
SharedEventTarget eventTarget) const {
SystraceSection s("UIManager::createNode");
auto &componentDescriptor = componentDescriptorRegistry_->at(name);
auto shadowNode = componentDescriptor.createShadowNode(
@ -34,6 +37,8 @@ SharedShadowNode UIManager::cloneNode(
const SharedShadowNode &shadowNode,
const SharedShadowNodeSharedList &children,
const RawProps *rawProps) const {
SystraceSection s("UIManager::cloneNode");
auto &componentDescriptor =
componentDescriptorRegistry_->at(shadowNode->getComponentHandle());
@ -52,6 +57,8 @@ SharedShadowNode UIManager::cloneNode(
void UIManager::appendChild(
const SharedShadowNode &parentShadowNode,
const SharedShadowNode &childShadowNode) const {
SystraceSection s("UIManager::appendChild");
auto &componentDescriptor =
componentDescriptorRegistry_->at(parentShadowNode->getComponentHandle());
componentDescriptor.appendChild(parentShadowNode, childShadowNode);
@ -60,6 +67,8 @@ void UIManager::appendChild(
void UIManager::completeSurface(
SurfaceId surfaceId,
const SharedShadowNodeUnsharedList &rootChildren) const {
SystraceSection s("UIManager::completeSurface");
if (delegate_) {
delegate_->uiManagerDidFinishTransaction(
surfaceId, rootChildren, getTime());
@ -69,7 +78,10 @@ void UIManager::completeSurface(
void UIManager::setNativeProps(
const SharedShadowNode &shadowNode,
const RawProps &rawProps) const {
SystraceSection s("UIManager::setNativeProps");
long startCommitTime = getTime();
auto &componentDescriptor =
componentDescriptorRegistry_->at(shadowNode->getComponentHandle());
auto props = componentDescriptor.cloneProps(shadowNode->getProps(), rawProps);
@ -88,7 +100,10 @@ void UIManager::setNativeProps(
LayoutMetrics UIManager::getRelativeLayoutMetrics(
const ShadowNode &shadowNode,
const ShadowNode *ancestorShadowNode) const {
SystraceSection s("UIManager::getRelativeLayoutMetrics");
long startCommitTime = getTime();
if (!ancestorShadowNode) {
shadowTreeRegistry_->visit(
shadowNode.getRootTag(), [&](const ShadowTree &shadowTree) {

View File

@ -2,6 +2,8 @@
#include "UIManagerBinding.h"
#include <react/debug/SystraceSection.h>
#include <jsi/JSIDynamic.h>
namespace facebook {
@ -66,6 +68,8 @@ void UIManagerBinding::dispatchEvent(
const EventTarget *eventTarget,
const std::string &type,
const ValueFactory &payloadFactory) const {
SystraceSection s("UIManagerBinding::dispatchEvent");
auto payload = payloadFactory(runtime);
auto instanceHandle = eventTarget