Skip to content

Build the pie extensions from the core's profile and cache the musl PHP builds - #6880

Open
ondrejmirtes wants to merge 2 commits into
2.3.xfrom
turbo-pie-profile-reuse
Open

ondrejmirtes wants to merge 2 commits into
2.3.xfrom
turbo-pie-profile-reuse

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Two changes to cut the time of the Turbo compile legs in phar.yml.

pie legs reuse the core's PGO profile. Each pie leg used to run a full make pgo (instrumented build, training run, optimised build): 6–18 minutes per leg, about 320 runner-minutes on the 2.3.3 release, and on the critical path of everything that needs turbo-compile. The core jobs now pack the core's share of their profile (make SPLIT=1 pgo-pack, artifact turbo-pgo-profile-<platform>, carried over with a reused core), and the pie legs build from it with make pgo-from-profile. When another compiler recorded the profile (e.g. the 8.6 NTS musl leg on alpine:edge), it falls back to make pgo.

GCC instruments before optimising, so the shared core is not always the same control flow against other headers: with the 8.5 core's profile, 85 of 33136 functions mismatch on 8.2-zts, none on 8.4, 8.4-zts or 8.5. Those functions build without a profile (-Wno-coverage-mismatch).

Verified in the CI images: core trained in gnu-php8.5, then an 8.2-zts self-contained build from its profile in gnu-php8.2-zts took 1m26s on 4 cores, reports the expected version, and turbo-ext/tests/smoke.php prints ALL OK. The macOS (clang) leg was not run locally.

musl legs cache the PHP they build from source. The thread-safe legs and 8.2 build PHP from the tarball (~6 min per leg). install-alpine-php.sh keeps that build in $PHP_CACHE_DIR, restored with actions/cache under the key install-alpine-php.sh --resolve prints (Alpine release, arch, PHP release, ZTS) plus the hash of build-php.sh. Verified in alpine:3.24 with 8.3 ZTS: 3m30s to build, 4s from the cache. Covers turbo-compile, turbo-compile-musl-arm64 and turbo-differential-musl.

The core jobs are part of the reuse fingerprint, so the first run after this compiles every core once more.

…again

The self-contained extensions of the pie legs ran a full `make pgo` each:
an instrumented build, a training run and the optimised build, 6-18 minutes
per leg. The core jobs now pack the core's share of their profile
(`make SPLIT=1 pgo-pack`, uploaded as turbo-pgo-profile-<platform> and
carried over with a reused core), and the pie legs build from it with
`make pgo-from-profile`, which falls back to `make pgo` when another
compiler recorded the profile.

The core compiles to the same code against every version's headers, but
GCC instruments before optimising: with the 8.5 core's profile, 85 of 33136
functions mismatch on 8.2-zts (none on 8.4, 8.4-zts, 8.5), and those build
without a profile.
The musl thread-safe legs and 8.2 build PHP from the release tarball, about
6 minutes per leg. install-alpine-php.sh now keeps that build in
$PHP_CACHE_DIR, which phar.yml restores with actions/cache under the key
`install-alpine-php.sh --resolve` prints (Alpine release, architecture, PHP
release, thread safety), so a new patch release or RC builds again.
Installing from the cache takes seconds.

Amp-Thread-ID: https://ampcode.com/threads/T-01a18495-f2db-74a3-a734-f1c0dbe24b9f
- name: "Resolve the PHP build to cache (Alpine container)"
id: alpine-php
if: matrix.target.family == 'musl'
run: sh .github/scripts/install-alpine-php.sh --resolve >> "$GITHUB_OUTPUT"
# see turbo-compile
- name: "Resolve the PHP build to cache"
id: alpine-php
run: docker exec alpine-build sh .github/scripts/install-alpine-php.sh --resolve >> "$GITHUB_OUTPUT"
# see turbo-compile
- name: "Resolve the PHP build to cache"
id: alpine-php
run: docker exec alpine-test sh .github/scripts/install-alpine-php.sh --resolve >> "$GITHUB_OUTPUT"

- name: "Restore the PHP build (Alpine container)"
if: steps.alpine-php.outputs.release != ''
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

- name: "Restore the PHP build"
if: steps.alpine-php.outputs.release != ''
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

- name: "Restore the PHP build"
if: steps.alpine-php.outputs.release != ''
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants