Impact of code difference in Collection#contains() worth improving?

John Rose john.r.rose at
Fri Sep 5 23:32:36 UTC 2014

On Aug 30, 2014, at 10:58 AM, Doug Lea <dl at> wrote:

> 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.

I grant you that's better than a coin flip.

Contributions from the constant pool and various attributes are going to be pretty noisy and unrelated to instruction traces.

You'll get somewhat less random information from measuring the affected method's bytecodes.

(Which is hard to do without writing an ASM-based tool, and compared with "wc -c Foo.class".)

— John

More information about the core-libs-dev mailing list