Pulled varargs test out of the loop to avoid checking on each parameter#352
Pulled varargs test out of the loop to avoid checking on each parameter#352Boereck wants to merge 1 commit intojava-native-access:masterfrom
Conversation
|
Looks legit, @twall will comment. Can you please squash these commits and add a line to the CHANGES.md? Thx. |
|
I realized that the double check locking will only work if Library$Handler$FunctionInfo is an immutable class (because of possible compiler reordering and Java Memory Model guarantees). So I will fix that, add a short description to the CHANGES.md and squash the commits either later today or tomorrow. |
The Method#isVarargs method is now referenced statically to avoid costs of looking it up on each native method call with at least one parameter. This also can save a lot of memory, since on every Class#getMethod() call a new Method object is returned. Added null check uses the double-checked locking to speed up subsequent calls to the same function. Made Function$Handler$FunctionInfo immutable class to make double check locking work correctly. Added description of changes to CHANGES.md
|
LGTM. |
|
I'll merge. @twall, the Linux build intermittently crashes, maybe you can check it out, I wasn't able to figure out what causes this. |
|
Merged via 7f2c689. |
|
I started looking at this but didn’t find anything conclusive. Will continue… On Jul 24, 2014, at 9:21 AM, Daniel Doubrovkine (dB.) @dblockdotorg [email protected] wrote:
|
Motivation: A new update for java 8 was released Modifications: Update to latest release Result: Use latest java 8 version on the CI
I realized that a lot of time is spent in the isVarArgs method, because it is called for every parameter, but the result will always be the same in each loop iteration.
So I pulled the check out of the loop. For functions with no parameter it introduces one more check and variable assignment, but the gain for methods with >1 parameter is dramatic.
This change makes one of the applications I am working on 13 to 15 percent faster on my machine.