4 ms·
This was something that was supposed to be about the single best case for hotspot: a single code path almost always, inside a single while loop that's doing the
by TheLoneWolfling 12y ago
This was something that was supposed to be about the single best case for hotspot: a single code path almost always, inside a single while loop that's doing the same thing over and over, with a couple sanity / bail-out checks that are rarely (if ever) called.
And it still didn't optimize something as trivial as avoiding an unnecessary copy that it was taking ~50% of the time doing.
It's too bad - Java is a fine language in many ways (though it tends to be rather overly verbose for no good reason, but meh. Looking at you getters and setters and lack of operator overloading), but it's saddled with a reliance on the arcane to actually get non-hideous performance out of it. I mean: 13ms per copy of what should be a single integer? (Milliseconds! I'm not joking. 595ms inside 47 calls to EnumSet.copyOf (mainly inside Object.clone))
That's, and I'm saying this quite literally, more than a million times slower than what it should be.
Assuming it needs to be done at all, and you can trivially show that it doesn't.
(That being said, I need to explicitly check that Hotspot does do it's full optimization pass on that chunk of code. I see no reason why it wouldn't, but maybe Hotspot doesn't want to. Though that'd be a WTF in and of itself.)
(On a side note: does Java cache hotspot optimizations? I think it does, in which case there's definitely no excuse. And if it doesn't that's a wtf in and of itself.)
(On another side note: is there a Java bytecode-to-bytecode optimizer that'll do optimizations based on the code you've got in front of you now?)
- mreiland 12y agoI honestly don't know too much about Java and its technologies outside of a general understanding of it. I specifically chose to stay out of the Java ecosystem years ago because I disliked the Java community as a whole. They had a real beef with C and C++ being more performant and constantly pushed and railed against both C and C++ to the point of being what I considered completely divorced from reality. Java as a tech is strong, but Java as a community was full of pretentious assholes who had a complex about performance (in my opinion of course). I have no doubt your example was most likely due to some technical issue preventing hotspot from doing what it should have. When hotspot can do it's work it's amazing, you just have to enable it, and you're right about doing arcane things to get performance. That's true in any GC'd language though, even .Net has it's boogeymen.
- TheLoneWolfling 12y agoThis isn't anything to do with GC. This is purely an optimization issue, and one that can be done regardless of if a language is GC'd or not.
- mreiland 12y agoYou're speaking of this specific issue, I'm speaking in general.