Skip to content

Commit

Permalink
Easier way to debug the runtime/benchOnly command
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Jul 28, 2023
1 parent 82b14c8 commit 95e6dea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/infrastructure/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ source files. In order to change, e.g., the number of measurement iterations, yo
modify the parameter to the `@Measurement` annotation.

### Debugging the benchmarks
Currently, the best way to debug the benchmark is to set the `@Fork` annotation to 0, and to
run `withDebug` command like this:

Make sure your IDE listens for JDWP connection at port 5005.
Debug the benchmark by running `withDebug` command like this:
```
withDebug --debugger benchOnly -- <fully qualified benchmark name>
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.enso.interpreter.bench;

import jakarta.xml.bind.JAXBException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.BenchmarkList;
import org.openjdk.jmh.runner.BenchmarkListEntry;
Expand All @@ -14,6 +14,8 @@
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import jakarta.xml.bind.JAXBException;

/** Runner class for the benchmarks. Discovers, runs and reports benchmark results. */
public class BenchmarksRunner {
public static final File REPORT_FILE = new File("./bench-report.xml");
Expand All @@ -39,7 +41,8 @@ public BenchmarkItem run(String label) throws RunnerException, JAXBException {
if (Boolean.getBoolean("bench.compileOnly")) {
builder
.measurementIterations(1)
.warmupIterations(0);
.warmupIterations(0)
.forks(0);
}

Options benchmarkOptions = builder.build();
Expand Down
9 changes: 7 additions & 2 deletions project/WithDebugCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import sbt._
*/
object WithDebugCommand {
val DEBUG_OPTION =
"-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y";
"-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"

val debugOptions = Seq(
DEBUG_OPTION,
"-Dbench.compileOnly=true"
)

val truffleNoBackgroundCompilationOptions = Seq(
"-Dpolyglot.engine.BackgroundCompilation=false"
Expand Down Expand Up @@ -80,7 +85,7 @@ object WithDebugCommand {
else Seq()
val debuggerOpts =
if (debugFlags.contains(debuggerOption))
Seq(DEBUG_OPTION)
debugOptions
else Seq()
val javaOpts: Seq[String] = Seq(
truffleNoBackgroundCompilationOptions,
Expand Down

0 comments on commit 95e6dea

Please sign in to comment.