Allow method inlining of ObjectUtils.nullSafeEquals() [SPR-14349] #18921
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Christoph Dreis opened SPR-14349 and commented
Hey,
while doing a benchmark in our project with the JVM options
I noticed that ObjectUtils.nullSafeEquals() is a hot method, but is unfortunately too big for the VM to inline it. At least with the defaults of 325 bytecodes as it currently shows up with 337 bytes.
I made a small improvement by simply extracting the more uncommon use-case of checking for array equality, which reduces the method to 55 bytes and allows the inlining of the method. As a small side-benefit it also reduces the cyclomatic complexity of the method itself.
I also created a small microbenchmark that looks like this:
The results of this microbenchmark look roughly like this.
I created a PR with my changes at #1076 and would be very happy if this gets accepted.
Keep up the great work!
Cheers,
Christoph
Affects: 3.2.17, 4.2.6
Referenced from: pull request #1076, and commits ca12e13, 14ab980, 71df9ce
Backported to: 4.2.7, 3.2.18
The text was updated successfully, but these errors were encountered: