Add quasar-hook agent for inspecting quasar instrumentation

This commit is contained in:
Andras Slemmer
2017-05-10 18:42:21 +01:00
parent 25dbac0f07
commit 4cd1f1677f
7 changed files with 410 additions and 2 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

@ -107,7 +107,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()
}
@ -544,7 +544,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
@ -564,6 +564,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) }
}
companion object {
@ -591,6 +592,10 @@ class DriverDSL(
"name" to nodeConf.myLegalName,
"visualvm.display.name" to "corda-${nodeConf.myLegalName}"
)
// 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"