Skip to content

Commit 856bb01

Browse files
Merge branch 'main' into correct-decompress-offloading-api
2 parents 98f59d4 + 8a65c4f commit 856bb01

File tree

15,495 files changed

+1033621
-354772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

15,495 files changed

+1033621
-354772
lines changed

.ci/all_requirements.txt

Lines changed: 213 additions & 11 deletions
Large diffs are not rendered by default.

.ci/cache_lit_timing_files.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Caches .lit_test_times.txt files between premerge invocations.
5+
6+
.lit_test_times.txt files are used by lit to order tests to best take advantage
7+
of parallelism. Having them around and up to date can result in a ~15%
8+
improvement in test times. This script downloading cached test time files and
9+
uploading new versions to the GCS buckets used for caching.
10+
"""
11+
12+
import sys
13+
import os
14+
import logging
15+
import multiprocessing.pool
16+
import pathlib
17+
import platform
18+
import glob
19+
20+
from google.cloud import storage
21+
22+
GCS_PARALLELISM = 100
23+
24+
25+
def _get_blob_prefix():
26+
return f"lit_timing_{platform.system().lower()}"
27+
28+
29+
def _maybe_upload_timing_file(bucket, timing_file_path):
30+
if os.path.exists(timing_file_path):
31+
timing_file_blob = bucket.blob(_get_blob_prefix() + "/" + timing_file_path)
32+
timing_file_blob.upload_from_filename(timing_file_path)
33+
34+
35+
def upload_timing_files(storage_client, bucket_name: str):
36+
bucket = storage_client.bucket(bucket_name)
37+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
38+
futures = []
39+
for timing_file_path in glob.glob("**/.lit_test_times.txt", recursive=True):
40+
futures.append(
41+
thread_pool.apply_async(
42+
_maybe_upload_timing_file, (bucket, timing_file_path)
43+
)
44+
)
45+
for future in futures:
46+
future.get()
47+
print("Done uploading")
48+
49+
50+
def _maybe_download_timing_file(blob):
51+
file_name = blob.name.removeprefix(_get_blob_prefix() + "/")
52+
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
53+
blob.download_to_filename(file_name)
54+
55+
56+
def download_timing_files(storage_client, bucket_name: str):
57+
bucket = storage_client.bucket(bucket_name)
58+
blobs = bucket.list_blobs(prefix=_get_blob_prefix())
59+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
60+
futures = []
61+
for timing_file_blob in blobs:
62+
futures.append(
63+
thread_pool.apply_async(
64+
_maybe_download_timing_file, (timing_file_blob,)
65+
)
66+
)
67+
for future in futures:
68+
future.get()
69+
print("Done downloading")
70+
71+
72+
if __name__ == "__main__":
73+
if len(sys.argv) != 2:
74+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
75+
sys.exit(1)
76+
action = sys.argv[1]
77+
storage_client = storage.Client()
78+
bucket_name = os.environ["CACHE_GCS_BUCKET"]
79+
if action == "download":
80+
download_timing_files(storage_client, bucket_name)
81+
elif action == "upload":
82+
upload_timing_files(storage_client, bucket_name)
83+
else:
84+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
85+
sys.exit(1)

.ci/compute_projects.py

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"flang",
5050
},
5151
"lld": {"bolt", "cross-project-tests"},
52-
# TODO(issues/132795): LLDB should be enabled on clang changes.
53-
"clang": {"clang-tools-extra", "cross-project-tests"},
52+
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
5453
"mlir": {"flang"},
5554
# Test everything if ci scripts are changed.
5655
".ci": {
@@ -80,6 +79,7 @@
8079
"clang": {"compiler-rt"},
8180
"clang-tools-extra": {"libc"},
8281
"libc": {"libc"},
82+
"compiler-rt": {"compiler-rt"},
8383
".ci": {"compiler-rt", "libc"},
8484
}
8585
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
@@ -100,6 +100,9 @@
100100
"libc", # No Windows Support.
101101
"lldb", # TODO(issues/132800): Needs environment setup.
102102
"bolt", # No Windows Support.
103+
"libcxx",
104+
"libcxxabi",
105+
"libunwind",
103106
}
104107

105108
# These are projects that we should test if the project itself is changed but
@@ -118,6 +121,9 @@
118121
"lldb",
119122
"openmp",
120123
"polly",
124+
"libcxx",
125+
"libcxxabi",
126+
"libunwind",
121127
}
122128

123129
PROJECT_CHECK_TARGETS = {
@@ -144,6 +150,23 @@
144150

145151
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
146152

153+
# Meta projects are projects that need explicit handling but do not reside
154+
# in their own top level folder. To add a meta project, the start of the path
155+
# for the metaproject should be mapped to the name of the project below.
156+
# Multiple paths can map to the same metaproject.
157+
META_PROJECTS = {
158+
("clang", "lib", "CIR"): "CIR",
159+
("clang", "test", "CIR"): "CIR",
160+
("clang", "include", "clang", "CIR"): "CIR",
161+
("*", "docs"): "docs",
162+
("llvm", "utils", "gn"): "gn",
163+
(".github", "workflows", "premerge.yaml"): ".ci",
164+
("third-party",): ".ci",
165+
}
166+
167+
# Projects that should not run any tests. These need to be metaprojects.
168+
SKIP_PROJECTS = ["docs", "gn"]
169+
147170

148171
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
149172
projects_with_dependents = set(projects)
@@ -236,29 +259,34 @@ def _compute_runtimes_to_build(
236259
return _exclude_projects(runtimes_to_build, platform)
237260

238261

262+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
263+
if len(file_path) < len(matcher):
264+
return False
265+
for match_part, file_part in zip(matcher, file_path):
266+
if match_part == "*" or file_part == "*":
267+
continue
268+
if match_part != file_part:
269+
return False
270+
return True
271+
272+
273+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
274+
modified_projects = set()
275+
path_parts = pathlib.Path(modified_file).parts
276+
for meta_project_files in META_PROJECTS.keys():
277+
if _path_matches(meta_project_files, path_parts):
278+
meta_project = META_PROJECTS[meta_project_files]
279+
if meta_project in SKIP_PROJECTS:
280+
return set()
281+
modified_projects.add(meta_project)
282+
modified_projects.add(pathlib.Path(modified_file).parts[0])
283+
return modified_projects
284+
285+
239286
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
240287
modified_projects = set()
241288
for modified_file in modified_files:
242-
path_parts = pathlib.Path(modified_file).parts
243-
# Exclude files in the docs directory. They do not impact an test
244-
# targets and there is a separate workflow used for ensuring the
245-
# documentation builds.
246-
if len(path_parts) > 2 and path_parts[1] == "docs":
247-
continue
248-
# Exclude files for the gn build. We do not test it within premerge
249-
# and changes occur often enough that they otherwise take up
250-
# capacity.
251-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
252-
continue
253-
# If the file is in the clang/lib/CIR directory, add the CIR project.
254-
if len(path_parts) > 3 and (
255-
path_parts[:3] == ("clang", "lib", "CIR")
256-
or path_parts[:3] == ("clang", "test", "CIR")
257-
or path_parts[:4] == ("clang", "include", "clang", "CIR")
258-
):
259-
modified_projects.add("CIR")
260-
# Fall through to add clang.
261-
modified_projects.add(pathlib.Path(modified_file).parts[0])
289+
modified_projects.update(_get_modified_projects_for_file(modified_file))
262290
return modified_projects
263291

264292

@@ -305,6 +333,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
305333
current_platform = platform.system()
306334
if len(sys.argv) == 2:
307335
current_platform = sys.argv[1]
308-
env_variables = get_env_variables(sys.stdin.readlines(), current_platform)
336+
changed_files = [line.strip() for line in sys.stdin.readlines()]
337+
env_variables = get_env_variables(changed_files, current_platform)
309338
for env_variable in env_variables:
310339
print(f"{env_variable}='{env_variables[env_variable]}'")

0 commit comments

Comments
 (0)