Performance of instanceof with interfaces is multiple times slower than with classes
aph at redhat.com
Sat Jul 18 13:00:58 UTC 2020
On 18/07/2020 00:13, John Rose wrote:
> Yes, we can always do something to improve it. Improving this micro could involve attempting to treat trivial interface hierarchies like trivial class hierarchies: But who would this benefit?
Personally speaking, I don't like counter-intuitive performance
gotchas. I know it's been quite a long time since high-level-language
constructs mapped simply onto machine instructions, but even so
predictability is nice to have.
And, just for some healthy competition, we had O(1) interface dispatch
and instanceof in GCJ during the last century. Just sayin'. :-)
Mind you, that O(1) might not have been very fast...
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-runtime-dev