feat: Start implementing PGO profiling on different steps, b=no-bug, c=workflows, configs

This commit is contained in:
mr. m
2026-01-07 13:42:42 +01:00
parent 3c7fb093db
commit 7f29800982
5 changed files with 84 additions and 23 deletions

View File

@@ -336,7 +336,7 @@ jobs:
MOZ_BUILD_DATE: ${{needs.buildid.outputs.buildids}}
use-sccache: ${{ inputs.use-sccache }}
mac:
mac-pgo-generate:
name: macOS build
uses: ./.github/workflows/macos-release-build.yml
permissions:
@@ -348,6 +348,21 @@ jobs:
release-branch: ${{ inputs.update_branch }}
MOZ_BUILD_DATE: ${{needs.buildid.outputs.buildids}}
use-sccache: ${{ inputs.use-sccache }}
generate-pgo-data: true
mac:
name: macOS build
uses: ./.github/workflows/macos-release-build.yml
permissions:
contents: write
secrets: inherit
needs: [build-data, buildid, mac-pgo-generate]
with:
build-version: ${{ needs.build-data.outputs.version }}
release-branch: ${{ inputs.update_branch }}
MOZ_BUILD_DATE: ${{needs.buildid.outputs.buildids}}
use-sccache: ${{ inputs.use-sccache }}
generate-pgo-data: false
mac-uni:
name: macOS build (Universal)

View File

@@ -22,6 +22,11 @@ on:
required: true
type: boolean
default: false
generate-pgo-data:
description: 'Generate PGO data'
required: false
type: boolean
default: false
jobs:
mac-build:
@@ -68,8 +73,8 @@ jobs:
- name: Setup Git
run: |
git config --global user.email "mauro-balades@users.noreply.github.com"
git config --global user.name "mauro-balades"
git config --global user.email "mr-cheffy@users.noreply.github.com"
git config --global user.name "mr-cheffy"
- name: Install system dependencies
run: |
@@ -120,6 +125,18 @@ jobs:
SURFER_COMPAT: ${{ matrix.arch }}
run: npm run import -- --verbose
- name: Download PGO data
if: ${{ inputs.generate-pgo-data == false }}
uses: actions/download-artifact@v4
with:
name: zen-macos-pgo-data-${{ matrix.arch }}
- name: Move PGO data
if: ${{ inputs.generate-pgo-data == false }}
run: |
mkdir -p $(echo ~)/artifact
mv ./zen-macos-pgo-data-*/ $(echo ~)/artifact
- name: Bootstrap
run: |
cd engine
@@ -141,6 +158,7 @@ jobs:
env:
SURFER_COMPAT: ${{ matrix.arch }}
ZEN_RELEASE_BRANCH: ${{ inputs.release-branch }}
ZEN_GENERATE_PGO_DATA: ${{ inputs.generate-pgo-data && '1' || '0' }}
run: |
export SURFER_PLATFORM="darwin"
if [[ -n ${{ inputs.MOZ_BUILD_DATE }} ]];then
@@ -149,6 +167,7 @@ jobs:
bash .github/workflows/src/release-build.sh
- name: Package
if: ${{ !inputs.generate-pgo-data }}
env:
SURFER_COMPAT: ${{ matrix.arch }}
ZEN_GA_DISABLE_PGO: true
@@ -162,6 +181,7 @@ jobs:
rm -rf ~/.zen-keys
- name: Rename artifacts
if: ${{ !inputs.generate-pgo-data }}
run: |
echo "Tarballing DMG"
set -ex
@@ -171,6 +191,7 @@ jobs:
- name: Upload dist dmg
uses: actions/upload-artifact@v4
if: ${{ !inputs.generate-pgo-data }}
with:
retention-days: 1
name: zen-${{ matrix.arch }}-apple-darwin-dist.dmg
@@ -178,7 +199,7 @@ jobs:
- name: Upload host mar
uses: actions/upload-artifact@v4
if: matrix.arch == 'aarch64'
if: matrix.arch == 'aarch64' && !inputs.generate-pgo-data
with:
retention-days: 1
name: zen-macos-host-mar
@@ -186,8 +207,16 @@ jobs:
- name: Upload platform.ini
uses: actions/upload-artifact@v4
if: matrix.arch == 'x86_64'
if: matrix.arch == 'x86_64' && !inputs.generate-pgo-data
with:
retention-days: 1
name: platform.ini
path: ./platform.ini
- name: Upload PGO data
uses: actions/upload-artifact@v4
if: inputs.generate-pgo-data
with:
retention-days: 1
name: zen-macos-pgo-data-${{ matrix.arch }}
path: ./zen-macos-pgo-data

View File

@@ -28,3 +28,22 @@ else
export ZEN_RELEASE=1
npm run build
fi
if test "$ZEN_GENERATE_PGO_DATA" = "1"; then
cd engine
export UPLOAD_PATH=../zen-macos-pgo-data
export MOZ_FETCHES_DIR=/Users/runner/.mozbuild
mkdir -p $UPLOAD_PATH
export JARLOG_FILE="en-US.log"
export LLVM_PROFDATA=$MOZ_FETCHES_DIR/clang/bin/llvm-profdata
set -v
./mach python build/pgo/profileserver.py --binary obj-*-apple-darwin/dist/*.app/Contents/MacOS/zen
mv merged.profdata $UPLOAD_PATH/
mv $JARLOG_FILE $UPLOAD_PATH/
cd ..
fi

View File

@@ -14,15 +14,6 @@ if test "$ZEN_RELEASE"; then
ac_add_options --enable-lto=cross,thin
fi
if test "$ZEN_RELEASE"; then
if test "$ZEN_GA_DISABLE_PGO"; then
export ZEN_DUMMY=1
else
export MOZ_PGO=1
ac_add_options MOZ_PGO=1
fi
fi
if test "$SURFER_COMPAT" = "x86_64"; then
ac_add_options --target=x86_64-apple-darwin
@@ -49,9 +40,18 @@ fi
# Keep using ld64 on PGO/LTO builds because of performance regressions when using lld.
# Mozilla sets "MOZ_LD64_KNOWN_GOOD" to true when they do automated builds with PGO/LTO on macOS.
# See https://searchfox.org/firefox-main/rev/e61d59b5c9a651fd7bf28043f87c0dc669833496/build/moz.configure/lto-pgo.configure#261
# export MOZ_LD64_KNOWN_GOOD=1
# ac_add_options --enable-linker=ld64
#
# if test "$ZEN_RELEASE"; then
# mk_add_options MOZ_MAKE_FLAGS="-j4"
# fi
export MOZ_LD64_KNOWN_GOOD=1
ac_add_options --enable-linker=ld64
if test "$ZEN_RELEASE"; then
if ! test "$ZEN_GA_DISABLE_PGO"; then
if test "$ZEN_GENERATE_PGO_DATA"; then
mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0"
ac_add_options --enable-profile-generate=cross
else
ac_add_options --enable-profile-use=cross
ac_add_options --with-pgo-profile-path=$(echo ~)/artifact/merged.profdata
ac_add_options --with-pgo-jarlog=$(echo ~)/artifact/en-US.log
fi
fi
fi

View File

@@ -62,9 +62,7 @@ if test "$ZEN_CROSS_COMPILING"; then
ac_add_options --enable-profile-generate=cross
elif test "$SURFER_COMPAT" = "x86_64"; then
# Dont use PGO on aarch64 builds and the ZEN_GA_DISABLE_PGO flag is not set
if test "$ZEN_GA_DISABLE_PGO"; then
export ZEN_DUMMY=1
else
if ! test "$ZEN_GA_DISABLE_PGO"; then
ac_add_options --enable-profile-use=cross
ac_add_options --with-pgo-profile-path=$(echo ~)/artifact/merged.profdata
ac_add_options --with-pgo-jarlog=$(echo ~)/artifact/en-US.log