Skip to content

Commit

Permalink
BREAKING: [litho] Remove unused perf event DRAW
Browse files Browse the repository at this point in the history
Summary: To my knowledge we haven't really been looking at this data and it's not free to record or check for. We should remove it until we know we want it again.

Reviewed By: passy

Differential Revision: D15663845

fbshipit-source-id: 60ed47055edaf75c5d18572758096a35df416cae
  • Loading branch information
astreet authored and facebook-github-bot committed Jun 15, 2019
1 parent 4917370 commit 9e548cb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 85 deletions.
58 changes: 1 addition & 57 deletions litho-core/src/main/java/com/facebook/litho/ComponentHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
@DoNotStrip
public class ComponentHost extends ViewGroup {

private static final double NS_IN_MS = 1000000.0;
private static final int SCRAP_ARRAY_INITIAL_SIZE = 4;

private SparseArrayCompat<MountItem> mMountItems;
Expand All @@ -78,9 +77,6 @@ public class ComponentHost extends ViewGroup {
private boolean mSuppressInvalidations;

private final InterleavedDispatchDraw mDispatchDraw = new InterleavedDispatchDraw();
private final DrawStats mDrawStats = new DrawStats();

@Nullable private PerfEvent mPerfEvent;

private int[] mChildDrawingOrder = new int[0];
private boolean mIsChildDrawingOrderDirty;
Expand Down Expand Up @@ -147,12 +143,6 @@ long getParentHostMarker() {
return mParentHostMarker;
}

/** Set a perf event to log additional draw stats for <b>the next draw call only</b>. */
void setPerfEvent(PerfEvent perfEvent) {
mPerfEvent = perfEvent;
mDrawStats.enableLogging();
}

/**
* Mounts the given {@link MountItem} with unique index.
* @param index index of the {@link MountItem}. Guaranteed to be the same index as is passed for
Expand Down Expand Up @@ -1424,7 +1414,6 @@ private void drawNext() {
for (int i = mDrawIndex, size = (mMountItems == null) ? 0 : mMountItems.size();
i < size;
i++) {
final long startDrawNs = System.nanoTime();
final MountItem mountItem = mMountItems.valueAt(i);
final Object content = mountItem.getContent();

Expand All @@ -1442,32 +1431,19 @@ private void drawNext() {
}

final boolean isTracing = ComponentsSystrace.isTracing();
final String mountItemName =
isTracing || mDrawStats.mIsLoggingEnabled ? getMountItemName(mountItem) : null;

if (isTracing) {
ComponentsSystrace.beginSection("draw: " + mountItemName);
ComponentsSystrace.beginSection("draw: " + getMountItemName(mountItem));
}
((Drawable) content).draw(mCanvas);
if (isTracing) {
ComponentsSystrace.endSection();
}

final long endDrawNs = System.nanoTime();
if (mDrawStats.mIsLoggingEnabled) {
mDrawStats.mMountItemTimes.add((endDrawNs - startDrawNs) / NS_IN_MS);
mDrawStats.mMountItemNames.add(mountItemName);
}
}

mDrawIndex = mItemsToDraw;
}

private void end() {
if (mDrawStats.mIsLoggingEnabled) {
mDrawStats.annotatePerfEvent(mPerfEvent);
mPerfEvent = null;
}
mCanvas = null;
}
}
Expand Down Expand Up @@ -1502,36 +1478,4 @@ public boolean performAccessibilityAction(int action, Bundle arguments) {

return super.performAccessibilityAction(action, arguments);
}

private static class DrawStats {
List<String> mMountItemNames;
List<Double> mMountItemTimes;

boolean mIsLoggingEnabled = false;
private boolean mIsInitialized = false;

void enableLogging() {
if (!mIsInitialized) {
mMountItemNames = new ArrayList<>(4);
mMountItemTimes = new ArrayList<>(4);
}

mIsLoggingEnabled = true;
mIsInitialized = true;
}

private void reset() {
mIsLoggingEnabled = false;
mMountItemNames.clear();
mMountItemTimes.clear();
}

void annotatePerfEvent(PerfEvent perfEvent) {
perfEvent.markerAnnotate(
FrameworkLogEvents.PARAM_DRAWN_CONTENT, mMountItemNames.toArray(new String[0]));
perfEvent.markerAnnotate(
FrameworkLogEvents.PARAM_DRAWN_TIME, mMountItemTimes.toArray(new Double[0]));
reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface FrameworkLogEvents {
int EVENT_SECTIONS_ON_CREATE_CHILDREN = 14;
int EVENT_SECTIONS_SET_ROOT = 15;
int EVENT_CALCULATE_LAYOUT_STATE = 16;
int EVENT_DRAW = 17;
// Previously int EVENT_DRAW = 17; Now unused.
int EVENT_BENCHMARK_RUN = 18;
int EVENT_RESUME_CALCULATE_LAYOUT_STATE = 19;

Expand All @@ -56,7 +56,6 @@ public interface FrameworkLogEvents {
FrameworkLogEvents.EVENT_SECTIONS_ON_CREATE_CHILDREN,
FrameworkLogEvents.EVENT_SECTIONS_SET_ROOT,
FrameworkLogEvents.EVENT_CALCULATE_LAYOUT_STATE,
FrameworkLogEvents.EVENT_DRAW,
FrameworkLogEvents.EVENT_BENCHMARK_RUN,
FrameworkLogEvents.EVENT_RESUME_CALCULATE_LAYOUT_STATE,
})
Expand Down
25 changes: 0 additions & 25 deletions litho-core/src/main/java/com/facebook/litho/LithoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,35 +664,10 @@ public void setTranslationY(float translationY) {

@Override
public void draw(Canvas canvas) {
final ComponentsLogger logger =
getComponentTree() == null ? null : getComponentTree().getContext().getLogger();
final PerfEvent perfEvent =
logger != null
? LogTreePopulator.populatePerfEventFromLogger(
getComponentContext(),
logger,
logger.newPerformanceEvent(getComponentContext(), FrameworkLogEvents.EVENT_DRAW))
: null;
if (perfEvent != null) {
setPerfEvent(perfEvent);
}

super.draw(canvas);

if (mOnPostDrawListener != null) {
if (perfEvent != null) {
perfEvent.markerPoint("POST_DRAW_START");
}
mOnPostDrawListener.onPostDraw();
if (perfEvent != null) {
perfEvent.markerPoint("POST_DRAW_END");
}
}

if (perfEvent != null) {
perfEvent.markerAnnotate(
FrameworkLogEvents.PARAM_ROOT_COMPONENT, getComponentTree().getRoot().getSimpleName());
logger.logPerfEvent(perfEvent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class SampleComponentsLogger : BaseComponentsLogger() {
FrameworkLogEvents.EVENT_SECTIONS_ON_CREATE_CHILDREN -> "SECTIONS_ON_CREATE_CHILDREN"
FrameworkLogEvents.EVENT_SECTIONS_SET_ROOT -> "SECTIONS_SET_ROOT"
FrameworkLogEvents.EVENT_CALCULATE_LAYOUT_STATE -> "CALCULATE_LAYOUT_STATE"
FrameworkLogEvents.EVENT_DRAW -> "DRAW"
else -> "UNKNOWN"
}

Expand Down

0 comments on commit 9e548cb

Please sign in to comment.