Skip to content

Commit 4940aa0

Browse files
authored
Template bloat (#6579)
1 parent f8e93d3 commit 4940aa0

File tree

9 files changed

+674
-23
lines changed

9 files changed

+674
-23
lines changed

.github/actions/build_analytics/action.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ runs:
3535
export TARGET_DIR=${{ inputs.build_target }}
3636
export build_preset="${{ inputs.build_preset }}"
3737
export build_target="${{ inputs.build_target }}"
38-
./ya tool bloat --linker-map $TARGET_DIR/$TARGET_NAME.map.lld --input $TARGET_DIR/$TARGET_NAME --save-html ya_bloat_html
38+
./ya tool bloat --linker-map $TARGET_DIR/$TARGET_NAME.map.lld --input $TARGET_DIR/$TARGET_NAME --save-html ya_bloat_html --save-json bloat.json
39+
./ydb/ci/build_bloat/template_bloat.py -j bloat.json -o template_bloat -t template_bloat_html
3940
./ydb/ci/build_bloat/main.py --build-dir . --html-dir-cpp html_cpp_impact --html-dir-headers html_headers_impact
4041
./ydb/ci/build_bloat/ydb_upload.py --html-dir-cpp html_cpp_impact --html-dir-headers html_headers_impact
4142
@@ -45,7 +46,18 @@ runs:
4546
set -ex
4647
s3cmd sync -r --acl-public --stats --no-progress --no-mime-magic --guess-mime-type --no-check-md5 "ya_bloat_html/" "$S3_BUCKET_PATH/ya_bloat_html/"
4748
echo "[ya bloat tool]($S3_URL_PREFIX/ya_bloat_html/index.html) (better use Safari, because it is too large for Chrome)" >> $GITHUB_STEP_SUMMARY
48-
49+
50+
s3cmd sync -r --acl-public --stats --no-progress --no-mime-magic --guess-mime-type --no-check-md5 "template_bloat.by_size.txt" "$S3_BUCKET_PATH/template_bloat.by_size.txt"
51+
TEMPLATE_BLOAT_BY_SIZE_URL=$S3_URL_PREFIX/template_bloat.by_size.txt
52+
53+
s3cmd sync -r --acl-public --stats --no-progress --no-mime-magic --guess-mime-type --no-check-md5 "template_bloat.by_count.txt" "$S3_BUCKET_PATH/template_bloat.by_count.txt"
54+
TEMPLATE_BLOAT_BY_COUNT_URL=$S3_URL_PREFIX/template_bloat.by_count.txt
55+
56+
s3cmd sync -r --acl-public --stats --no-progress --no-mime-magic --guess-mime-type --no-check-md5 "template_bloat_html/" "$S3_BUCKET_PATH/template_bloat_html/"
57+
TEMPLATE_BLOAT_TREEMAP_URL=$S3_URL_PREFIX/template_bloat_html/index.html
58+
59+
echo "[template bloat]($TEMPLATE_BLOAT_TREEMAP_URL) ([sorted by size]($TEMPLATE_BLOAT_BY_SIZE_URL), [sorted by count]($TEMPLATE_BLOAT_BY_COUNT_URL))" >> $GITHUB_STEP_SUMMARY
60+
4961
s3cmd sync -r --acl-public --stats --no-progress --no-mime-magic --guess-mime-type --no-check-md5 "html_cpp_impact/" "$S3_BUCKET_PATH/html_cpp_impact/"
5062
echo "[cpp compilation time]($S3_URL_PREFIX/html_cpp_impact/index.html)" >> $GITHUB_STEP_SUMMARY
5163

ydb/ci/build_bloat/html/webtreemap.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
var dom = document.createElement('div');
6969
dom.style.zIndex = 1;
7070
dom.className = 'webtreemap-node webtreemap-level' + Math.min(level, 4);
71-
if (tree.data['$symbol']) {
72-
dom.className += ' webtreemap-type-' + tree.data['$symbol'];
71+
if (tree.type) {
72+
dom.className += ' webtreemap-type-' + tree.type;
7373
}
7474
if (tree.children) {
7575
dom.className += ' webtreemap-aggregate';
@@ -131,12 +131,12 @@
131131
// bad. Result is [start,end) covering the best run for this span.
132132
// http://scholar.google.com/scholar?cluster=5972512107845615474
133133
var node = nodes[start];
134-
var rmin = node.data['$area']; // Smallest seen child so far.
134+
var rmin = node.size; // Smallest seen child so far.
135135
var rmax = rmin; // Largest child.
136136
var rsum = 0; // Sum of children in this span.
137137
var last_score = 0; // Best score yet found.
138138
for (var end = start; node = nodes[end]; ++end) {
139-
var size = node.data['$area'];
139+
var size = node.size;
140140
if (size < rmin)
141141
rmin = size;
142142
if (size > rmax)
@@ -162,7 +162,7 @@
162162
if (!('children' in tree))
163163
return;
164164

165-
var total = tree.data['$area'];
165+
var total = tree.size;
166166

167167
// XXX why do I need an extra -1/-2 here for width/height to look right?
168168
var x1 = 0, y1 = 0, x2 = width - 1, y2 = height - 2;
@@ -208,7 +208,7 @@
208208
} else {
209209
child.dom.style.zIndex = 1;
210210
}
211-
var size = child.data['$area'];
211+
var size = child.size;
212212
var frac = size / rsum;
213213
if (ysplit) {
214214
width = rsum / space;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Based on https://github.com/martine/webtreemap */
2+
3+
body {
4+
font-family: sans-serif;
5+
font-size: 0.8em;
6+
height: calc(100vh - 20px);
7+
}
8+
9+
.content {
10+
height: 100%;
11+
display: flex;
12+
flex-direction: column;
13+
gap: 1ex;
14+
}
15+
16+
.header {
17+
width: 100%;
18+
display: flex;
19+
flex-direction: row;
20+
flex-wrap: wrap;
21+
vertical-align: middle;
22+
}
23+
24+
.header div {
25+
padding: 1ex 1em;
26+
}
27+
28+
.header legend {
29+
display: flex;
30+
flex-direction: row;
31+
gap: 1em;
32+
padding: 0;
33+
}
34+
35+
.header .note {
36+
width: 100%;
37+
flex-basis: content;
38+
flex-grow: 1;
39+
}
40+
41+
.header .webtreemap-node {
42+
flex-basis: max-content;
43+
flex-grow: 0;
44+
position: relative;
45+
text-align: center;
46+
}
47+
48+
#map {
49+
flex-basis: 100%;
50+
51+
min-width: 300px;
52+
min-height: 300px;
53+
54+
position: relative;
55+
cursor: pointer;
56+
user-select: none;
57+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<!-- Based on https://github.com/martine/webtreemap -->
3+
<head>
4+
<title>Build bloat</title>
5+
<link rel="stylesheet" href="webtreemap.css">
6+
<link rel="stylesheet" href="bloat.css">
7+
</head>
8+
9+
<body>
10+
<div class="content">
11+
<div class="header">
12+
<div class="note">Click on a box to zoom in. Click on the outermost box to zoom out.</div>
13+
<legend>
14+
<div>Legend:</div>
15+
<div class="webtreemap-node webtreemap-type-namespace">Namespace</div>
16+
<div class="webtreemap-node webtreemap-type-function">Function</div>
17+
</legend>
18+
</div>
19+
<div id='map'></div>
20+
</div>
21+
22+
<script src="bloat.json"></script>
23+
<script type="text/javascript" src='webtreemap.js'></script>
24+
<script type="text/javascript">
25+
var map = document.getElementById('map');
26+
var bloat = null;
27+
28+
renderTreemap(map, kTree);
29+
window.addEventListener("resize", (event) => {
30+
renderTreemap(map, kTree);
31+
});
32+
</script>
33+
</body>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.webtreemap-node {
2+
/* Required attributes. */
3+
position: absolute;
4+
overflow: hidden; /* To hide overlong captions. */
5+
background: white; /* Nodes must be opaque for zIndex layering. */
6+
border: solid 1px #555; /* Calculations assume 1px border. */
7+
8+
/* Optional: CSS animation. */
9+
transition: top 0.3s,
10+
left 0.3s,
11+
width 0.3s,
12+
height 0.3s;
13+
}
14+
15+
/* Optional: highlight nodes on mouseover. */
16+
.webtreemap-node:hover {
17+
background: #FFFFFF;
18+
}
19+
20+
/* Optional: Different background colors depending on type. */
21+
.webtreemap-type-namespace {
22+
background: #66C2A5;
23+
}
24+
.webtreemap-type-function {
25+
background: #FC8D62;
26+
}
27+
.webtreemap-type-dir {
28+
background: #8DA0CB;
29+
}
30+
31+
#legend > * {
32+
border: solid 1px #444;
33+
}
34+
35+
/* Optional: Different borders depending on level. */
36+
/*
37+
.webtreemap-level0 {
38+
border: solid 1px #444;
39+
}
40+
.webtreemap-level1 {
41+
border: solid 1px #666;
42+
}
43+
.webtreemap-level2 {
44+
border: solid 1px #888;
45+
}
46+
.webtreemap-level3 {
47+
border: solid 1px #aaa;
48+
}
49+
.webtreemap-level4 {
50+
border: solid 1px #ccc;
51+
}
52+
*/
53+
54+
/* Optional: styling on node captions. */
55+
.webtreemap-caption {
56+
font-family: sans-serif;
57+
font-size: 11px;
58+
padding: 2px;
59+
text-align: center;
60+
}
61+
62+
/* Optional: styling on captions on mouse hover. */
63+
/*.webtreemap-node:hover > .webtreemap-caption {
64+
text-decoration: underline;
65+
}*/

0 commit comments

Comments
 (0)