News for hackers. Stuff that matters.
Re:Logging Performance Comparison by ahpeeyem on Sunday July 10, 2022 @09:52PM (#32051310)

    for (; counter < 1_000; counter++) {
        // ... I know this doesn't make much sense :)
    }
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.

Re:Logging Performance Comparison by invalidname on Sunday July 10, 2022 @10:43PM (#32051593)
Exactly my thoughts when reading the article. A bad micro-benchmark that puts everything in bad context as a result. I have numbers on the impact of logging from other articles that show a significant impact, but nothing at this scale.
Re:Logging Performance Comparison by j16sdiz on Sunday July 10, 2022 @10:44PM (#32051600)
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?

Re:Logging Performance Comparison by thfuran on Sunday July 10, 2022 @10:58PM (#32051687)
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 by pwagland on Monday July 11, 2022 @07:48AM (#32054852)
No, but in this case, the JIT will get rid of this empty loop.