Hello,
During a performance tuning task, we notice a high locking time on com.cognitect.transit.impl.Cache during service startup.

I tracked it down to this code snippet:
|
synchronized (handlerCache) { |
|
writeHandlerMap = handlerCache.get(customHandlers); |
|
if (writeHandlerMap == null) { |
|
writeHandlerMap = new WriteHandlerMap(customHandlers); |
|
handlerCache.put(customHandlers, writeHandlerMap); |
|
} |
|
} |
Without changing the library itself, I wrapped our write handlers here with a WriteHandlerMap class to avoid that block, getting into this code path instead:
|
if (customHandlers instanceof WriteHandlerMap) |
|
return new WriteHandlerMap(customHandlers); |
Doing so significantly improved our locking times; in comparable scenarios, it dropped from 53 minutes of locking time on com.cognitect.transit.impl.Cache to 1 minute and 30 seconds.
I think if we can improve this locking block, maybe replacing it with a ConcurrentHashMap or something else that avoids global locking, we may be able to improve transit performance in high concurrency scenarios.
Hello,
During a performance tuning task, we notice a high locking time on
com.cognitect.transit.impl.Cacheduring service startup.I tracked it down to this code snippet:
transit-java/src/main/java/com/cognitect/transit/impl/WriterFactory.java
Lines 27 to 33 in 8c29b1c
Without changing the library itself, I wrapped our write handlers here with a
WriteHandlerMapclass to avoid that block, getting into this code path instead:transit-java/src/main/java/com/cognitect/transit/impl/WriterFactory.java
Lines 23 to 24 in 8c29b1c
Doing so significantly improved our locking times; in comparable scenarios, it dropped from 53 minutes of locking time on
com.cognitect.transit.impl.Cacheto 1 minute and 30 seconds.I think if we can improve this locking block, maybe replacing it with a
ConcurrentHashMapor something else that avoids global locking, we may be able to improve transit performance in high concurrency scenarios.