mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Add README.md, some docs
This commit is contained in:
parent
16b26970a9
commit
c56c9fd455
@ -47,6 +47,12 @@ fun prettyStatsTree(indent: Int, statsTree: StatsTree, builder: StringBuilder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hook simply records the write() entries and exits together with the output offset at the time of the call.
|
||||||
|
* This is recorded in a StrandID -> List<StatsEvent> map.
|
||||||
|
*
|
||||||
|
* Later we "parse" these lists into a tree.
|
||||||
|
*/
|
||||||
object KryoHook : ClassFileTransformer {
|
object KryoHook : ClassFileTransformer {
|
||||||
val classPool = ClassPool.getDefault()
|
val classPool = ClassPool.getDefault()
|
||||||
|
|
||||||
@ -88,17 +94,14 @@ object KryoHook : ClassFileTransformer {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StrandID -> StatsEvent map
|
||||||
val events = ConcurrentHashMap<Long, ArrayList<StatsEvent>>()
|
val events = ConcurrentHashMap<Long, ArrayList<StatsEvent>>()
|
||||||
val eventCount = AtomicInteger(0)
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun writeEnter(kryo: Kryo, output: Output, obj: Any) {
|
fun writeEnter(kryo: Kryo, output: Output, obj: Any) {
|
||||||
events.getOrPut(Strand.currentStrand().id) { ArrayList() }.add(
|
events.getOrPut(Strand.currentStrand().id) { ArrayList() }.add(
|
||||||
StatsEvent.Enter(obj.javaClass.name, output.total())
|
StatsEvent.Enter(obj.javaClass.name, output.total())
|
||||||
)
|
)
|
||||||
if (eventCount.incrementAndGet() % 100 == 0) {
|
|
||||||
println("EVENT COUNT ${eventCount}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun writeExit(kryo: Kryo, output: Output, obj: Any) {
|
fun writeExit(kryo: Kryo, output: Output, obj: Any) {
|
||||||
@ -108,11 +111,17 @@ object KryoHook : ClassFileTransformer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO we could add events on entries/exits to field serializers to get more info on what's being serialised.
|
||||||
|
*/
|
||||||
sealed class StatsEvent {
|
sealed class StatsEvent {
|
||||||
data class Enter(val className: String, val offset: Long) : StatsEvent()
|
data class Enter(val className: String, val offset: Long) : StatsEvent()
|
||||||
data class Exit(val className: String, val offset: Long) : StatsEvent()
|
data class Exit(val className: String, val offset: Long) : StatsEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO add Field constructor.
|
||||||
|
*/
|
||||||
sealed class StatsTree {
|
sealed class StatsTree {
|
||||||
data class Object(
|
data class Object(
|
||||||
val className: String,
|
val className: String,
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
What is this
|
||||||
|
------------
|
||||||
|
|
||||||
|
This is a javaagent that hooks into Kryo serializers to record a breakdown of how many bytes objects take in the output.
|
||||||
|
|
||||||
|
The dump is quite ugly now, but the in-memory representation is a simple tree so we could put some nice visualisation on
|
||||||
|
top if we want.
|
||||||
|
|
||||||
|
How do I run it
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Build the agent:
|
||||||
|
```
|
||||||
|
./gradlew experimental:kryo-hook:jar
|
||||||
|
```
|
||||||
|
|
||||||
|
Add this JVM flag to what you're running:
|
||||||
|
|
||||||
|
```
|
||||||
|
-javaagent:<PROJECT>/experimental/kryo-hook/build/libs/kryo-hook.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
The agent will dump the output when the JVM shuts down.
|
Loading…
Reference in New Issue
Block a user