Skip to content

Commit

Permalink
Merge pull request #459 from renaissance-benchmarks/issue/458
Browse files Browse the repository at this point in the history
Set 'java.class.path' temporarily during Chronicle intialization
  • Loading branch information
lbulej authored Nov 20, 2024
2 parents 967ea9c + 54ec743 commit 18ece12
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ The following is the complete list of benchmarks, separated into groups.

- `db-shootout` - Executes a shootout test using several in-memory databases.
\
Default repetitions: 16; APACHE2 license, MIT distribution; Supported JVM: 11 - 22
Default repetitions: 16; APACHE2 license, MIT distribution; Supported JVM: 11 and later

- `neo4j-analytics` - Executes Neo4j graph queries against a movie database.
\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import org.renaissance.BenchmarkResult
import org.renaissance.BenchmarkResult.Validators
import org.renaissance.License

import java.io.File
import java.net.URLClassLoader
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import scala.collection.Seq

@Name("db-shootout")
@Group("database")
@Summary("Executes a shootout test using several in-memory databases.")
@Licenses(Array(License.APACHE2))
@SupportsJvm("22") // Works on Java 24 in standalone mode.
@Repetitions(16)
@Parameter(name = "rw_entry_count", defaultValue = "500000")
@Configuration(name = "test", settings = Array("rw_entry_count = 10000"))
Expand Down Expand Up @@ -49,6 +55,21 @@ final class DbShootout extends Benchmark {

var mvStoreWriter: MvStore.Writer = _

private def buildChronicleClassPath(classPath: String): Seq[Path] = {
val elements = classPath.split(File.pathSeparatorChar).map(Paths.get(_)).toSeq
Thread.currentThread.getContextClassLoader match {
case ucl: URLClassLoader =>
ucl.getURLs.map(url => Paths.get(url.toURI)).filter { path =>
val fn = path.getFileName.toString
fn.startsWith("chronicle-core") || fn.startsWith("chronicle-bytes")
}
case _ =>
// Fall back to current class path.
// This should be the case in standalone mode.
elements
}
}

override def setUpBeforeAll(c: BenchmarkContext): Unit = {
val tempDirPath = c.scratchDirectory()
val readWriteEntryCountParam = c.parameter("rw_entry_count").toPositiveInteger
Expand All @@ -59,12 +80,24 @@ final class DbShootout extends Benchmark {
mapDbReader.setup(tempDirPath.toFile, readWriteEntryCountParam)
mapDbWriter.setup(tempDirPath.toFile, readWriteEntryCountParam)

//
// Chronicle needs the 'java.class.path' property to contain certain jars because
// it is using the Java compiler to compile generated source code and expects the
// compiler to find libraries through the normal class path. It is enough to set
// the property during initialization.
//
val oldClassPath = System.getProperty("java.class.path")
val newClassPath = buildChronicleClassPath(oldClassPath).mkString(File.pathSeparator)
System.setProperty("java.class.path", newClassPath)

chronicle = new Chronicle
chronicleReader = new Chronicle.Reader
chronicleWriter = new Chronicle.Writer
chronicleReader.setup(tempDirPath.toFile, readWriteEntryCountParam)
chronicleWriter.setup(tempDirPath.toFile, readWriteEntryCountParam)

System.setProperty("java.class.path", oldClassPath)

mvStore = new MvStore
mvStoreReader = new MvStore.Reader
mvStoreWriter = new MvStore.Writer
Expand Down

0 comments on commit 18ece12

Please sign in to comment.