logoalt Hacker News

motoboiyesterday at 7:23 PM2 repliesview on HN

I believe the whole string vs stringbuffer that later was made redundant by compiler contributed to that vision.

People started dismissing allocation discipline as a thing from the past because "that thing was solved a lot ago and the compiler now is smart enough".

Well, for string, yes, but not for arbitrary objects.


Replies

hinkleyyesterday at 9:44 PM

I worked on projects where we indeed needed the manual stringbuffer refactor on hot paths in the code. It's not difficult work but boy is it tedious. Spent a lot of time with headphones on during those days. Only to work on another project a few years later where I paid for my sins by reversing the same change on someone else's codebase.

There's a version of Java, I can't recall which but I want to say 4? Maybe 3? Where someone rewrote parts of the Swing backend as native code to speed it up. Then Hotspot got good enough in the next version that the generated code was faster than the native code + FFI overhead. FFI was pretty high at the time. So they reverted the native code migration and went back to the old code.

cogman10yesterday at 7:30 PM

The most surprising allocation pressure I constantly run into is primitive boxing.

The JVM does heroics to try and avoid it as much as possible, but when you end up with some primitive boxing in a hotspot the amount of GC pressure that creates can be unreal.

show 3 replies