XComp commented on code in PR #78: URL: https://github.com/apache/flink-benchmarks/pull/78#discussion_r1353047609
########## src/main/java/org/apache/flink/olap/benchmark/HighAvailabilityServiceBenchmark.java: ########## @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +package org.apache.flink.olap.benchmark; + +import org.apache.curator.test.TestingServer; +import org.apache.flink.api.common.JobID; +import org.apache.flink.benchmark.BenchmarkBase; +import org.apache.flink.benchmark.FlinkEnvironmentContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.util.FileUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.VerboseMode; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.UUID; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** The benchmark for submitting short-lived jobs with and without high availability service. */ +@OutputTimeUnit(SECONDS) +public class HighAvailabilityServiceBenchmark extends BenchmarkBase { + public static void main(String[] args) throws RunnerException { + Options options = + new OptionsBuilder() + .verbosity(VerboseMode.NORMAL) + .include(".*" + HighAvailabilityServiceBenchmark.class.getCanonicalName() + ".*") + .build(); + + new Runner(options).run(); + } + + @Benchmark + public void submitJobThroughput(HighAvailabilityContext context) throws Exception { + context.miniCluster.executeJobBlocking(buildNoOpJob()); + } + + private JobGraph buildNoOpJob() { + JobGraph jobGraph = new JobGraph(JobID.generate(), UUID.randomUUID().toString()); + jobGraph.addVertex(createNoOpVertex()); + return jobGraph; + } + + private JobVertex createNoOpVertex() { Review Comment: ```suggestion private static JobVertex createNoOpVertex() { ``` nit: the create methods could be static ########## pom.xml: ########## @@ -63,6 +63,7 @@ under the License. <chill.version>0.7.6</chill.version> <thrift.version>0.13.0</thrift.version> <protobuf.version>3.21.7</protobuf.version> + <curator.version>5.4.0</curator.version> Review Comment: I guess we have to keep the curator version here aligned with the Flink dependency. Do we have to set it explicitlly or is there a way to use Flink's dependency transitively? :thinking: We might want to add a comment to the corresponding line in [apache/flink:pom.xml:144](https://github.com/apache/flink/blob/ec6ebe2d22d15883f7236895387a45a533cfefe0/pom.xml#L144) to point out that updating the curator version in Flink should result in updating the corresponding version in Flink's benchmark tests as well. ########## src/main/java/org/apache/flink/olap/benchmark/HighAvailabilityServiceBenchmark.java: ########## @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +package org.apache.flink.olap.benchmark; + +import org.apache.curator.test.TestingServer; +import org.apache.flink.api.common.JobID; +import org.apache.flink.benchmark.BenchmarkBase; +import org.apache.flink.benchmark.FlinkEnvironmentContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.util.FileUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.VerboseMode; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.UUID; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** The benchmark for submitting short-lived jobs with and without high availability service. */ +@OutputTimeUnit(SECONDS) +public class HighAvailabilityServiceBenchmark extends BenchmarkBase { + public static void main(String[] args) throws RunnerException { + Options options = + new OptionsBuilder() + .verbosity(VerboseMode.NORMAL) + .include(".*" + HighAvailabilityServiceBenchmark.class.getCanonicalName() + ".*") + .build(); + + new Runner(options).run(); + } + + @Benchmark + public void submitJobThroughput(HighAvailabilityContext context) throws Exception { + context.miniCluster.executeJobBlocking(buildNoOpJob()); + } + + private JobGraph buildNoOpJob() { + JobGraph jobGraph = new JobGraph(JobID.generate(), UUID.randomUUID().toString()); + jobGraph.addVertex(createNoOpVertex()); + return jobGraph; + } + + private JobVertex createNoOpVertex() { + JobVertex vertex = new JobVertex("v"); + vertex.setInvokableClass(NoOpInvokable.class); + vertex.setParallelism(1); + vertex.setMaxParallelism(1); + return vertex; + } + + @State(Thread) + public static class HighAvailabilityContext extends FlinkEnvironmentContext { + private TestingServer testingServer; + public final File haDir; + + @Param({"ZOOKEEPER", "NONE"}) + public HighAvailabilityMode highAvailabilityMode; + + public HighAvailabilityContext() { + try { + haDir = Files.createTempDirectory("bench-ha-").toFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void setUp() throws Exception { + if (isZookeeperHighAvailability()) { + testingServer = new TestingServer(); + testingServer.start(); + } + + super.setUp(); Review Comment: Could we add the reasoning add a comment here? That might help avoiding running into the same question @KarmaGYZ had in the future ########## src/main/java/org/apache/flink/olap/benchmark/HighAvailabilityServiceBenchmark.java: ########## @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +package org.apache.flink.olap.benchmark; + +import org.apache.curator.test.TestingServer; +import org.apache.flink.api.common.JobID; +import org.apache.flink.benchmark.BenchmarkBase; +import org.apache.flink.benchmark.FlinkEnvironmentContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.util.FileUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.VerboseMode; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.UUID; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** The benchmark for submitting short-lived jobs with and without high availability service. */ +@OutputTimeUnit(SECONDS) +public class HighAvailabilityServiceBenchmark extends BenchmarkBase { + public static void main(String[] args) throws RunnerException { + Options options = + new OptionsBuilder() + .verbosity(VerboseMode.NORMAL) + .include(".*" + HighAvailabilityServiceBenchmark.class.getCanonicalName() + ".*") + .build(); + + new Runner(options).run(); + } + + @Benchmark + public void submitJobThroughput(HighAvailabilityContext context) throws Exception { Review Comment: I haven't worked with the benchmark framework, yet. But don't we have to add some repititiveness somewhere? Other benchmark implementations use the `@OperationsPerInvocation` to trigger the test method to run multiple times per invocation (e.g. [TwoInputBenchmark:54](https://github.com/apache/flink-benchmarks/blob/17013937df264f927590a855abb90c4ace2a41d2/src/main/java/org/apache/flink/benchmark/TwoInputBenchmark.java#L54)). ########## src/main/java/org/apache/flink/olap/benchmark/HighAvailabilityServiceBenchmark.java: ########## @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +package org.apache.flink.olap.benchmark; + +import org.apache.curator.test.TestingServer; +import org.apache.flink.api.common.JobID; +import org.apache.flink.benchmark.BenchmarkBase; +import org.apache.flink.benchmark.FlinkEnvironmentContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.util.FileUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.VerboseMode; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.UUID; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** The benchmark for submitting short-lived jobs with and without high availability service. */ Review Comment: Can we add a bit more documentation here? More specifically, adding the motivation (i.e. why this test is necessary) would help, I guess. ########## src/main/java/org/apache/flink/olap/benchmark/HighAvailabilityServiceBenchmark.java: ########## @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * http://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. + */ + +package org.apache.flink.olap.benchmark; + +import org.apache.curator.test.TestingServer; +import org.apache.flink.api.common.JobID; +import org.apache.flink.benchmark.BenchmarkBase; +import org.apache.flink.benchmark.FlinkEnvironmentContext; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.HighAvailabilityOptions; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmanager.HighAvailabilityMode; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.util.FileUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.VerboseMode; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.UUID; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** The benchmark for submitting short-lived jobs with and without high availability service. */ +@OutputTimeUnit(SECONDS) +public class HighAvailabilityServiceBenchmark extends BenchmarkBase { + public static void main(String[] args) throws RunnerException { + Options options = + new OptionsBuilder() + .verbosity(VerboseMode.NORMAL) + .include(".*" + HighAvailabilityServiceBenchmark.class.getCanonicalName() + ".*") + .build(); + + new Runner(options).run(); + } + + @Benchmark + public void submitJobThroughput(HighAvailabilityContext context) throws Exception { + context.miniCluster.executeJobBlocking(buildNoOpJob()); + } + + private JobGraph buildNoOpJob() { Review Comment: ```suggestion private static JobGraph buildNoOpJob() { ``` nit: the create methods could be static -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
