CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
95 lines
3.2 KiB
Python
95 lines
3.2 KiB
Python
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""Caches .lit_test_times.txt files between premerge invocations.
|
|
|
|
.lit_test_times.txt files are used by lit to order tests to best take advantage
|
|
of parallelism. Having them around and up to date can result in a ~15%
|
|
improvement in test times. This script downloading cached test time files and
|
|
uploading new versions to the GCS buckets used for caching.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import logging
|
|
import multiprocessing.pool
|
|
import pathlib
|
|
import glob
|
|
|
|
from google.cloud import storage
|
|
from google.api_core import exceptions
|
|
|
|
GCS_PARALLELISM = 100
|
|
|
|
|
|
def _maybe_upload_timing_file(bucket, timing_file_path):
|
|
if os.path.exists(timing_file_path):
|
|
timing_file_blob = bucket.blob("lit_timing/" + timing_file_path)
|
|
timing_file_blob.upload_from_filename(timing_file_path)
|
|
|
|
|
|
def upload_timing_files(storage_client, bucket_name: str):
|
|
bucket = storage_client.bucket(bucket_name)
|
|
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
|
|
futures = []
|
|
for timing_file_path in glob.glob("**/.lit_test_times.txt", recursive=True):
|
|
futures.append(
|
|
thread_pool.apply_async(
|
|
_maybe_upload_timing_file, (bucket, timing_file_path)
|
|
)
|
|
)
|
|
for future in futures:
|
|
future.get()
|
|
print("Done uploading")
|
|
|
|
|
|
def _maybe_download_timing_file(blob):
|
|
file_name = blob.name.removeprefix("lit_timing/")
|
|
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
|
|
blob.download_to_filename(file_name)
|
|
|
|
|
|
def download_timing_files(storage_client, bucket_name: str):
|
|
bucket = storage_client.bucket(bucket_name)
|
|
try:
|
|
blobs = bucket.list_blobs(prefix="lit_timing")
|
|
except exceptions.ClientError as client_error:
|
|
print(
|
|
"::warning file=cache_lit_timing_files.py::Failed to list blobs "
|
|
"in bucket."
|
|
)
|
|
sys.exit(0)
|
|
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
|
|
futures = []
|
|
for timing_file_blob in blobs:
|
|
futures.append(
|
|
thread_pool.apply_async(
|
|
_maybe_download_timing_file, (timing_file_blob,)
|
|
)
|
|
)
|
|
for future in futures:
|
|
future.wait()
|
|
if not future.successful():
|
|
print(
|
|
"::warning file=cache_lit_timing_files.py::Failed to "
|
|
"download lit timing file."
|
|
)
|
|
continue
|
|
print("Done downloading")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
|
|
sys.exit(1)
|
|
action = sys.argv[1]
|
|
storage_client = storage.Client()
|
|
bucket_name = os.environ["CACHE_GCS_BUCKET"]
|
|
if action == "download":
|
|
download_timing_files(storage_client, bucket_name)
|
|
elif action == "upload":
|
|
upload_timing_files(storage_client, bucket_name)
|
|
else:
|
|
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
|
|
sys.exit(1)
|