

How I sped up Go by 20% (or is Go really slower than Java?) - moogle19
https://blog.kowalczyk.info/article/u3d4/How-I-sped-up-Go-by-20-or-is-Go-really-slower-th.html

======
Doradus
_" Go compiles to native code. Java, ultimately, does too, but compilation
happens at runtime, which is an overhead that Go doesn’t have, so in principle
Go should be faster."_

Oh boy. It pains me every time I hear this.

In a microbenchmark, JIT compilation increases the time to ramp up to peak
performance. Once you're at peak performance, compilation time doesn't matter
anymore. At that point, the JIT compiler's drawbacks are mitigated by two
distinct advantages.

First, the JIT has information about run-time conditions that was unavailable
to the static compiler. It's hard to over-state how important it is to know,
for example, which if-statements are highly biased, or which polymorphic calls
are effectively monomorphic at run time.

Second, the JIT can make over-aggressive optimizations based on unverified
assumptions, secure in the knowledge that when an assumption proves to be
wrong, it can discard that code and re-compile another version of the same
method, optimized according to the latest available information. This is only
possible if the compiler is present at run-time.

[These are my personal opinions, not those of my employer.]

