Skip to content

Commit

Permalink
Don't be as eager to merge small slices and override state.
Browse files Browse the repository at this point in the history
 - Only merge slices less than a pixel wide or with a gap of
   less than 2px.
 - If a slices is 3 times larger than what it's merged with,
   it's state dominates the merge priority, thus a tiny running
   slices doesn't turn it's large runnable neighbor into running.
  • Loading branch information
pmuetschard committed Jun 12, 2019
1 parent 636e1e9 commit c0b6cac
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public class ThreadPanel extends TrackPanel implements Selectable {
private static final double SLICE_HEIGHT = 25 - 2 * TRACK_MARGIN;
private static final double HOVER_MARGIN = 10;
private static final double HOVER_PADDING = 4;
private static final double MERGE_SLICE_THRESHOLD = 3;
private static final double MERGE_GAP_THRESHOLD = 4;
private static final double MERGE_SLICE_THRESHOLD = 1;
private static final double MERGE_GAP_THRESHOLD = 2;
private static final double MERGE_STATE_RATIO = 3;

protected final ThreadTrack track;
private boolean expanded;
Expand Down Expand Up @@ -112,8 +113,13 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double
}
if (rectWidth < MERGE_SLICE_THRESHOLD) {
if (merging) {
double ratio = (mergeEndX - mergeStartX) / rectWidth;
if (ratio < 1 / MERGE_STATE_RATIO) {
mergeState = data.schedStates[i];
} else if (ratio < MERGE_STATE_RATIO) {
mergeState = mergeState.merge(data.schedStates[i]);
}
mergeEndX = rectEnd;
mergeState = mergeState.merge(data.schedStates[i]);
} else {
merging = true;
mergeStartX = rectStart;
Expand All @@ -123,9 +129,14 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double
} else {
ThreadState ts = data.schedStates[i];
if (merging) {
double ratio = (mergeEndX - mergeStartX) / rectWidth;
if (ratio > MERGE_STATE_RATIO) {
ts = mergeState;
} else if (ratio > 1 / MERGE_STATE_RATIO) {
ts = mergeState.merge(ts);
}
rectStart = mergeStartX;
rectWidth = rectEnd - rectStart;
ts = ts.merge(mergeState);
merging = false;
}

Expand Down

0 comments on commit c0b6cac

Please sign in to comment.