We've been using LogbackMDCAdapter, but recently found that it's copying around a lot of hashmaps. We're currently trying out LogbackMDCAdapterSimple, and it seems better and we found that it does even more copying.
Question
Why does Logback provide both LogbackMDCAdapterSimple and LogbackMDCAdapter? Would you consider just consolidating on LogbackMDCAdapterSimple?
Proposed Improvement
Since LogbackMDCAdapterSimple uses a thread local, it doesn't seem like it actually needs to use copy-on-write semantics to keep the map safe. What about using a simple ThreadLocal<Map<String, String>> where the map is mutable and we update it directly?
Result
We require fewer intermediate data structures as we assemble MDC.
Problem
We've been using LogbackMDCAdapter, but recently found that it's copying around a lot of hashmaps. We're currently trying out LogbackMDCAdapterSimple,
and it seems betterand we found that it does even more copying.Question
Why does Logback provide both LogbackMDCAdapterSimple and LogbackMDCAdapter?
Would you consider just consolidating on LogbackMDCAdapterSimple?Proposed Improvement
Since LogbackMDCAdapterSimple uses a thread local, it doesn't seem like it actually needs to use copy-on-write semantics to keep the map safe. What about using a simple ThreadLocal<Map<String, String>> where the map is mutable and we update it directly?
Result
We require fewer intermediate data structures as we assemble MDC.