commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | set -o pipefail |
| 4 | |
| 5 | # Build WebKit, run benchmarks, and spit out compressed PGO profiles |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 6 | |
| 7 | DisplayHelp() { |
| 8 | echo "Usage: build-and-collect-pgo-profiles [ options ]" |
| 9 | echo " -h Show this help message." |
| 10 | echo " -b <directory> Base directory in which output files are stored. Default: /Volumes/WebKit/BenchmarkProfiles/." |
| 11 | echo " -a <app> Path to Safari.app to generate profiles for. If not specified, the script will build WebKit." |
| 12 | echo " -d <directory> Path to build directory. Use seperately from -a." |
| 13 | } |
| 14 | |
| 15 | BASE="/Volumes/WebKit/BenchmarkProfiles/" |
| 16 | |
| 17 | while getopts "b:a:d:h" flag; do |
| 18 | case "${flag}" in |
| 19 | b) BASE=${OPTARG};; |
| 20 | a) APP=${OPTARG};; |
| 21 | d) BUILD=${OPTARG};; |
| 22 | h) |
| 23 | DisplayHelp |
| 24 | exit;; |
| 25 | esac |
| 26 | done |
| 27 | |
| 28 | echo "app: $APP" |
| 29 | echo "build: $BUILD" |
| 30 | echo "base: $BASE" |
| 31 | |
| 32 | if [ ! -z $APP ] && [ ! -z $BUILD ] ; then |
| 33 | echo "These flags (-a and -d) cannot be used together." |
| 34 | DisplayHelp |
| 35 | exit |
| 36 | fi |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 37 | |
| 38 | while true; do |
| 39 | read -p "Have you read the source of this script, and do you understand that it is potentially destructive? [y/N]" yn |
| 40 | case $yn in |
| 41 | [Yy]* ) break;; |
| 42 | [Nn]* ) exit;; |
| 43 | * ) echo "Please answer yes or no.";; |
| 44 | esac |
| 45 | done |
| 46 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 47 | echo "Using output directory: $BASE" |
| 48 | |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 49 | if [[ ! -d "$BASE" ]] ; then |
| 50 | echo "$BASE is missing, aborting." |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 51 | DisplayHelp |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 52 | exit |
| 53 | fi |
| 54 | |
| 55 | rm -rf "$BASE/*" |
| 56 | |
| 57 | mkdir -p "$BASE/speedometer" |
| 58 | mkdir -p "$BASE/jetstream" |
justin_michaud@apple.com | 6489239 | 2022-05-06 18:37:28 +0000 | [diff] [blame] | 59 | mkdir -p "$BASE/motionmark" |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 60 | mkdir -p "$BASE/output" |
| 61 | mkdir -p "$BASE/Internal/WebKit/WebKitAdditions/Profiling/" |
| 62 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 63 | if [[ -z $APP ]] ; then |
| 64 | cd Internal |
| 65 | echo "Building WebKit..." |
| 66 | rm -rf ../OpenSource/WebKitBuild |
| 67 | make release WK_LTO_MODE=thin ENABLE_LLVM_PROFILE_GENERATION=ON |
| 68 | cd ../ |
| 69 | else |
| 70 | if [[ ! -e "$APP" ]] ; then |
| 71 | echo "$APP is missing, aborting." |
| 72 | DisplayHelp |
| 73 | exit |
| 74 | fi |
| 75 | echo "Using .app: $APP" |
| 76 | fi |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 77 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 78 | jsargs=( |
| 79 | --plan jetstream2 |
| 80 | --diagnose-directory="$BASE/jetstream" |
| 81 | --generate-profiles |
| 82 | --count 1 |
| 83 | ) |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 84 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 85 | spargs=( |
| 86 | --plan speedometer2 |
| 87 | --diagnose-directory="$BASE/speedometer" |
| 88 | --generate-profiles |
| 89 | --count 1 |
| 90 | ) |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 91 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 92 | mmargs=( |
| 93 | --plan motionmark1.1 |
| 94 | --diagnose-directory="$BASE/motionmark" |
| 95 | --generate-profiles |
| 96 | --count 1 |
| 97 | ) |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 98 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 99 | if [[ -n $APP ]] ; then |
| 100 | jsargs+=(--browser-path "$APP") |
| 101 | spargs+=(--browser-path "$APP") |
| 102 | mmargs+=(--browser-path "$APP") |
| 103 | else |
| 104 | jsargs+=(--build-directory $BUILD) |
| 105 | spargs+=(--build-directory $BUILD) |
| 106 | mmargs+=(--build-directory $BUILD) |
| 107 | fi |
| 108 | |
| 109 | SPTH='OpenSource/Tools/Scripts' |
| 110 | |
| 111 | $SPTH/run-benchmark "${jsargs[@]}" |
| 112 | $SPTH/pgo-profile merge "$BASE/jetstream" |
| 113 | |
| 114 | $SPTH/run-benchmark "${spargs[@]}" |
| 115 | $SPTH/pgo-profile merge "$BASE/speedometer" |
| 116 | |
| 117 | $SPTH/run-benchmark "${mmargs[@]}" |
| 118 | $SPTH/pgo-profile merge "$BASE/motionmark" |
justin_michaud@apple.com | 6489239 | 2022-05-06 18:37:28 +0000 | [diff] [blame] | 119 | |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 120 | rm *.result |
| 121 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 122 | $SPTH/pgo-profile combine --jetstream "$BASE/jetstream" --speedometer "$BASE/speedometer" --motionmark "$BASE/motionmark" --output "$BASE/output" |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 123 | |
commit-queue@webkit.org | 2d8bf28 | 2022-06-16 17:32:25 +0000 | [diff] [blame] | 124 | $SPTH/pgo-profile compress --input "$BASE/output" --output "$BASE/Internal/WebKit/WebKitAdditions/Profiling/" |
commit-queue@webkit.org | 16463e9 | 2022-04-20 19:30:06 +0000 | [diff] [blame] | 125 | |
| 126 | echo "Done! Find your profiles in $BASE/Internal/WebKit/WebKitAdditions/Profiling/" |
justin_michaud@apple.com | 6489239 | 2022-05-06 18:37:28 +0000 | [diff] [blame] | 127 | echo "To check these in, do: 'cp -r $BASE/Internal/ ../Internal/'" |