Impact of code difference in Collection#contains() worth improving?
Doug Lea
dl at cs.oswego.edu
Sat Aug 30 17:58:35 UTC 2014
Stepping back from this just a little...
Potential OpenJDK contributors wonder whether, all other things
being equal, they should choose construction A because it is
faster than construction B.
And they'd like a better answer than "it's complicated".
Usually, the answer IS complicated, so it's hard to know
where to start. I suppose one way is to recommend study of or
courses in compilers, systems software, computer architecture, and
algorithm design to provide a conceptual basis for dealing with
virtual machine infrastructures, and then to study OpenJDK source
and try performance experiments to see how they apply or are
extended.
That's not a very satisfying answer either.
In the present case, I'm with Martin about short-circuiting
this with a simple approximate answer: Rather than flip a coin
choosing between solutions A and B, pick the one with smaller bytecode.
This has a decent enough correlation with actual performance
factors to better than chance. And even if the effects are small,
sometimes the only path to making things substantially faster
is a few percent at a time.
-Doug
More information about the core-libs-dev
mailing list