forked from real-logic/benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
334 lines (289 loc) · 10.6 KB
/
build.gradle
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/*
* Copyright 2015-2023 Real Logic Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'org.ow2.asm:asm:9.5'
classpath 'org.ow2.asm:asm-commons:9.5'
}
}
plugins {
id 'java-library'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.47.0'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'com.google.protobuf' version '0.9.3' apply false
}
defaultTasks 'clean', 'build'
static int getBuildJavaVersion() {
def buildJavaVersion = System.getenv('BUILD_JAVA_VERSION') ?: JavaVersion.current().getMajorVersion()
if (buildJavaVersion.indexOf('.') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('.'))
}
if (buildJavaVersion.indexOf('-') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('-'))
}
Integer.parseInt(buildJavaVersion)
}
int buildJavaVersion = getBuildJavaVersion()
def toolchainLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}
def toolchainCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
}
def agronaVersion = '1.18.2'
def aeronVersion = '1.41.4'
def byteBuddyVersion = '1.14.5'
def jmhVersion = '1.36'
def hdrHistogramVersion = '2.1.12'
def disruptorVersion = '3.4.4'
def junitVersion = '5.9.3'
def mockitoVersion = '4.11.0'
def checkstyleVersion = '9.3'
def grpcVersion = '1.56.0'
def protobufVersion = '3.23.2'
def errorproneVersion = '2.14.0'
def kafkaVersion = '3.5.0'
def slf4jVersion = '1.7.36'
def scalaVersion = '2.13.10'
def jacksonVersion = '2.13.5'
def annotationsApiVersion = '6.0.53'
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
configurations.configureEach {
resolutionStrategy {
failOnVersionConflict()
force "org.agrona:agrona:${agronaVersion}",
"net.bytebuddy:byte-buddy:${byteBuddyVersion}",
"net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}",
"com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
"org.slf4j:slf4j-api:${slf4jVersion}",
"org.slf4j:slf4j-log4j12:${slf4jVersion}",
"org.scala-lang:scala-library:${scalaVersion}",
"org.scala-lang:scala-reflect:${scalaVersion}",
"com.google.protobuf:protobuf-java:${protobufVersion}",
"com.google.errorprone:error_prone_annotations:${errorproneVersion}"
}
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'checkstyle'
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
checkstyle.toolVersion = "${checkstyleVersion}"
tasks.withType(Jar).configureEach {
enabled = true
includeEmptyDirs = false
}
tasks.withType(JavaCompile).configureEach {
if (buildJavaVersion >= 9) {
javaCompiler.set(toolchainCompiler)
}
else {
options.fork = true
def javaHome = toolchainCompiler.get().metadata.installationPath.asFile.toPath().toAbsolutePath()
options.forkOptions.javaHome = javaHome.toFile()
}
options.compilerArgs.add('-XDignore.symbol.file') // Suppress warnings about using Unsafe
options.encoding = 'UTF-8'
options.deprecation = true
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
if (buildJavaVersion >= 9) {
jvmArgs('--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED')
}
testLogging {
for (def level : LogLevel.values())
{
def testLogging = get(level)
testLogging.exceptionFormat = 'full'
testLogging.events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
}
}
javaLauncher.set(toolchainLauncher)
}
}
project(':benchmarks-api') {
dependencies {
api "org.agrona:agrona:${agronaVersion}"
implementation "org.hdrhistogram:HdrHistogram:${hdrHistogramVersion}"
}
}
project(':benchmarks-aeron') {
dependencies {
api project(':benchmarks-api')
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}"
implementation "org.openjdk.jmh:jmh-core:${jmhVersion}"
implementation "io.aeron:aeron-cluster:${aeronVersion}"
implementation "com.lmax:disruptor:${disruptorVersion}"
implementation "org.hdrhistogram:HdrHistogram:${hdrHistogramVersion}"
runtimeOnly "io.aeron:aeron-samples:${aeronVersion}"
}
}
project(':benchmarks-grpc') {
apply plugin: 'com.google.protobuf'
dependencies {
api project(':benchmarks-api')
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
implementation "org.hdrhistogram:HdrHistogram:${hdrHistogramVersion}"
compileOnly "org.apache.tomcat:annotations-api:${annotationsApiVersion}"
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:${protobufVersion}" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
}
generateProtoTasks {
all()*.plugins { grpc {} }
}
}
sourceSets {
main {
proto {
srcDir 'source/main/proto'
srcDir 'build/generated/source/proto/main/java'
srcDir 'build/generated/source/proto/main/grpc'
}
}
}
tasks.processResources.dependsOn('generateProto')
}
project(':benchmarks-kafka') {
dependencies {
api project(':benchmarks-api')
implementation "org.apache.kafka:kafka-clients:${kafkaVersion}"
implementation "org.hdrhistogram:HdrHistogram:${hdrHistogramVersion}"
runtimeOnly "org.apache.kafka:kafka_2.13:${kafkaVersion}"
runtimeOnly "org.slf4j:slf4j-log4j12:${slf4jVersion}"
testImplementation "org.apache.kafka:kafka_2.13:${kafkaVersion}"
testImplementation "org.apache.kafka:kafka-server-common:${kafkaVersion}"
testRuntimeOnly "org.slf4j:slf4j-log4j12:${slf4jVersion}"
}
}
project(':benchmarks-all') {
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
implementation project(':benchmarks-aeron')
implementation project(':benchmarks-grpc')
implementation project(':benchmarks-kafka')
}
shadowJar {
archiveFileName = 'benchmarks.jar'
manifest.attributes('Main-Class': 'org.openjdk.jmh.Main')
mergeServiceFiles()
}
jar.finalizedBy shadowJar
}
static def benchmarkJvmArgs() {
StringBuilder args = new StringBuilder("-Dagrona.disable.bounds.checks=true -XX:+UseParallelGC")
if (buildJavaVersion > 8) {
args.append(" --add-opens java.base/sun.nio.ch=ALL-UNNAMED")
}
return args.toString()
}
tasks.register('runJavaBenchmarks', Exec) {
dependsOn ':benchmarks-all:shadowJar'
commandLine toolchainLauncher.get().executablePath,
'-jar', 'benchmarks-all/build/libs/benchmarks.jar',
'-jvmArgs', benchmarkJvmArgs(),
'-wi', '3', '-w', '1s', '-i', '5', '-r', '1s', '-tu', 'ns', '-f', '5'
}
tasks.register('runAeronJavaBenchmarks', Exec) {
dependsOn ':benchmarks-all:shadowJar'
commandLine toolchainLauncher.get().executablePath,
'-jar', 'benchmarks-all/build/libs/benchmarks.jar',
'-jvmArgs', benchmarkJvmArgs(),
'Aeron',
'-wi', '3', '-w', '1s', '-i', '5', '-r', '1s', '-tu', 'ns', '-f', '5'
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
// Reject all non stable versions
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
FileTree benchmarksFileTree = fileTree('.') {
include 'benchmarks-all/build/libs/benchmarks.jar'
include 'scripts/**'
include 'certificates/**'
}
FileTree cDriverTree = (project.hasProperty('aeron.cdriver.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.package'))) :
files().asFileTree
FileTree cDriverDpdkTree = (project.hasProperty('aeron.cdriver.dpdk.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.dpdk.package'))) :
files().asFileTree
FileTree cDriverEfviTree = (project.hasProperty('aeron.cdriver.efvi.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.efvi.package'))) :
files().asFileTree
FileTree cDriverAtsTree = (project.hasProperty('aeron.cdriver.ats.package')) ?
tarTree(resources.gzip(project.property('aeron.cdriver.ats.package'))) :
files().asFileTree
tasks.register('deployTar', Tar) {
dependsOn ':benchmarks-all:shadowJar'
from(benchmarksFileTree)
from(cDriverTree) {
include "*/**"
eachFile { fcd ->
fcd.relativePath = new RelativePath(true, (String[])fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
from(cDriverDpdkTree)
from(cDriverAtsTree)
from(cDriverEfviTree)
}
tasks.register('copyTestLogs', Copy) {
from '.'
include '**/build/test-output/**'
include '**/*.log'
include '**/*.tlog'
include '**/build/reports/tests/**'
include '**/build/test-results/*/TEST*.xml'
include 'LICENSE'
exclude 'build'
into 'build/test_logs'
includeEmptyDirs = false
}
tasks.register('tarTestLogs', Tar) {
dependsOn tasks.named('copyTestLogs')
archiveBaseName.set('test_logs')
from 'build/test_logs'
compression Compression.BZIP2
}
wrapper {
gradleVersion = '8.1.1'
distributionType = 'ALL'
}