Skip to content

Commit 0b4640a

Browse files
committed
[GR-44732] Add new microservice benchmarks
PullRequest: graal/13993
2 parents ab57b20 + 28aa710 commit 0b4640a

File tree

3 files changed

+146
-6
lines changed

3 files changed

+146
-6
lines changed

java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py

Lines changed: 117 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,13 @@ def parserNames(self):
172172
return super(TemporaryWorkdirMixin, self).parserNames() + ["temporary_workdir_parser"]
173173

174174

175-
class BaseMicroserviceBenchmarkSuite(object):
175+
class BaseMicroserviceBenchmarkSuite(mx_benchmark.BenchmarkSuite):
176176
def group(self):
177177
return "Graal"
178178

179179
def subgroup(self):
180180
return "graal-compiler"
181181

182-
def version(self):
183-
raise NotImplementedError()
184-
185182
def validateReturnCode(self, retcode):
186183
return retcode == 143
187184

@@ -238,6 +235,7 @@ def mainClass(self):
238235
def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
239236
lib = self.applicationDist()
240237
classpath = os.path.join(lib, "BOOT-INF/classes")
238+
classpath += ':' + os.path.join(lib, "classes")
241239
for filename in os.listdir(os.path.join(lib, "BOOT-INF/lib")):
242240
if filename.endswith(".jar"):
243241
classpath = classpath + ":" + os.path.join(lib, "BOOT-INF/lib", filename)
@@ -258,8 +256,16 @@ def default_stages(self):
258256

259257

260258
class BasePetClinicBenchmarkSuite(BaseSpringBenchmarkSuite):
261-
def version(self):
262-
return "0.1.6"
259+
"""
260+
Version 0.1.7 MIGHT NOT be fully functional. So far, it was used only to collect image build time metrics.
261+
"""
262+
def availableSuiteVersions(self):
263+
# 0.1.6 is still based on org.springframework.experimental
264+
# 0.1.7 is based on Spring 3, hence with official GraalVM NI support, requires Java 17 or newer
265+
return ["0.1.6", "0.1.7"]
266+
267+
def defaultSuiteVersion(self):
268+
return self.availableSuiteVersions()[0]
263269

264270
def applicationDist(self):
265271
return mx.library("PETCLINIC_" + self.version(), True).get_path(True)
@@ -477,6 +483,111 @@ def extra_image_build_argument(self, benchmark, args):
477483
def default_stages(self):
478484
return ['instrument-image', 'instrument-run', 'image', 'run']
479485

486+
class BaseQuarkusRegistryBenchmark(BaseQuarkusBenchmarkSuite, mx_sdk_benchmark.BaseMicroserviceBenchmarkSuite):
487+
"""
488+
This benchmark is NOT yet fully functional - there is not load for measuring its runtime performance.
489+
It is only useful to collect image build time metrics.
490+
"""
491+
492+
def version(self):
493+
return "0.0.1"
494+
495+
def name(self):
496+
return "quarkus"
497+
498+
def benchmarkList(self, bmSuiteArgs):
499+
return ["registry"]
500+
501+
def default_stages(self):
502+
return ['image']
503+
504+
def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
505+
if benchmarks is None:
506+
mx.abort("Suite can only run a single benchmark per VM instance.")
507+
elif len(benchmarks) != 1:
508+
mx.abort("Must specify exactly one benchmark.")
509+
else:
510+
benchmark = benchmarks[0]
511+
return self.vmArgs(bmSuiteArgs) + ["-jar", os.path.join(self.applicationDist(), benchmark + ".jar")]
512+
513+
def applicationDist(self):
514+
return mx.library("QUARKUS_REGISTRY_" + self.version(), True).get_path(True)
515+
516+
def extra_image_build_argument(self, benchmark, args):
517+
return ['-J-Dsun.nio.ch.maxUpdateArraySize=100',
518+
'-J-Djava.util.logging.manager=org.jboss.logmanager.LogManager',
519+
'-J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false',
520+
'-J-Dio.quarkus.caffeine.graalvm.recordStats=true',
521+
'-J-Dlogging.initial-configurator.min-level=500',
522+
'-J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory',
523+
'-J-Dvertx.disableDnsResolver=true',
524+
'-J-Dio.netty.noUnsafe=true',
525+
'-J-Dio.netty.leakDetection.level=DISABLED' ,
526+
'-J-Dio.netty.allocator.maxOrder=3',
527+
'-J-Duser.language=en',
528+
'-J-Duser.country=GB',
529+
'-J-Dfile.encoding=UTF-8',
530+
'--features=org.hibernate.graalvm.internal.GraalVMStaticFeature,io.quarkus.hibernate.orm.runtime.graal.DisableLoggingFeature,io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature,org.hibernate.graalvm.internal.QueryParsingSupport,io.quarkus.jdbc.postgresql.runtime.graal.SQLXMLFeature,io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature,io.quarkus.hibernate.validator.runtime.DisableLoggingFeature',
531+
'-J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED',
532+
'-J--add-opens=java.base/java.text=ALL-UNNAMED',
533+
'-J--add-opens=java.base/java.io=ALL-UNNAMED',
534+
'-J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED',
535+
'-J--add-opens=java.base/java.util=ALL-UNNAMED',
536+
'-H:+AllowFoldMethods',
537+
'-J-Djava.awt.headless=true',
538+
'--no-fallback',
539+
'-H:+ReportExceptionStackTraces',
540+
'-H:-AddAllCharsets',
541+
'--enable-url-protocols=http,https',
542+
'-H:-UseServiceLoaderFeature',
543+
'-H:+StackTrace',
544+
'-J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED',
545+
'-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
546+
'--exclude-config' ,
547+
'io\.netty\.netty-codec',
548+
'/META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json',
549+
'--exclude-config',
550+
'io\.netty\.netty-handler',
551+
'/META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json'
552+
] + super(BaseQuarkusBenchmarkSuite,self).extra_image_build_argument(benchmark, args)
553+
554+
mx_benchmark.add_bm_suite(BaseQuarkusRegistryBenchmark())
555+
556+
class BaseMicronautMuShopBenchmark(BaseMicronautBenchmarkSuite, mx_sdk_benchmark.BaseMicroserviceBenchmarkSuite):
557+
"""
558+
This benchmark suite is NOT yet fully functional - there is not load for measuring its runtime performance.
559+
It is only useful to collect image build time metrics.
560+
"""
561+
562+
def version(self):
563+
return "0.0.1"
564+
565+
def name(self):
566+
return "mushop"
567+
568+
def benchmarkList(self, bmSuiteArgs):
569+
return ["user", "order", "payment"]
570+
571+
def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
572+
if benchmarks is None:
573+
mx.abort("Suite can only run a single benchmark per VM instance.")
574+
elif len(benchmarks) != 1:
575+
mx.abort("Must specify exactly one benchmark.")
576+
else:
577+
benchmark = benchmarks[0]
578+
return self.vmArgs(bmSuiteArgs) + ["-jar", os.path.join(self.applicationDist(), benchmark + ".jar")]
579+
580+
def applicationDist(self):
581+
return mx.library("MICRONAUT_MUSHOP_" + self.version(), True).get_path(True)
582+
583+
def extra_image_build_argument(self, benchmark, args):
584+
return [
585+
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
586+
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED',
587+
'--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED'
588+
] + super(BaseMicronautBenchmarkSuite,self).extra_image_build_argument(benchmark, args)
589+
590+
mx_benchmark.add_bm_suite(BaseMicronautMuShopBenchmark())
480591

481592
class BaseShopCartBenchmarkSuite(BaseMicronautBenchmarkSuite):
482593
def version(self):

java-benchmarks/mx.java-benchmarks/suite.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,30 @@
1313
"packedResource": True,
1414
},
1515

16+
"MICRONAUT_MUSHOP_0.0.1" : {
17+
"urls": ["https://graalvm.oraclecorp.com/ci-legacy/slavefiles2/substratevm/native-benchmarks-experimental/mu-shop-0.0.1.zip"],
18+
"digest": "sha512:41f91679c2077a9c252cfc29b8cbf7884f2e9f3c411cfe6c88d807d346178b76299bc5c3f446290b84139ca3a9f6f18c91511fc8ee90b47549b4a8c19cdb337d" ,
19+
"packedResource": True
20+
},
21+
22+
"QUARKUS_REGISTRY_0.0.1" : {
23+
"urls": ["https://graalvm.oraclecorp.com/ci-legacy/slavefiles2/substratevm/native-benchmarks-experimental/quarkus-registry-0.0.1.zip"],
24+
"digest": "sha512:fb798881ea406f05dd01523479b323a8e5ed6a59a545a70c06ec153ccfdb0a45be9b98d544d9fc5360007aae519a1221a7b2a794316dfc9cb9a38126ae13a9b3" ,
25+
"packedResource": True
26+
},
27+
1628
"PETCLINIC_0.1.6": {
1729
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/petclinic-jpa-0.1.6.zip"],
1830
"digest": "sha512:d16f251e4b5727c8a0e2f653a7d1d2b41967414d960e6a490d8e9fa4715f752b7f7bfc73dd069a001053bc1a4f75583abb40577c79017fef4c8f5cc972c0ed25",
1931
"packedResource": True,
2032
},
2133

34+
"PETCLINIC_0.1.7": {
35+
"urls": ["https://graalvm.oraclecorp.com/ci-legacy/slavefiles2/substratevm/native-benchmarks-experimental/petclinic-jpa-0.1.7.zip"],
36+
"digest": "sha512:fe8f34a6cbb24099e3cc68051c857e82536c6d81498c604157e6312c04e675745d6f77dd292adde006307d5319b77917bbc9e5f301501ab1e9c072870be113a5",
37+
"packedResource": True,
38+
},
39+
2240
"SHOPCART_0.3.6": {
2341
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/shopcart-0.3.6.zip"],
2442
"digest": "sha512:0ea6402e2325e8cfad2c6592c0fa36faf0c6719125f4edefc2c13740c4bfe500e8cc2726e56404c6ac6abcefb2dbf73e6d9a479d49af7e373ba665c92a4ecffc",

vm/mx.vm/mx_vm_benchmark.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,17 @@ def __init__(self, vm, bm_suite, args):
204204
self.stages.remove(stage)
205205
if self.image_vm_args is not None:
206206
self.base_image_build_args += self.image_vm_args
207+
self.is_runnable = self.check_runnable()
207208
self.base_image_build_args += self.extra_image_build_arguments
208209

210+
def check_runnable(self):
211+
# TODO remove once there is load available for the specified benchmarks
212+
if self.benchmark_suite_name in ["mushop", "quarkus"]:
213+
return False
214+
if self.benchmark_suite_name == "petclinic-wrk":
215+
return self.bmSuite.version() == "0.1.6"
216+
return True
217+
209218
def __init__(self, name, config_name, extra_java_args=None, extra_launcher_args=None, **kwargs):
210219
super(NativeImageVM, self).__init__(name, config_name, extra_java_args, extra_launcher_args)
211220
if len(kwargs) > 0:
@@ -890,6 +899,8 @@ def run_stage_image(self, config, stages):
890899
mx.run(upx_cmd, s.stdout(True), s.stderr(True))
891900

892901
def run_stage_run(self, config, stages, out):
902+
if not config.is_runnable:
903+
mx.abort(f"Benchmark {config.benchmark_suite_name}:{config.benchmark_name} is not runnable.")
893904
image_path = os.path.join(config.output_dir, config.final_image_name)
894905
with stages.set_command([image_path] + config.image_run_args) as s:
895906
s.execute_command(vm=self)

0 commit comments

Comments
 (0)