Skip to content

Commit

Permalink
Added check to disregard jmh failed attempts as legit
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Aug 13, 2024
1 parent 2667f54 commit fc074a3
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions runBenchmarks.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import scala.util.boundary
import scala.util.boundary.break

// Combinations of driver, project, Gb mem, known to OOM
val oomCombinations: Set[(String, String, Int)] = Set(("tinkergraph", "compress", 2))
val drivers = Seq("overflowdb", "tinkergraph", "neo4j-embedded")
val drivers = Seq("overflowdb", "tinkergraph", "neo4j-embedded")

@main def main(): Unit = {
println("[info] Ensuring compilation status and benchmark dataset availability...")
Expand All @@ -28,7 +27,9 @@ val drivers = Seq("overflowdb", "tinkergraph
val outputPath = Path.of(driverResultsDir.toString, s"output-Xmx${memGb}G")
val (writeOutputFile, readOutputFile) =
(Path.of(s"$outputPath-write.txt").toFile, Path.of(s"$outputPath-read.txt").toFile)
val existingAttempt = Path.of(s"$outputPath-sbt.txt").toFile.exists()
val sbtFile = Path.of(s"$outputPath-sbt.txt").toFile
val existingAttempt =
sbtFile.exists() && !readLogsForJmhClassLoaderError(sbtFile) // If there is a jmh error we retry
val cmd =
s"Jmh/runMain com.github.plume.oss.Benchmark $driver ${projectDir.toAbsolutePath} -o ${outputPath.toAbsolutePath} -r ${resultsPath.toAbsolutePath} -m $memGb"
JmhProcessInfo(cmd, existingAttempt, writeOutputFile, readOutputFile)
Expand All @@ -47,27 +48,40 @@ val drivers = Seq("overflowdb", "tinkergraph
drivers.foreach { driver =>
projects.foreach { project =>
val projectName = project.getFileName.toString.toLowerCase.stripSuffix(".jar")
if (oomCombinations.contains(driver, projectName, memConfig)) {
val JmhProcessInfo(cmd, resultsExist, writeOutputFile, readOutputFile) =
benchmarkArgs(driver, project.getFileName.toString, memConfig)
if (resultsExist) {
println(
s"[info] '$driver' on project '$project' with `-Xmx${memConfig}G` will cause an OutOfMemoryException. Skipping..."
s"[info] An attempt for '$driver' on project '$projectName' with `-Xmx${memConfig}G` already exist. Skipping..."
)
} else {
val JmhProcessInfo(cmd, resultsExist, writeOutputFile, readOutputFile) =
benchmarkArgs(driver, project.getFileName.toString, memConfig)
if (resultsExist) {
println(
s"[info] An attempt for '$driver' on project '$project' with `-Xmx${memConfig}G` already exist. Skipping..."
)
} else {
println(s"[info] Benchmarking '$driver' on project '$project' with `-Xmx${memConfig}G`")
runAndMonitorBenchmarkProcess(cmd, writeOutputFile, readOutputFile)
}
println(s"[info] Benchmarking '$driver' on project '$projectName' with `-Xmx${memConfig}G`")
runAndMonitorBenchmarkProcess(cmd, writeOutputFile, readOutputFile)
}
}
}
}
}

def readLogsForJmhClassLoaderError(file: File): Boolean = {
val reader = new BufferedReader(new FileReader(file))
var hasError = false
try {
var line: String = null
while ({
line = reader.readLine();
line != null
}) {
if (line.contains("jmhType.class (No such file or directory)")) {
hasError = true
}
}
} finally {
reader.close()
}
hasError
}

def sendCtrlCSignal(processId: Long): Unit = {
val osName = System.getProperty("os.name").toLowerCase
if (osName.contains("win")) {
Expand All @@ -83,7 +97,7 @@ def runAndMonitorBenchmarkProcess(cmd: String, writeOutputFile: File, readOutput
writeOutputFile.createIfNotExists
readOutputFile.createIfNotExists

val sbtFile = File(writeOutputFile.getAbsolutePath.stripSuffix("write.txt") + "sbt.txt")
val sbtFile = File(writeOutputFile.getAbsolutePath.stripSuffix("write.txt") + "sbt.txt")
val processBuilder = new java.lang.ProcessBuilder("sbt", cmd).redirectOutput(sbtFile)

// Ignore locks for aborted JMH processes
Expand Down Expand Up @@ -123,7 +137,8 @@ def runAndMonitorBenchmarkProcess(cmd: String, writeOutputFile: File, readOutput
var shouldTerminate = false
while (!shouldTerminate && process.isAlive) {
Thread.sleep(5000)
shouldTerminate = readLogsForErrors(writeOutputFile) || readLogsForErrors(readOutputFile) || readLogsForErrors(sbtFile)
shouldTerminate =
readLogsForErrors(writeOutputFile) || readLogsForErrors(readOutputFile) || readLogsForErrors(sbtFile)
}
}

Expand Down

0 comments on commit fc074a3

Please sign in to comment.