Merge pull request #669 from corda/aslemmer-quasar-hook

Add quasar-hook agent for inspecting quasar instrumentation
This commit is contained in:
Andras Slemmer
2017-05-11 15:34:46 +01:00
committed by GitHub
7 changed files with 400 additions and 3 deletions

View File

@ -0,0 +1,27 @@
package net.corda.node
import com.google.common.base.Stopwatch
import net.corda.node.driver.driver
import org.junit.Ignore
import org.junit.Test
import java.util.concurrent.TimeUnit
@Ignore("Only use locally")
class NodeStartupPerformanceTests {
// Measure the startup time of nodes. Note that this includes an RPC roundtrip, which causes e.g. Kryo initialisation.
@Test
fun `single node startup time`() {
driver(automaticallyStartNetworkMap = false) {
startNetworkMapService().get()
val times = ArrayList<Long>()
for (i in 1 .. 10) {
val time = Stopwatch.createStarted().apply {
startNode().get()
}.stop().elapsed(TimeUnit.MICROSECONDS)
times.add(time)
}
println(times.map { it / 1_000_000.0 })
}
}
}

View File

@ -104,7 +104,7 @@ interface DriverDSLExposedInterface {
* Starts a network map service node. Note that only a single one should ever be running, so you will probably want
* to set automaticallyStartNetworkMap to false in your [driver] call.
*/
fun startNetworkMapService()
fun startNetworkMapService(): ListenableFuture<Unit>
fun waitForAllNodesToFinish()
@ -561,7 +561,7 @@ class DriverDSL(
}
}
override fun startNetworkMapService() {
override fun startNetworkMapService(): ListenableFuture<Unit> {
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
val apiAddress = portAllocation.nextHostAndPort().toString()
val baseDirectory = driverDirectory / networkMapLegalName.commonName
@ -581,6 +581,7 @@ class DriverDSL(
log.info("Starting network-map-service")
val startNode = startNode(executorService, config.parseAs<FullNodeConfiguration>(), config, quasarJarPath, debugPort, systemProperties)
registerProcess(startNode)
return startNode.flatMap { addressMustBeBound(executorService, networkMapAddress, it) }
}
override fun <A> pollUntilNonNull(pollName: String, pollInterval: Duration, warnCount: Int, check: () -> A?): ListenableFuture<A> {
@ -615,6 +616,10 @@ class DriverDSL(
"visualvm.display.name" to "corda-${nodeConf.myLegalName}",
"java.io.tmpdir" to System.getProperty("java.io.tmpdir") // Inherit from parent process
)
// TODO Add this once we upgrade to quasar 0.7.8, this causes startup time to halve.
// val excludePattern = x(rx**;io**;kotlin**;jdk**;reflectasm**;groovyjarjarasm**;groovy**;joptsimple**;groovyjarjarantlr**;javassist**;com.fasterxml**;com.typesafe**;com.google**;com.zaxxer**;com.jcabi**;com.codahale**;com.esotericsoftware**;de.javakaffee**;org.objectweb**;org.slf4j**;org.w3c**;org.codehaus**;org.h2**;org.crsh**;org.fusesource**;org.hibernate**;org.dom4j**;org.bouncycastle**;org.apache**;org.objenesis**;org.jboss**;org.xml**;org.jcp**;org.jetbrains**;org.yaml**;co.paralleluniverse**;net.i2p**)"
// val extraJvmArguments = systemProperties.map { "-D${it.key}=${it.value}" } +
// "-javaagent:$quasarJarPath=$excludePattern"
val extraJvmArguments = systemProperties.map { "-D${it.key}=${it.value}" } +
"-javaagent:$quasarJarPath"
val loggingLevel = if (debugPort == null) "INFO" else "DEBUG"