Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short circuit for public method to avoid unnecessary synchronization and cache #90

Open
quaff opened this issue Oct 28, 2019 · 5 comments

Comments

@quaff
Copy link
Contributor

quaff commented Oct 28, 2019

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);
         }

before
https://github.com/jkuhnert/ognl/blob/32d076d209c11da12bebe48d88321b961ac1b087/src/java/ognl/OgnlRuntime.java#L1132

@yasserzamani @lukaszlenart WDYT?

@yasserzamani
Copy link
Contributor

It at least misses two things: checkPermission and invokeMethodInSandbox.

@quaff
Copy link
Contributor Author

quaff commented Oct 29, 2019

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.

@yasserzamani
Copy link
Contributor

yasserzamani commented Oct 29, 2019 via email

@quaff
Copy link
Contributor Author

quaff commented Oct 30, 2019

I've tested one simple scene of my actual application, throughput could increase about 5%, I think it worth a shot.

@JCgH4164838Gh792C124B5
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants