Skip to content

build_bloat: add paths sorting to improve visual stability #10604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions ydb/ci/build_bloat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def build_include_tree(path: str, build_output_dir: str, base_src_dir: str) -> l
else:
assert current_includes_stack[-1] == sanitize_path(path, base_src_dir)
current_includes_stack.pop()
# filter small entities

# filter small entities
tree_paths_to_include = set()
result = []
for tree_path, duration in tree_path_to_sum_duration.items():
Expand All @@ -97,7 +97,7 @@ def build_include_tree(path: str, build_output_dir: str, base_src_dir: str) -> l

def add_to_tree(tree, tree_path, duration):
if len(tree_path) == 0:
tree["duration"] += duration
tree["duration"] += duration
else:
if tree_path[0] not in tree["children"]:
tree["children"][tree_path[0]] = {
Expand Down Expand Up @@ -140,7 +140,7 @@ def collect(tree, current_tree_path):
result.append((current_tree_path[:], tree["duration"]))
for child, child_tree in tree["children"].items():
collect(child_tree, current_tree_path + [child])

collect(tree, [])

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

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

time_breakdown = {}
Expand All @@ -383,7 +387,7 @@ def generate_header_bloat(build_output_dir: str, result_dir: str, base_src_dir:
}

os.makedirs(result_dir, exist_ok=True)

with open(os.path.join(result_dir, "output.json"), "w") as f:
json.dump(human_readable_output, f, indent=4)

Expand All @@ -393,7 +397,7 @@ def parse_args():
parser = argparse.ArgumentParser(
description="""A tool for analyzing build time\n

To use it run ya make with '--output=output_dir -DCOMPILER_TIME_TRACE' and *.time_trace.json files
To use it run ya make with '--output=output_dir -DCOMPILER_TIME_TRACE' and *.time_trace.json files
will be generated in output_dir"""
)
parser.add_argument(
Expand Down