Skip to content

Commit ef3b93e

Browse files
Fabio Carballofacebook-github-bot
authored andcommitted
Add perf event for resolve calculation in ComponentsLogger
Summary: Adding a `PerfEvent` for the calculation of the Resolve phase. Differential Revision: D44261102 fbshipit-source-id: 3731af2fdfa13bcf76c66e1b1c4e0461039abc87
1 parent 9cb1bd5 commit ef3b93e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

litho-core/src/main/java/com/facebook/litho/ComponentTree.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
package com.facebook.litho;
1818

1919
import static com.facebook.litho.FrameworkLogEvents.EVENT_PRE_ALLOCATE_MOUNT_CONTENT;
20+
import static com.facebook.litho.FrameworkLogEvents.PARAM_ATTRIBUTION;
21+
import static com.facebook.litho.FrameworkLogEvents.PARAM_COMPONENT;
22+
import static com.facebook.litho.FrameworkLogEvents.PARAM_IS_BACKGROUND_LAYOUT;
23+
import static com.facebook.litho.FrameworkLogEvents.PARAM_RESOLVE_SOURCE;
24+
import static com.facebook.litho.FrameworkLogEvents.PARAM_RESOLVE_VERSION;
2025
import static com.facebook.litho.LayoutState.CalculateLayoutSource;
2126
import static com.facebook.litho.LayoutState.isFromSyncLayout;
2227
import static com.facebook.litho.LayoutState.layoutSourceToString;
@@ -2146,6 +2151,20 @@ private void doResolve(
21462151
context = new ComponentContext(mContext, treeProps);
21472152
}
21482153

2154+
ComponentsLogger componentsLogger = context.getLogger();
2155+
PerfEvent resolvePerfEvent = null;
2156+
if (componentsLogger != null) {
2157+
resolvePerfEvent =
2158+
componentsLogger.newPerformanceEvent(FrameworkLogEvents.EVENT_CALCULATE_RESOLVE);
2159+
if (resolvePerfEvent != null) {
2160+
resolvePerfEvent.markerAnnotate(PARAM_COMPONENT, root.getSimpleName());
2161+
resolvePerfEvent.markerAnnotate(PARAM_RESOLVE_SOURCE, layoutSourceToString(source));
2162+
resolvePerfEvent.markerAnnotate(PARAM_IS_BACKGROUND_LAYOUT, !ThreadUtils.isMainThread());
2163+
resolvePerfEvent.markerAnnotate(PARAM_ATTRIBUTION, extraAttribution);
2164+
resolvePerfEvent.markerAnnotate(PARAM_RESOLVE_VERSION, localResolveVersion);
2165+
}
2166+
}
2167+
21492168
if (root.getBuilderContextName() != null
21502169
&& !Component.getBuilderContextName(mContext.getAndroidContext())
21512170
.equals(root.getBuilderContextName())) {
@@ -2235,6 +2254,9 @@ && isFromSyncLayout(source)
22352254
}
22362255

22372256
commitResolveResult(resolveResult, isCreateLayoutInProgress);
2257+
if (componentsLogger != null && resolvePerfEvent != null) {
2258+
componentsLogger.logPerfEvent(resolvePerfEvent);
2259+
}
22382260

22392261
requestLayoutWithSplitFutures(
22402262
resolveResult,

litho-perf-logger/src/main/kotlin/com/facebook/litho/performance/FrameworkLogEvents.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public interface FrameworkLogEvents {
4747
int EVENT_RESUME_CALCULATE_LAYOUT_STATE = 19;
4848
int EVENT_INIT_RANGE = 20;
4949
int EVENT_LAYOUT_STATE_FUTURE_GET_WAIT = 21;
50+
int EVENT_CALCULATE_RESOLVE = 22;
5051

5152
@IntDef({
5253
FrameworkLogEvents.EVENT_MOUNT,
@@ -61,6 +62,7 @@ public interface FrameworkLogEvents {
6162
FrameworkLogEvents.EVENT_RESUME_CALCULATE_LAYOUT_STATE,
6263
FrameworkLogEvents.EVENT_INIT_RANGE,
6364
FrameworkLogEvents.EVENT_LAYOUT_STATE_FUTURE_GET_WAIT,
65+
FrameworkLogEvents.EVENT_CALCULATE_RESOLVE,
6466
})
6567
@Retention(RetentionPolicy.SOURCE)
6668
@interface LogEventId {}
@@ -102,6 +104,8 @@ public interface FrameworkLogEvents {
102104
String PARAM_LAYOUT_FUTURE_WAIT_FOR_RESULT = "wait_for_result";
103105
String PARAM_IS_MAIN_THREAD = "is_main_thread";
104106
String PARAM_LAYOUT_VERSION = "layout_version";
107+
String PARAM_RESOLVE_VERSION = "resolve_version";
108+
String PARAM_RESOLVE_SOURCE = "resolve_source";
105109

106110
String PARAM_CHANGESET_EFFECTIVE_COUNT = "changeset_effective_count";
107111
String PARAM_CHANGESET_INSERT_SINGLE_COUNT = "changeset_insert_single_count";

sample/src/main/java/com/facebook/samples/litho/kotlin/logging/SampleComponentsLogger.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class SampleComponentsLogger : ComponentsLogger {
9191
FrameworkLogEvents.EVENT_SECTIONS_ON_CREATE_CHILDREN -> "SECTIONS_ON_CREATE_CHILDREN"
9292
FrameworkLogEvents.EVENT_SECTIONS_SET_ROOT -> "SECTIONS_SET_ROOT"
9393
FrameworkLogEvents.EVENT_CALCULATE_LAYOUT_STATE -> "CALCULATE_LAYOUT_STATE"
94+
FrameworkLogEvents.EVENT_CALCULATE_RESOLVE -> "CALCULATE_RESOLVE"
9495
FrameworkLogEvents.EVENT_BENCHMARK_RUN -> "EVENT_BENCHMARK_RUN"
9596
FrameworkLogEvents.EVENT_RESUME_CALCULATE_LAYOUT_STATE ->
9697
"EVENT_RESUME_CALCULATE_LAYOUT_STATE"

0 commit comments

Comments
 (0)