Skip to content

Commit c0b6cac

Browse files
committed
Don't be as eager to merge small slices and override state.
- 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.
1 parent 636e1e9 commit c0b6cac

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

gapic/src/main/com/google/gapid/perfetto/views/ThreadPanel.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class ThreadPanel extends TrackPanel implements Selectable {
4242
private static final double SLICE_HEIGHT = 25 - 2 * TRACK_MARGIN;
4343
private static final double HOVER_MARGIN = 10;
4444
private static final double HOVER_PADDING = 4;
45-
private static final double MERGE_SLICE_THRESHOLD = 3;
46-
private static final double MERGE_GAP_THRESHOLD = 4;
45+
private static final double MERGE_SLICE_THRESHOLD = 1;
46+
private static final double MERGE_GAP_THRESHOLD = 2;
47+
private static final double MERGE_STATE_RATIO = 3;
4748

4849
protected final ThreadTrack track;
4950
private boolean expanded;
@@ -112,8 +113,13 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double
112113
}
113114
if (rectWidth < MERGE_SLICE_THRESHOLD) {
114115
if (merging) {
116+
double ratio = (mergeEndX - mergeStartX) / rectWidth;
117+
if (ratio < 1 / MERGE_STATE_RATIO) {
118+
mergeState = data.schedStates[i];
119+
} else if (ratio < MERGE_STATE_RATIO) {
120+
mergeState = mergeState.merge(data.schedStates[i]);
121+
}
115122
mergeEndX = rectEnd;
116-
mergeState = mergeState.merge(data.schedStates[i]);
117123
} else {
118124
merging = true;
119125
mergeStartX = rectStart;
@@ -123,9 +129,14 @@ public void renderTrack(RenderContext ctx, Repainter repainter, double w, double
123129
} else {
124130
ThreadState ts = data.schedStates[i];
125131
if (merging) {
132+
double ratio = (mergeEndX - mergeStartX) / rectWidth;
133+
if (ratio > MERGE_STATE_RATIO) {
134+
ts = mergeState;
135+
} else if (ratio > 1 / MERGE_STATE_RATIO) {
136+
ts = mergeState.merge(ts);
137+
}
126138
rectStart = mergeStartX;
127139
rectWidth = rectEnd - rectStart;
128-
ts = ts.merge(mergeState);
129140
merging = false;
130141
}
131142

0 commit comments

Comments
 (0)