From 18be49e7bbd3e52637b589705c6314d38d02b3cd Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 12 Jun 2024 08:32:26 -0700 Subject: [PATCH] split trace blocks inside of IntBufferBatchMountItem by type of operation (#44897) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44897 changelog: [internal] To get better understanding of where the time is spent, let's split IntBufferBatchMountItem systrace section into individual types. Reviewed By: javache Differential Revision: D58080444 fbshipit-source-id: d71dcc74a042c6c40270ca6f1dc7a8735c0471b8 --- .../mountitems/IntBufferBatchMountItem.java | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index 40e159669e4f9e..2db50ef134d0f7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -14,8 +14,6 @@ import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Nullsafe; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.ReactMarker; -import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.fabric.events.EventEmitterWrapper; import com.facebook.react.fabric.mounting.MountingManager; @@ -74,25 +72,6 @@ final class IntBufferBatchMountItem implements BatchMountItem { mObjBufferLen = mObjBuffer.length; } - private void beginMarkers(String reason) { - Systrace.beginSection( - Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "IntBufferBatchMountItem::" + reason); - - if (mCommitNumber > 0) { - ReactMarker.logFabricMarker( - ReactMarkerConstants.FABRIC_BATCH_EXECUTION_START, null, mCommitNumber); - } - } - - private void endMarkers() { - if (mCommitNumber > 0) { - ReactMarker.logFabricMarker( - ReactMarkerConstants.FABRIC_BATCH_EXECUTION_END, null, mCommitNumber); - } - - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); - } - @Override public void execute(MountingManager mountingManager) { SurfaceMountingManager surfaceMountingManager = mountingManager.getSurfaceManager(mSurfaceId); @@ -111,13 +90,15 @@ public void execute(MountingManager mountingManager) { FLog.d(TAG, "Executing IntBufferBatchMountItem on surface [%d]", mSurfaceId); } - beginMarkers("mountViews"); - int i = 0, j = 0; while (i < mIntBufferLen) { int rawType = mIntBuffer[i++]; int type = rawType & ~INSTRUCTION_FLAG_MULTIPLE; int numInstructions = ((rawType & INSTRUCTION_FLAG_MULTIPLE) != 0 ? mIntBuffer[i++] : 1); + + Systrace.beginSection( + Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, + "IntBufferBatchMountItem::mountInstructions::" + nameForInstructionString(type)); for (int k = 0; k < numInstructions; k++) { if (type == INSTRUCTION_CREATE) { String componentName = getFabricComponentName((String) mObjBuffer[j++]); @@ -184,9 +165,8 @@ public void execute(MountingManager mountingManager) { "Invalid type argument to IntBufferBatchMountItem: " + type + " at index: " + i); } } + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); } - - endMarkers(); } @Override @@ -308,4 +288,32 @@ public String toString() { return ""; } } + + private static String nameForInstructionString(int type) { + if (type == INSTRUCTION_CREATE) { + return "CREATE"; + } else if (type == INSTRUCTION_DELETE) { + return "DELETE"; + } else if (type == INSTRUCTION_INSERT) { + return "INSERT"; + } else if (type == INSTRUCTION_REMOVE) { + return "REMOVE"; + } else if (type == INSTRUCTION_REMOVE_DELETE_TREE) { + return "REMOVE_DELETE_TREE"; + } else if (type == INSTRUCTION_UPDATE_PROPS) { + return "UPDATE_PROPS"; + } else if (type == INSTRUCTION_UPDATE_STATE) { + return "UPDATE_STATE"; + } else if (type == INSTRUCTION_UPDATE_LAYOUT) { + return "UPDATE_LAYOUT"; + } else if (type == INSTRUCTION_UPDATE_PADDING) { + return "UPDATE_PADDING"; + } else if (type == INSTRUCTION_UPDATE_OVERFLOW_INSET) { + return "UPDATE_OVERFLOW_INSET"; + } else if (type == INSTRUCTION_UPDATE_EVENT_EMITTER) { + return "UPDATE_EVENT_EMITTER"; + } else { + return "UNKNOWN"; + } + } }