Enabled kryo initialization counts
This commit is contained in:
parent
9b1603daa4
commit
f2bd71d8c4
@ -92,6 +92,7 @@ open class Serialization(private val references: Boolean = true, private val fac
|
|||||||
private lateinit var logger: KLogger
|
private lateinit var logger: KLogger
|
||||||
|
|
||||||
private var initialized = atomic(false)
|
private var initialized = atomic(false)
|
||||||
|
private val initializedKryoCount = atomic(0)
|
||||||
private val kryoPool = MultithreadConcurrentQueue<KryoExtra>(1024) // reasonable size of available kryo's
|
private val kryoPool = MultithreadConcurrentQueue<KryoExtra>(1024) // reasonable size of available kryo's
|
||||||
private val kryoHandshakePool = MultithreadConcurrentQueue<KryoExtra>(1024) // reasonable size of available kryo's
|
private val kryoHandshakePool = MultithreadConcurrentQueue<KryoExtra>(1024) // reasonable size of available kryo's
|
||||||
|
|
||||||
@ -335,6 +336,7 @@ open class Serialization(private val references: Boolean = true, private val fac
|
|||||||
* called as the first thing inside when initializing the classesToRegister
|
* called as the first thing inside when initializing the classesToRegister
|
||||||
*/
|
*/
|
||||||
private fun initKryo(): KryoExtra {
|
private fun initKryo(): KryoExtra {
|
||||||
|
initializedKryoCount.getAndIncrement()
|
||||||
val kryo = KryoExtra()
|
val kryo = KryoExtra()
|
||||||
|
|
||||||
kryo.instantiatorStrategy = instantiatorStrategy
|
kryo.instantiatorStrategy = instantiatorStrategy
|
||||||
@ -530,7 +532,7 @@ open class Serialization(private val references: Boolean = true, private val fac
|
|||||||
// save this as a byte array (so class registration validation during connection handshake is faster)
|
// save this as a byte array (so class registration validation during connection handshake is faster)
|
||||||
val output = AeronOutput()
|
val output = AeronOutput()
|
||||||
try {
|
try {
|
||||||
kryo.writeCompressed(logger, output, registrationDetails.toTypedArray())
|
kryo.write(output, registrationDetails.toTypedArray())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error("Unable to write compressed data for registration details", e)
|
logger.error("Unable to write compressed data for registration details", e)
|
||||||
return false
|
return false
|
||||||
@ -549,7 +551,7 @@ open class Serialization(private val references: Boolean = true, private val fac
|
|||||||
classesToRegisterForRmi: List<ClassRegistrationForRmi>,
|
classesToRegisterForRmi: List<ClassRegistrationForRmi>,
|
||||||
kryo: KryoExtra): Boolean {
|
kryo: KryoExtra): Boolean {
|
||||||
val input = AeronInput(kryoRegistrationDetailsFromServer)
|
val input = AeronInput(kryoRegistrationDetailsFromServer)
|
||||||
val clientClassRegistrations = kryo.readCompressed(logger, input, kryoRegistrationDetailsFromServer.size) as Array<Array<Any>>
|
val clientClassRegistrations = kryo.read(input) as Array<Array<Any>>
|
||||||
|
|
||||||
val maker = kryo.instantiatorStrategy
|
val maker = kryo.instantiatorStrategy
|
||||||
|
|
||||||
@ -627,6 +629,16 @@ open class Serialization(private val references: Boolean = true, private val fac
|
|||||||
kryoHandshakePool.offer(kryo)
|
kryoHandshakePool.offer(kryo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of kryo instances created. This does not reflect the size of the pool, just the number of
|
||||||
|
* existing kryo instances.
|
||||||
|
*
|
||||||
|
* If there are more kryo instances than the pool size, they will end up on the heap and will contribute to GC pauses.
|
||||||
|
*/
|
||||||
|
fun getInitializedKryoCount(): Int {
|
||||||
|
return initializedKryoCount.value
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return takes a kryo instance from the pool, or creates one if the pool was empty
|
* @return takes a kryo instance from the pool, or creates one if the pool was empty
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user