Setup build benchmark jobs (#80941)

Setting up automatic benchmark builds.

This PR allows testing impact on build changes on the build performance by comparing the PR source against master and run different scenarios to verify build performance by using the gradle profiler (see https://github.com/gradle/gradle-profiler)

they can be triggered by adding the `build-benchmark` GitHub label
This commit is contained in:
Rene Groeschke 2021-12-15 09:27:16 +01:00 committed by GitHub
parent 3851f3f75b
commit 2dbf330ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 181 additions and 2 deletions

View File

@ -0,0 +1,51 @@
---
- job:
name: "elastic+elasticsearch+pull-request+build-benchmark"
display-name: "elastic / elasticsearch - pull request build benchmark"
description: "Testing of Elasticsearch pull requests - build benchmark"
workspace: "/dev/shm/elastic+elasticsearch+pull-request+build-bench"
scm:
- git:
refspec: "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*"
branches:
- "${ghprbActualCommit}"
properties:
- inject:
properties-content: |
BUILD_PERFORMANCE_TEST=true
COMPOSE_HTTP_TIMEOUT=120
JOB_BRANCH=%BRANCH%
HOME=$JENKINS_HOME
GRADLEW=./gradlew --parallel --scan --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/
GRADLEW_BAT=./gradlew.bat --parallel --scan --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/
triggers:
- github-pull-request:
org-list:
- elastic
allow-whitelist-orgs-as-admins: true
trigger-phrase: '.*run\W+elasticsearch-ci/build-bench.*'
github-hooks: true
status-context: elasticsearch-ci/build-benchmark
cancel-builds-on-update: true
black-list-target-branches:
- 6.8
excluded-regions:
- ^docs/.*
black-list-labels:
- '>test-mute'
white-list-labels:
- 'build-benchmark'
builders:
- inject:
properties-file: '.ci/java-versions.properties'
properties-content: |
JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA
JAVA8_HOME=$HOME/.java/java8
JAVA11_HOME=$HOME/.java/java11
- shell: |
#!/usr/local/bin/runbld --redirect-stderr
$WORKSPACE/.ci/scripts/run-gradle.sh :build-tools-internal:bootstrapPerformanceTests
$WORKSPACE/.ci/scripts/install-gradle-profiler.sh
$WORKSPACE/.ci/scripts/run-gradle-profiler.sh --benchmark --scenario-file build-tools-internal/build/performanceTests/elasticsearch-build-tool-update.scenarios --project-dir . --output-dir profile-out
tar -czf build/${BUILD_NUMBER}.tar.bz2 profile-out

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# profiler version we wanna install
PROFILER_VERSION="0.16.0"
wget https://repo.gradle.org/gradle/ext-releases-local/org/gradle/profiler/gradle-profiler/$PROFILER_VERSION/gradle-profiler-$PROFILER_VERSION.zip -O $WORKSPACE/gradle-profiler-$PROFILER_VERSION.zip
unzip $WORKSPACE/gradle-profiler-$PROFILER_VERSION.zip
mv $WORKSPACE/gradle-profiler-$PROFILER_VERSION $WORKSPACE/gradle-profiler

View File

@ -0,0 +1,24 @@
#!/bin/bash
# drop page cache and kernel slab objects on linux
[[ -x /usr/local/sbin/drop-caches ]] && sudo /usr/local/sbin/drop-caches
rm -Rfv $WORKSPACE/gradle-user-home
mkdir -p $WORKSPACE/gradle-user-home/init.d && cp -v $WORKSPACE/.ci/init.gradle $WORKSPACE/gradle-user-home
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
MAX_WORKERS=16
elif [ -f /proc/cpuinfo ]; then
MAX_WORKERS=`grep '^cpu\scores' /proc/cpuinfo | uniq | sed 's/\s\+//g' | cut -d':' -f 2`
else
if [[ "$OSTYPE" == "darwin"* ]]; then
MAX_WORKERS=`sysctl -n hw.physicalcpu | sed 's/\s\+//g'`
else
echo "Unsupported OS Type: $OSTYPE"
exit 1
fi
fi
if pwd | grep -v -q ^/dev/shm ; then
echo "Not running on a ramdisk, reducing number of workers"
MAX_WORKERS=$(($MAX_WORKERS*2/3))
fi
set -e
GRADLE_PROFILER="$WORKSPACE/gradle-profiler/bin/gradle-profiler"
$GRADLE_PROFILER "-Dorg.gradle.workers.max=$MAX_WORKERS" $@

View File

@ -6,6 +6,9 @@
* Side Public License, v 1.
*/
import org.apache.tools.ant.filters.ReplaceTokens
import org.elasticsearch.gradle.internal.conventions.info.GitInfo
plugins {
id 'java-gradle-plugin'
id 'groovy-gradle-plugin'
@ -281,3 +284,10 @@ tasks.register("integTest", Test) {
}
tasks.named("check").configure { dependsOn("integTest") }
tasks.register("bootstrapPerformanceTests", Copy) {
from('performance')
into('build/performanceTests')
def root = file('..')
filter(ReplaceTokens, tokens: [testGitCommit:GitInfo.gitInfo(root).revision])
}

View File

@ -0,0 +1,86 @@
# Can specify scenarios to use when none are specified on the command line
default-scenarios = ["buildConfiguration_master", "buildConfiguration_branch", "single_project_branch", "single_project_master", "precommit_master", "precommit_branch"]
buildConfiguration_branch {
title = "configuration phase (@testGitCommit@)"
tasks = ["help"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "@testGitCommit@"
}
}
buildConfiguration_master {
title = "configuration phase (master)"
tasks = ["help"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "master"
}
}
precommit_branch {
title = "precommit (@testGitCommit@)"
cleanup-tasks = ["clean"]
tasks = ["precommit"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "@testGitCommit@"
}
}
precommit_master {
title = "precommit (master)"
cleanup-tasks = ["clean"]
tasks = ["precommit"]
gradle-args = ["--no-scan", "--no-build-cache"]
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "master"
}
}
single_project_branch {
title = "single project (@testGitCommit@)"
cleanup-tasks = [":server:clean"]
tasks = [":server:spotlessApply", ":server:precommit"]
gradle-args = ["--no-scan"]
apply-abi-change-to = "server/src/main/java/org/elasticsearch/Build.java"
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "@testGitCommit@"
}
}
single_project_master {
title = "single project (master)"
cleanup-tasks = [":server:clean"]
tasks = [":server:spotlessApply", ":server:precommit"]
gradle-args = ["--no-scan"]
apply-abi-change-to = "server/src/main/java/org/elasticsearch/Build.java"
run-using = cli // value can be "cli" or "tooling-api"
daemon = warm // value can be "warm", "cold", or "none"
warm-ups = 5
iterations = 10
git-checkout = {
build = "master"
}
}

View File

@ -9,8 +9,8 @@
import java.nio.file.Files
String buildNumber = System.getenv('BUILD_NUMBER')
if (buildNumber) {
String performanceTest = System.getenv('BUILD_PERFORMANCE_TEST')
if (buildNumber && performanceTest != null) {
File uploadFile = file("build/${buildNumber}.tar.bz2")
project.gradle.buildFinished { result ->
println "build complete, generating: $uploadFile"