Reduce boxing of primitives for intercepted `Unsafe` methods
Closed this issue · 0 comments
Problem solved by the enhancement
Currently the interceptors use Byte Buddy's Typing.DYNAMIC
. It seems this causes primitive values to be boxed as corresponding wrapper objects, which might decrease performance.
Enhancement description
First check whether this is really a problem, and whether this affects all intercepted methods using Typing.DYNAMIC
. For example maybe for @Return(typing = DYNAMIC, readOnly = false)
the boxing only occurs when overwriting the return value, which is normally only done for bad memory access (with ErrorAction.PRINT_SKIP
). And assuming that these error cases are rare, the boxing might be acceptable.
This can probably be verified by checking allocations for example with VisualVM, or maybe even setting breakpoints in the IDE for the wrapper object constructors / valueOf
methods.
Then if necessary try to split the interceptors so that the separate interceptors can use the exact types and using Typing.DYNAMIC
is not necessary anymore.