Skip to content

sandbox-perf: Fix broken benchmarks and make sure they stay fixed. #4265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions bazel_tools/scala-fail-jmh-build-on-error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/src/scala/io/bazel/rules_scala/jmh_support/BenchmarkGenerator.scala b/src/scala/io/bazel/rules_scala/jmh_support/BenchmarkGenerator.scala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me, would be great to upstream to https://github.com/bazelbuild/rules_scala

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index d367ff4..99076ec 100644
--- a/src/scala/io/bazel/rules_scala/jmh_support/BenchmarkGenerator.scala
+++ b/src/scala/io/bazel/rules_scala/jmh_support/BenchmarkGenerator.scala
@@ -12,6 +12,7 @@ import org.openjdk.jmh.runner.options.{Options, OptionsBuilder}
import java.net.URI

import scala.collection.JavaConverters._
+import scala.util.control.NonFatal
import java.nio.file.{FileSystems, Files, Path, Paths}

import io.bazel.rulesscala.jar.JarCreator
@@ -43,13 +44,18 @@ object BenchmarkGenerator {

def main(argv: Array[String]): Unit = {
val args = parseArgs(argv)
- generateJmhBenchmark(
- args.generatorType,
- args.resultSourceJar,
- args.resultResourceJar,
- args.inputJar,
- args.classPath
- )
+ try {
+ generateJmhBenchmark(
+ args.generatorType,
+ args.resultSourceJar,
+ args.resultResourceJar,
+ args.inputJar,
+ args.classPath
+ )
+ } catch {
+ case NonFatal(exception) =>
+ sys.exit(1)
+ }
}

private def parseArgs(argv: Array[String]): BenchmarkGeneratorArgs = {
@@ -172,6 +178,7 @@ object BenchmarkGenerator {
for (e <- destination.getErrors.asScala) {
log(e.toString)
}
+ throw new RuntimeException("JHM Benchmark generator failed")
}
}
constructJar(sourceJarOut, tmpSourceDir)
1 change: 1 addition & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def daml_deps():
sha256 = "132cf8eeaab67f3142cec17152b8415901e7fa8396dd585d6334eec21bf7419d",
patches = [
"@com_github_digital_asset_daml//bazel_tools:scala-escape-jvmflags.patch",
"@com_github_digital_asset_daml//bazel_tools:scala-fail-jmh-build-on-error.patch",
],
patch_args = ["-p1"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@ import com.digitalasset.ledger.api.v1.event.CreatedEvent
import com.digitalasset.ledger.api.v1.value.Identifier
import com.digitalasset.ledger.client.services.acs.ActiveContractSetClient
import com.digitalasset.platform.sandbox.services.TestCommands
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.{Benchmark, Level, Setup}

class AcsBenchState extends PerfBenchState with DummyCommands with InfAwait {

def commandCount = 10000L

@Setup(Level.Invocation)
def submitCommands(): Unit = {
await(
dummyCreates(ledger.ledgerId)
.take(commandCount)
.mapAsync(100)(ledger.commandService.submitAndWait)
.runWith(Sink.ignore)(mat))
()
}
}

class AcsBench extends TestCommands with InfAwait {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import org.openjdk.jmh.annotations._

import scala.concurrent.Await

@State(Scope.Benchmark)
abstract class CreatedStateBase extends PerfBenchState {

override def darFile: File = TestHelper.darFile

@Param(Array("10", "100", "1000", "100000"))
var n: Int = _

var workflowId: String = null
var workflowId: String = _

@Setup(Level.Invocation)
def init(): Unit = {
Expand All @@ -29,17 +30,19 @@ abstract class CreatedStateBase extends PerfBenchState {
def sendCreates(): Unit
}

final class RangeOfIntsCreatedState extends CreatedStateBase {
class RangeOfIntsCreatedState extends CreatedStateBase {

override def sendCreates(): Unit =
Await.result(rangeOfIntsCreateCommand(this, workflowId, n), setupTimeout)
}

final class ListOfNIntsCreatedState extends CreatedStateBase {
class ListOfNIntsCreatedState extends CreatedStateBase {

override def sendCreates(): Unit =
Await.result(listUtilCreateCommand(this, workflowId), setupTimeout)
}

final class LargeTransactionBench {
class LargeTransactionBench {

@Benchmark
def singleHugeContract(state: RangeOfIntsCreatedState): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import akka.stream.scaladsl.Sink
import com.digitalasset.daml.bazeltools.BazelRunfiles._
import org.openjdk.jmh.annotations.Benchmark

class SimpleBenchState extends PerfBenchState with DummyCommands with InfAwait

class SimpleBench extends DummyCommands with InfAwait {

override protected def darFile: File = new File(rlocation("ledger/test-common/Test-stable.dar"))

@Benchmark
def ingest10kCommands(state: PerfBenchState): Unit = {
def ingest10kCommands(state: SimpleBenchState): Unit = {
val commandCount = 10000L
await(
dummyCreates(state.ledger.ledgerId)
Expand Down

This file was deleted.