Add short circuit for public method to avoid unnecessary synchronization and cache
quaff opened this issue · comments
Here is my proposal:
add
if (Modifier.isPublic(method.getModifiers()) && Modifier.isPublic(method.getDeclaringClass().getModifiers()))
{
// real public method should invoke directly
return method.invoke(target, argsArray);
}
@yasserzamani @lukaszlenart WDYT?
It at least misses two things: checkPermission and invokeMethodInSandbox.
Please think twice, is it necessary for real public methods? if yes, we could call it before real method invoke, my point is avoiding synchronization and reduce cache size.
I've tested one simple scene of my actual application, throughput could increase about 5%, I think it worth a shot.
Hello.
The proposed change might improve performance (avoiding some synchronization) for public method calls but there may not be a clean way to preserve the permission checks and sandboxing calls in the new code path (without reintroducing some form of synchronization). Some kind of opt-in mechanism to bypass the checks/synchronization for public methods might be possible ... but the risk of bypassing the checks probably outweighs a small performance gain.