Skip to content

Commit f55b002

Browse files
committed
Auto merge of #103019 - Kobzol:ci-multistage-python, r=Mark-Simulacrum
Port pgo.sh to Python This PR ports the `pgo.sh` multi stage build file from bash to Python, to make it easier to add new functionality and gather statistics. Main changes: 1) `pgo.sh` rewritten from Bash to Python. Jump from ~200 Bash LOC to ~650 Python LOC. Bash is, unsurprisingly, more concise for running scripts and binaries. 2) Better logging. Each separate stage is now clearly separated in logs, and the logs can be quickly grepped to find out which stage has completed or failed, and how long it took. 3) Better statistics. At the end of the run, there is now a table that shows the duration of the individual stages, along with a percentual ratio of the total workflow run: ``` 2023-01-15T18:13:49.9896916Z stage-build INFO: Timer results 2023-01-15T18:13:49.9902185Z --------------------------------------------------------- 2023-01-15T18:13:49.9902605Z Build rustc (LLVM PGO): 1815.67s (21.47%) 2023-01-15T18:13:49.9902949Z Gather profiles (LLVM PGO): 418.73s ( 4.95%) 2023-01-15T18:13:49.9903269Z Build rustc (rustc PGO): 584.46s ( 6.91%) 2023-01-15T18:13:49.9903835Z Gather profiles (rustc PGO): 806.32s ( 9.53%) 2023-01-15T18:13:49.9904154Z Build rustc (LLVM BOLT): 1662.92s (19.66%) 2023-01-15T18:13:49.9904464Z Gather profiles (LLVM BOLT): 715.18s ( 8.46%) 2023-01-15T18:13:49.9914463Z Final build: 2454.00s (29.02%) 2023-01-15T18:13:49.9914798Z Total duration: 8457.27s 2023-01-15T18:13:49.9915305Z --------------------------------------------------------- ``` A sample run can be seen [here](https://github.com/rust-lang/rust/actions/runs/3923980164/jobs/6707932029). I tried to keep the code compatible with Python 3.6 and don't use dependencies, which required me to reimplement some small pieces of functionality (like formatting bytes). I suppose that it shouldn't be so hard to upgrade to a newer Python or install dependencies in the CI container, but I'd like to avoid it if it won't be needed. The code is in a single file `stage-build.py`, so it's a bit cluttered. I can also separate it into multiple files, although having it in a single file has some benefits. The code could definitely be nicer, but I'm a bit wary of introducing a lot of abstraction and similar stuff, as long as the code is stuffed into a single file. Currently, the Python pipeline should faithfully mirror the bash pipeline one by one. After this PR, I'd like to try to optimize it, e.g. by caching the LLVM builds on S3. r? `@Mark-Simulacrum`
2 parents e972bc8 + 5b77cb4 commit f55b002

File tree

4 files changed

+666
-3
lines changed

4 files changed

+666
-3
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ jobs:
447447
- name: dist-x86_64-msvc
448448
env:
449449
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --host=x86_64-pc-windows-msvc --target=x86_64-pc-windows-msvc --enable-full-tools --enable-profiler --set rust.lto=thin"
450-
SCRIPT: PGO_HOST=x86_64-pc-windows-msvc src/ci/pgo.sh python x.py dist bootstrap --include-default-paths
450+
SCRIPT: PGO_HOST=x86_64-pc-windows-msvc python src/ci/stage-build.py python x.py dist bootstrap --include-default-paths
451451
DIST_REQUIRE_ALL_TOOLS: 1
452452
os: windows-latest-xl
453453
- name: dist-i686-msvc

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ENV RUST_CONFIGURE_ARGS \
8181
--set rust.jemalloc \
8282
--set rust.use-lld=true \
8383
--set rust.lto=thin
84-
ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist \
84+
ENV SCRIPT python3 ../src/ci/stage-build.py python3 ../x.py dist \
8585
--host $HOSTS --target $HOSTS \
8686
--include-default-paths \
8787
build-manifest bootstrap

src/ci/github-actions/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ jobs:
680680
--enable-full-tools
681681
--enable-profiler
682682
--set rust.lto=thin
683-
SCRIPT: PGO_HOST=x86_64-pc-windows-msvc src/ci/pgo.sh python x.py dist bootstrap --include-default-paths
683+
SCRIPT: PGO_HOST=x86_64-pc-windows-msvc python src/ci/stage-build.py python x.py dist bootstrap --include-default-paths
684684
DIST_REQUIRE_ALL_TOOLS: 1
685685
<<: *job-windows-xl
686686

0 commit comments

Comments
 (0)