Skip to content
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

Fix build of engine benchmarks #8620

Merged
merged 4 commits into from
Dec 22, 2023
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
101 changes: 79 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import src.main.scala.licenses.{
DistributionDescription,
SBTDistributionComponent
}
import sbt.librarymanagement.DependencyFilter

// This import is unnecessary, but bit adds a proper code completion features
// to IntelliJ.
import JPMSPlugin.autoImport.*

import java.io.File
import scala.collection.mutable.ListBuffer

// ============================================================================
// === Global Configuration ===================================================
Expand Down Expand Up @@ -1687,15 +1685,88 @@ lazy val runtime = (project in file("engine/runtime"))
.dependsOn(`std-aws` / Compile / packageBin)
.value
)
/** Benchmark settings */
.settings(
inConfig(Benchmark)(Defaults.testSettings),
Benchmark / fork := true,
Benchmark / parallelExecution := false,
(Benchmark / modulePath) := {
val requiredModIds = GraalVM.modules ++ GraalVM.langsPkgs ++ Seq(
"org.slf4j" % "slf4j-api" % slf4jVersion,
"org.slf4j" % "slf4j-nop" % slf4jVersion
)
val requiredMods = JPMSUtils.filterModulesFromUpdate(
(Benchmark / update).value,
requiredModIds,
streams.value.log,
shouldContainAll = true
)
val runtimeMod =
(`runtime-fat-jar` / Compile / exportedProducts).value.head.data
requiredMods ++ Seq(runtimeMod)
},
(Benchmark / addModules) := Seq(
(`runtime-fat-jar` / javaModuleName).value
),
(Benchmark / addReads) := Map(
(`runtime-fat-jar` / javaModuleName).value -> Seq("ALL-UNNAMED")
),
(Benchmark / patchModules) := {
val modulesToPatchIntoRuntime: Seq[File] =
(LocalProject(
"runtime-instrument-common"
) / Compile / productDirectories).value ++
(LocalProject(
"runtime-instrument-id-execution"
) / Compile / productDirectories).value ++
(LocalProject(
"runtime-instrument-repl-debugger"
) / Compile / productDirectories).value ++
(LocalProject(
"runtime-instrument-runtime-server"
) / Compile / productDirectories).value ++
(LocalProject(
"runtime-language-epb"
) / Compile / productDirectories).value ++
(LocalProject(
"runtime-compiler"
) / Compile / productDirectories).value
Map(
(`runtime-fat-jar` / javaModuleName).value -> modulesToPatchIntoRuntime
)
},
// Reset javacOptions and javaOptions - do not inherit them from the Test scope
(Benchmark / javacOptions) := (Compile / javacOptions).value,
(Benchmark / javaOptions) := (Compile / javaOptions).value,
(Benchmark / javacOptions) ++= {
JPMSPlugin.constructOptions(
streams.value.log,
modulePath = (Benchmark / modulePath).value,
addModules = (Benchmark / addModules).value
)
},
(Benchmark / javaOptions) ++= {
JPMSPlugin.constructOptions(
streams.value.log,
(Benchmark / modulePath).value,
(Benchmark / addModules).value,
(Benchmark / patchModules).value,
(Benchmark / addExports).value,
(Benchmark / addReads).value
)
},
(Benchmark / javaOptions) ++= benchOnlyOptions,
// Override test log provider and its resource
(Benchmark / javaOptions) ++= Seq(
"-Dslf4j.provider=org.enso.logger.TestLogProvider",
"-Dconfig.resource=application-bench.conf"
),
(Benchmark / compile) := (Benchmark / compile)
.dependsOn(`runtime-fat-jar` / Compile / compileModuleInfo)
.value,
bench := (Benchmark / test)
.tag(Exclusive)
.dependsOn(
// runtime.jar fat jar needs to be assembled as it is used in the
// benchmarks. This dependency is here so that `runtime/bench` works
// after clean build.
LocalProject("runtime-fat-jar") / assembly
)
.dependsOn(Benchmark / compile)
.value,
benchOnly := Def.inputTaskDyn {
import complete.Parsers.spaceDelimited
Expand All @@ -1708,20 +1779,6 @@ lazy val runtime = (project in file("engine/runtime"))
}
}.evaluated
)
/** Benchmark settings */
.settings(
inConfig(Benchmark)(Defaults.testSettings),
Benchmark / javacOptions --= Seq(
"-source",
frgaalSourceLevel,
"--enable-preview"
),
(Benchmark / javaOptions) :=
(LocalProject("std-benchmarks") / Benchmark / run / javaOptions).value,
(Benchmark / javaOptions) ++= benchOnlyOptions,
Benchmark / fork := true,
Benchmark / parallelExecution := false
)
.dependsOn(`common-polyglot-core-utils`)
.dependsOn(`edition-updater`)
.dependsOn(`interpreter-dsl`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {

var benchmarkName = SrcUtil.findName(params);
var code = """
from Standard.Base.Any import Any
from Standard.Base.Data.List.List import Cons, Nil
from Standard.Base.Data.Text import Text
from Standard.Base.Data.Numbers import Float
from Standard.Base import Integer
import Standard.Base.IO

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally left empty - use the default settings for the log provider
9 changes: 0 additions & 9 deletions project/JPMSPlugin.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import sbt.*
import sbt.Keys.*
import sbt.internal.inc.{CompileOutput, PlainVirtualFile}
import sbt.util.CacheStore
import sbtassembly.Assembly.{Dependency, JarEntry, Project}
import sbtassembly.{CustomMergeStrategy, MergeStrategy}
import xsbti.compile.IncToolOptionsUtil

import java.io.File

Expand Down Expand Up @@ -50,10 +45,6 @@ object JPMSPlugin extends AutoPlugin {
|""".stripMargin
)
val compileModuleInfo = taskKey[Unit]("Compile module-info.java")
val modulePathTestOptions_ = taskKey[Seq[String]](
"Assembles options for the JVM for running tests with all the required modules. " +
"Including truffle-compiler and org.enso.runtime modules and all their dependencies."
)
}

import autoImport.*
Expand Down
Loading