Skip to content

Commit c3fedc4

Browse files
rockdabootkderusso
authored andcommitted
[Profiling] Don't group by address if executable is known but function is unknown (elastic#129498)
* [Profiling] Omit address in grouping for unknown function but known executable This reduces the complexity of the flamegraph in unsymbolized areas. Symbolized areas of the flamegraph are not affected. * Fix tests * Fix IT tests
1 parent 8504ca2 commit c3fedc4

File tree

5 files changed

+25
-40
lines changed

5 files changed

+25
-40
lines changed

x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/GetFlameGraphActionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testGetStackTracesUnfiltered() throws Exception {
2626
);
2727
GetFlamegraphResponse response = client().execute(GetFlamegraphAction.INSTANCE, request).get();
2828
// only spot-check top level properties - detailed tests are done in unit tests
29-
assertEquals(1010, response.getSize());
29+
assertEquals(1008, response.getSize());
3030
assertEquals(1.0d, response.getSamplingRate(), 0.001d);
3131
assertEquals(46, response.getSelfCPU());
3232
assertEquals(1995, response.getTotalCPU());

x-pack/plugin/profiling/src/internalClusterTest/java/org/elasticsearch/xpack/profiling/action/GetTopNFunctionsActionIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void testGetTopNFunctionsUnfiltered() throws Exception {
2929
);
3030
request.setAdjustSampleCount(true);
3131
GetTopNFunctionsResponse response = client().execute(GetTopNFunctionsAction.INSTANCE, request).get();
32-
assertEquals(747, response.getTopN().size());
32+
assertEquals(671, response.getTopN().size());
3333
}
3434

3535
public void testGetTopNFunctionsGroupedByServiceName() throws Exception {
@@ -76,6 +76,6 @@ public void testGetTopNFunctionsFromAPM() throws Exception {
7676
null
7777
);
7878
GetTopNFunctionsResponse response = client().execute(GetTopNFunctionsAction.INSTANCE, request).get();
79-
assertEquals(45, response.getTopN().size());
79+
assertEquals(42, response.getTopN().size());
8080
}
8181
}

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/FrameGroupID.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public static String getBasenameAndParent(String fullPath) {
3030

3131
public static String create(String fileId, Integer addressOrLine, String exeFilename, String sourceFilename, String functionName) {
3232
if (Strings.isEmpty(functionName)) {
33-
return Integer.toString(Objects.hash(fileId, addressOrLine));
33+
if (Strings.isEmpty(exeFilename)) {
34+
return Integer.toString(Objects.hash(fileId, addressOrLine));
35+
}
36+
return Integer.toString(Objects.hash(exeFilename));
3437
}
3538
if (Strings.isEmpty(sourceFilename)) {
3639
return Integer.toString(Objects.hash(fileId, functionName));

x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/action/TransportGetFlamegraphActionTests.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,21 @@ public void testCreateFlamegraph() {
6262
assertEquals(1.0d, response.getSamplingRate(), 0.001d);
6363
assertEquals(List.of(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), response.getCountInclusive());
6464
assertEquals(List.of(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L), response.getCountExclusive());
65+
// {145245218=3}, {145245218=4}, {145245218=5}, {145245218=6}, {145245218=7}, {145245218=8}, {145245218=9}, {145245218=10},
66+
// {145245218=11}
6567
assertEquals(
6668
List.of(
6769
Map.of("1220", 1),
6870
Map.of("1219", 2),
69-
Map.of("174640828", 3),
70-
Map.of("181190529", 4),
71-
Map.of("181192637", 5),
72-
Map.of("180652335", 6),
73-
Map.of("180479184", 7),
74-
Map.of("180475689", 8),
75-
Map.of("174846197", 9),
76-
Map.of("175515318", 10),
77-
Map.of("178196121", 11),
71+
Map.of("145245218", 3),
72+
Map.of("145245218", 4),
73+
Map.of("145245218", 5),
74+
Map.of("145245218", 6),
75+
Map.of("145245218", 7),
76+
Map.of("145245218", 8),
77+
Map.of("145245218", 9),
78+
Map.of("145245218", 10),
79+
Map.of("145245218", 11),
7880
Map.of()
7981
),
8082
response.getEdges()

x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/action/TransportGetTopNFunctionsActionTests.java

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,13 @@ public void testCreateAllTopNFunctions() {
6060
GetTopNFunctionsResponse response = TransportGetTopNFunctionsAction.buildTopNFunctions(stacktraces, null);
6161
assertNotNull(response);
6262
assertEquals(1, response.getSelfCount());
63-
assertEquals(9, response.getTotalCount());
63+
assertEquals(1, response.getTotalCount());
6464

6565
List<TopNFunction> topNFunctions = response.getTopN();
6666
assertNotNull(topNFunctions);
67-
assertEquals(9, topNFunctions.size());
68-
69-
assertEquals(
70-
List.of(
71-
topN("178196121", 1, 16339645, 1L, 1L, 0.3d, 0.3d, 2.7d, 2.7d),
72-
topN("181192637", 2, 19336161, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
73-
topN("181190529", 3, 19334053, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
74-
topN("180652335", 4, 18795859, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
75-
topN("180479184", 5, 18622708, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
76-
topN("180475689", 6, 18619213, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
77-
topN("175515318", 7, 13658842, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
78-
topN("174846197", 8, 12989721, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
79-
topN("174640828", 9, 12784352, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d)
80-
),
81-
topNFunctions
82-
);
67+
assertEquals(1, topNFunctions.size());
68+
69+
assertEquals(List.of(topN("145245218", 1, 12784352, 1L, 1L, 0.3d, 0.3d, 2.7d, 2.7d)), topNFunctions);
8370
}
8471

8572
public void testCreateTopNFunctionsWithLimit() {
@@ -129,20 +116,13 @@ public void testCreateTopNFunctionsWithLimit() {
129116
GetTopNFunctionsResponse response = TransportGetTopNFunctionsAction.buildTopNFunctions(stacktraces, 3);
130117
assertNotNull(response);
131118
assertEquals(1, response.getSelfCount());
132-
assertEquals(9, response.getTotalCount());
119+
assertEquals(1, response.getTotalCount());
133120

134121
List<TopNFunction> topNFunctions = response.getTopN();
135122
assertNotNull(topNFunctions);
136-
assertEquals(3, topNFunctions.size());
123+
assertEquals(1, topNFunctions.size());
137124

138-
assertEquals(
139-
List.of(
140-
topN("178196121", 1, 16339645, 1L, 1L, 0.3d, 0.3d, 2.7d, 2.7d),
141-
topN("181192637", 2, 19336161, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d),
142-
topN("181190529", 3, 19334053, 0L, 1L, 0.0d, 0.3d, 0.0d, 2.7d)
143-
),
144-
topNFunctions
145-
);
125+
assertEquals(List.of(topN("145245218", 1, 12784352, 1L, 1L, 0.3d, 0.3d, 2.7d, 2.7d)), topNFunctions);
146126
}
147127

148128
private TopNFunction topN(

0 commit comments

Comments
 (0)