Skip to content

Commit

Permalink
split trace blocks inside of IntBufferBatchMountItem by type of opera…
Browse files Browse the repository at this point in the history
…tion (#44897)

Summary:
Pull Request resolved: #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
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Jun 12, 2024
1 parent 55e08a9 commit 18be49e
Showing 1 changed file with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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++]);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
}
}
}

0 comments on commit 18be49e

Please sign in to comment.