The linked answer on StackOverflow seems to indicate that statically held MethodHandle instances are more than twice as fast as a reflective getting and setting of fields. We should investigate whether we could provide an alternative to the BeanWrapper implementation that uses ASM to generate a PropertyAccessor implementation for a type with the method handles for properties held in static final fields and an if-then-else cascade to select invoke the right one for a given PersistentProperty.
Using method handles here seems suboptimal as the gain is minimal. There's however another possibility of directly calling methods. As we have details about the getter/setter methods, also regarding visibility, it's more efficient generating method calls instead of using method handles, where applicable. A benchmark shows a higher performance gain:
Oliver Drotbohm opened DATACMNS-809 and commented
The linked answer on StackOverflow seems to indicate that statically held
MethodHandle
instances are more than twice as fast as a reflective getting and setting of fields. We should investigate whether we could provide an alternative to theBeanWrapper
implementation that uses ASM to generate aPropertyAccessor
implementation for a type with the method handles for properties held instatic final
fields and an if-then-else cascade to select invoke the right one for a givenPersistentProperty
.Reference URL: http://stackoverflow.com/questions/22244402/how-can-i-improve-performance-of-field-set-perhap-using-methodhandles/22337726#22337726
Referenced from: pull request #159
The text was updated successfully, but these errors were encountered: