-
Notifications
You must be signed in to change notification settings - Fork 373
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
Reflect - Calling the same method over and over to be quicker #109
Comments
From the screenshot before vs after, you can see that before the profiler captured around 70 object allocations per seconds when calling that jOOR method via And on the after screenshot the object allocations is down to 1 allocation per second, then we call the |
Thank you very much for your feature request, @davsclaus. There was a deliberate choice in early jOOR design to not cache However, I like your idea of adding the additional functionality of getting a hold of a |
Hello @lukaseder, I was wondering if you are still working on this. I see a lot of interesting new features for Version 0.9.16 will they ever get implemented? |
Not currently as this issue's progress illustrates
Eventually, in the long run, they might. |
Expected behavior and actual behavior:
This is an enhancement request.
In Apache Camel in our new camel-joor component we use jOOR as an expression language in the Camel DSL that allows our end users to use some small scripting code that with the help from jOOR can be pre-compiled to Java. We wrap the end user code into a single class with a single method with the same method signature.
And for runtime we then call that same method over and over again.
I used a profiler (YourKit) and noticed that jOOR spend some time to compute which method to call. And then noticed I was able to get hold of the class type, and with Java reflection I could find the method (that jOOR would also find) and then keep that method reference for reuse and so its much faster.
The "improvement" in the camel-joor is located around this place
https://github.com/apache/camel/blob/master/components/camel-joor/src/main/java/org/apache/camel/language/joor/JoorExpression.java#L89
I wonder if there could be some API in jOOR that allows end users to do something like this, where you can tell jOOR I want a reference to calling a method with this name and these types, and then keep that reference for calling over and over again.
The profiler shows its significant improvement in terms of reduced object allocations etc. I have some screenshots I will paste to this ticket.
Steps to reproduce the problem:
Versions:
The text was updated successfully, but these errors were encountered: