forked from ClickHouse/clickhouse-java
-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (172 loc) · 7.66 KB
/
Copy pathbenchmark.yml
File metadata and controls
175 lines (172 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Benchmark
on:
pull_request_target:
branches:
- master
- develop
types:
- opened
- synchronize
- reopened
workflow_dispatch:
inputs:
clickhouse:
description: "ClickHouse version"
required: true
default: "latest"
java:
description: "Java version"
required: true
default: "8"
baseline:
description: "Baseline to compare"
required: true
default: "0.2.6"
driver:
description: "Driver version"
required: true
default: "0.3.2-SNAPSHOT"
options:
description: "Benchmark options"
required: true
default: "-prof gc 'Query|Insertion'"
pr:
description: "Pull request#"
required: false
jobs:
benchmark-pull-request:
runs-on: ubuntu-latest
name: Benchmark pull request
if: github.event_name == 'pull_request_target'
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
- name: Extract version
id: version
run: |
echo ::set-output name=value::$(grep '<revision>' pom.xml | sed -e 's|.*>\(.*\)<.*|\1|')
- name: Update version and group id
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ steps.version.outputs.value }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ steps.version.outputs.value }}\2|' \
-e 's|${parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
- name: Build project
run: |
mvn --batch-mode --update-snapshots -q -DskipTests install
cd clickhouse-benchmark
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf text \
-p client=clickhouse-http-jdbc1 -p client=clickhouse-grpc-jdbc -p type=object Basic
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV
cat jmh-result.text >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
cd -
- name: Comment PR
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const report = process.env.BENCHMARK_REPORT;
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
if (report) {
github.issues.createComment({issue_number, owner, repo, body: '```\n' + report + '\n```'});
}
benchmark-on-demand:
runs-on: ubuntu-latest
name: Benchmark on demand
if: github.event_name == 'workflow_dispatch'
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Check out PR
run: |
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
if: github.event.inputs.pr != ''
- name: Set up JDK ${{ github.event.inputs.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ github.event.inputs.java }}
continue-on-error: true
- name: Update version and group id
run: |
find . -type f -name "pom.xml" -exec sed -i -e 's|${revision}|${{ github.event.inputs.driver }}|g' \
-e 's|^\( <version>\).*\(</version>\)$|\1${{ github.event.inputs.driver }}\2|' \
-e 's|${parent.groupId}|com.clickhouse|g' -e 's|${project.parent.groupId}|com.clickhouse|g' '{}' \;
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
continue-on-error: true
- name: Install driver as needed
run: mvn --batch-mode --update-snapshots -q -DskipTests install
if: endsWith(github.event.inputs.driver, '-SNAPSHOT')
continue-on-error: true
- name: Build project
run: |
mvn --batch-mode --update-snapshots -DskipTests -pl clickhouse-benchmark -am package
cd clickhouse-benchmark
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf json ${{ github.event.inputs.options }} > output.txt
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV
tail -n +$(grep -n '^REMEMBER:' output.txt | tail -1 | awk -F: '{print $1+6}') output.txt | head -n -2 | grep -v ':·' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
cd -
id: benchmark
continue-on-error: true
- name: Record benchmark results
run: |
mv -fv clickhouse-benchmark/jmh-result.json \
clickhouse-benchmark/docs/results/v${{ github.event.inputs.driver }}.json
if: github.event.inputs.pr == ''
continue-on-error: true
- name: Record pull request benchmark results
run: |
mv -fv clickhouse-benchmark/jmh-result.json \
clickhouse-benchmark/docs/results/pull-request_${{github.event.inputs.pr}}.json
if: github.event.inputs.pr != ''
continue-on-error: true
- name: Commit benchmark result
uses: zhicwu/add-and-commit@v7
with:
add: 'clickhouse-benchmark/docs/results/*.json'
author_name: zhicwu
author_email: 4270380+zhicwu@users.noreply.github.com
branch: develop
message: 'Record benchmark results'
push: true
continue-on-error: true
- name: Get commit hash
run: |
echo ::set-output name=hash::$(git log --pretty=format:'%H' -n 1)
id: commit
continue-on-error: true
- name: Comment PR
uses: actions/github-script@v3
if: github.event.inputs.pr != ''
env:
PR_NO: ${{ github.event.inputs.pr }}
COMMIT_HASH: ${{ steps.commit.outputs.hash }}
COMPARE_TO: ${{ github.event.inputs.baseline }}
CLICKHOUSE_VRESION: ${{ github.event.inputs.clickhouse }}
DRIVER_VRESION: ${{ github.event.inputs.driver }}
JAVA_VERSION: ${{ github.event.inputs.java }}
PREV_STEP_RESULT: '${{ steps.benchmark.outcome }}'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = process.env.PR_NO;
const { repo: { owner, repo } } = context;
const result = process.env.PREV_STEP_RESULT;
const compareUrl = `http://jmh.morethan.io/?sources=https://raw.githubusercontent.com/${owner}/${repo}/develop/clickhouse-benchmark/docs/results/v${process.env.COMPARE_TO}.json,https://raw.githubusercontent.com/${owner}/${repo}/${process.env.COMMIT_HASH || 'develop'}/clickhouse-benchmark/docs/results/${issue_number ? 'pull-request_' + issue_number : 'v' + process.env.DRIVER_VERSION}.json`;
// const benchmarkUrl = `http://jmh.morethan.io/?source=https://raw.githubusercontent.com/${owner}/${repo}/${process.env.COMMIT_HASH || 'develop'}/clickhouse-benchmark/docs/results/${issue_number ? 'pull-request_' + issue_number : 'v' + process.env.DRIVER_VERSION}.json`;
const buildUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`;
const flag = result === 'success'
? ':green_circle:'
: (result === 'failure' ? ':red_circle:' : ':yellow_circle:');
let msg = `${flag} [benchmark](${compareUrl}) using JDK [${process.env.JAVA_VERSION}] and ClickHouse [${process.env.CLICKHOUSE_VRESION}]: [${result}](${buildUrl})`;
if (result === 'success') {
msg = msg + '<details>\n<summary>Expand to see details...</summary>\n\n```\n'
+ process.env.BENCHMARK_REPORT || '' + '\n```\n</details>';
}
github.issues.createComment({ issue_number, owner, repo, body: msg });