Skip to content

Commit 39e82bd

Browse files
authored
build_bloat: add paths sorting to improve visual stability (#10604)
Sorting paths enables the renderer to produce more consistent visual results across different runs, even when build statistics change. Elements with minimal duration change between runs are more likely to maintain their positions on a grid. This stability makes it easier to visually compare the outcomes of build time optimization efforts aimed at specific modules or components.
1 parent 07f47ac commit 39e82bd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ydb/ci/build_bloat/main.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def build_include_tree(path: str, build_output_dir: str, base_src_dir: str) -> l
8686
else:
8787
assert current_includes_stack[-1] == sanitize_path(path, base_src_dir)
8888
current_includes_stack.pop()
89-
90-
# filter small entities
89+
90+
# filter small entities
9191
tree_paths_to_include = set()
9292
result = []
9393
for tree_path, duration in tree_path_to_sum_duration.items():
@@ -97,7 +97,7 @@ def build_include_tree(path: str, build_output_dir: str, base_src_dir: str) -> l
9797

9898
def add_to_tree(tree, tree_path, duration):
9999
if len(tree_path) == 0:
100-
tree["duration"] += duration
100+
tree["duration"] += duration
101101
else:
102102
if tree_path[0] not in tree["children"]:
103103
tree["children"][tree_path[0]] = {
@@ -140,7 +140,7 @@ def collect(tree, current_tree_path):
140140
result.append((current_tree_path[:], tree["duration"]))
141141
for child, child_tree in tree["children"].items():
142142
collect(child_tree, current_tree_path + [child])
143-
143+
144144
collect(tree, [])
145145

146146
return result
@@ -209,6 +209,8 @@ def generate_cpp_bloat(build_output_dir: str, result_dir: str, base_src_dir: str
209209
("cpp", "Cpp", "#FC8D62"),
210210
("dir", "Dir", "#8DA0CB"),
211211
]
212+
# sort paths to make render results more stable
213+
tree_paths = sorted(tree_paths)
212214
tree_map.generate_tree_map_html(result_dir, tree_paths, unit_name="ms", factor=1, types=types)
213215

214216
os.makedirs(result_dir, exist_ok=True)
@@ -359,6 +361,8 @@ def generate_header_bloat(build_output_dir: str, result_dir: str, base_src_dir:
359361
("cpp", "Cpp", "#FC8D62"),
360362
("dir", "Dir", "#8DA0CB"),
361363
]
364+
# sort paths to make render results more stable
365+
tree_paths = sorted(tree_paths)
362366
tree_map.generate_tree_map_html(result_dir, tree_paths, unit_name="ms", factor=1, types=types)
363367

364368
time_breakdown = {}
@@ -383,7 +387,7 @@ def generate_header_bloat(build_output_dir: str, result_dir: str, base_src_dir:
383387
}
384388

385389
os.makedirs(result_dir, exist_ok=True)
386-
390+
387391
with open(os.path.join(result_dir, "output.json"), "w") as f:
388392
json.dump(human_readable_output, f, indent=4)
389393

@@ -393,7 +397,7 @@ def parse_args():
393397
parser = argparse.ArgumentParser(
394398
description="""A tool for analyzing build time\n
395399
396-
To use it run ya make with '--output=output_dir -DCOMPILER_TIME_TRACE' and *.time_trace.json files
400+
To use it run ya make with '--output=output_dir -DCOMPILER_TIME_TRACE' and *.time_trace.json files
397401
will be generated in output_dir"""
398402
)
399403
parser.add_argument(

0 commit comments

Comments
 (0)