richardstartin commented on issue #335: Import of LogstashLayout as JsonTemplateLayout URL: https://github.com/apache/logging-log4j2/pull/335#issuecomment-580229964 > I don’t think we’re measuring the cost of GC anywhere, are we? At this scale, there are so many confounding factors which can explain a difference, and you won't get an explanation without profiling the benchmark. One quite big factor at this scale is the choice of garbage collector, and _not_ because of the time it spends collecting garbage. I just guessed (in what I thought was a private conversation) that the cost might be explained by the little bit of machine code the JIT compiler inserts into reference assignments to track inter-region references (the write barrier). In my experience, this can really show up in microbenchmarks running G1, especially with some concurrency. My advice was simply to run the benchmark with a different garbage collector and see how much it affects the numbers. Since I was tagged here, my advice would be to think twice about optimising this, and think about the future. If someone imports this library, they may well never upgrade it, but stack allocation which might be implemented in the JIT compiler would: * remove the garbage (benefit vs heap allocation) * avoid any contention (benefit vs pooling) * avoid an increase in the number of GC roots (benefit vs thread local) Applications would benefit automatically when they upgrade the JVM, but not if you optimise this now.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services