by hedora · 4y ago · 0 comments
(I didn't say doing this is easy; just that it is easier than reasoning about a JIT)
* sticking to primitives or arrays of primitives as much as possible. The language has no support for user-defined value types!
* Sticking to regular for loops, while loops, and other similar control structures.
* Using offheap memory via Unsafe or similar API when feasible.
"Normally you'd not change this value. I think the default values are quite good balanced because this problems occur on very rare occasions only (in my experince)."
Similarly, your organization tends to run the version of Java that the whole company supports. I have never worked anywhere where someone was allowed to use a different version than the rest of the company for performance reasons.
In contrast, the advice to write low-level code for predictable, high performance has been virtually timeless and generally applicable across languages.
As for the code caches, you're right that it's a binary outcome, but the signals are subtle and if you aren't looking at the right stats a non-expert without a good calibrated gut feeling for how good the performance should be might just conclude that the app was written poorly, or Java just sucks, or whatever.