Live data from Hacker News

Logging Performance Comparison

blog.sebastian-daschner.com

11–20 of 20 posts

Re: Logging Performance Comparison

#11

Really liked the data driven approach of this article

Yes, but the methodology is completely broken. He uses microbenchmarks on a JVM which can eliminate these instantly. It's inconsistent with findings from other logging benchmarks (especially the last bit).

Re: Logging Performance Comparison

#12
post #10
post #8

for (; counter I think the JVM would optimise away this loop because it doesn't do anything. e.g. if the loop optimisation method is to unroll the loop into 1000 inline statements, there's nothing there. This makes "No Logging" result not quite a fair comparison; maybe something like the sum of 1000 random numbers do some actual work in the loop.

In many C/C++ optimizing compiler, this is replaced with `counter = 1000;`. I have no idea how java handle this.. Does the AOT compiler do any optimization? Would this defer to the JIT?

There is aot native compilation in javaland these days, but I assume you mean javac, the compiler that transforms source into jvm bytecode. It defers pretty much all optimization to the JITs and won't remove empty loops.

Re: Logging Performance Comparison

#13
Now compare the efficiency of minimal logging compared to lotsa logging (even if most of it is only conditionally enabled), when optimising for dev time spent on troubleshooting :)

The one thing from modern Java logging I love and miss in other languages is being able to set log levels on specific loggers while the app is running.

Yeah it involves JMX, which has an annoying protocol that insists on domain names that you can resolve, making it a PITA with K8s from your local terminal, but it's such a QoL feature.

Re: Logging Performance Comparison

#14

Now compare the efficiency of minimal logging compared to lotsa logging (even if most of it is only conditionally enabled), when optimising for dev time spent on troubleshooting :) The one thing from modern Java logging I love and miss in other languages is being able to set log levels on specific loggers while the app is running. Yeah it involves JMX, which has an annoying protocol that insists on domain names that…

Both Log4j2 and Logback support automatic reloading of the configuration file at a regular interval - just update the file and the log library picks it up after X seconds.

Should work well with K8s config map mounted as volume.

Re: Logging Performance Comparison

#17
I really hope no one takes this analysis to heart. If I was moved onto a project without logging for this reason I would be pretty pissed. If you already have the quarkus project, why not get some metrics in real use-cases, instead of a weird do-nothing loop?

Re: Logging Performance Comparison

#18
post #16

Isn't buffered log writer prone to error (read not flushing to output) in case of ie. Premature container termination?

Yes, as he says:

> The downside of this approach is that if the system crashes without a chance to flush the buffer, the last lines might not have been written and may be lost.

Re: Logging Performance Comparison

#19

Now compare the efficiency of minimal logging compared to lotsa logging (even if most of it is only conditionally enabled), when optimising for dev time spent on troubleshooting :) The one thing from modern Java logging I love and miss in other languages is being able to set log levels on specific loggers while the app is running. Yeah it involves JMX, which has an annoying protocol that insists on domain names that…

> Now compare the efficiency of minimal logging compared to lotsa logging (even if most of it is only conditionally enabled), when optimising for dev time spent on troubleshooting :)

Or even for successful requests per second averaged over spans of time including normal outages, degradations, and other indignities of life. It doesn't take many minutes at zero throughput to drag those averages down, so every minute shaved off by more illuminating logging is a performance benefit.

Re: Logging Performance Comparison

#20
post #12
post #10

Earlier quoted context omitted.

In many C/C++ optimizing compiler, this is replaced with `counter = 1000;`. I have no idea how java handle this.. Does the AOT compiler do any optimization? Would this defer to the JIT?

There is aot native compilation in javaland these days, but I assume you mean javac, the compiler that transforms source into jvm bytecode. It defers pretty much all optimization to the JITs and won't remove empty loops.

No, but in this case, the JIT will get rid of this empty loop.
Post reply on HN