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

Lock contention in Java Beanshell interpreter under high load #565

Closed
ajain-adeptia opened this issue Jul 17, 2019 · 1 comment
Closed

Comments

@ajain-adeptia
Copy link

We are using Java BeanShell interpreter (v1.2 b7) in our application for dynamically executing standard Java syntax.

Sample Code

bsh.Interpreter interpreter = new bsh.Interpreter();
interpreter.set("context", ctx);
interpreter.set("transaction", transaction);
interpreter.set("log", log);
interpreter.eval(script);

We are having a problem under high load where we are seeing thread lock contention when multiple threads execute above code simultaneously. We have multiple threads in the waiting state which is degrading application performance.

Here are the call stack traces of waiting and blocked threads:

Waiting Thread Call Stack

java.util.Vector.addElement():619
bsh.classpath.ClassManagerImpl.addListener():N/A
bsh.BshClassManager.addCMListener():N/A
bsh.NameSpace.<init>():N/A
bsh.BlockNameSpace.<init>():N/A
bsh.BSHBlock.eval():N/A
bsh.BSHBlock.eval():N/A
bsh.BSHWhileStatement.eval():N/A
bsh.Interpreter.eval():N/A
bsh.Interpreter.eval():N/A
bsh.Interpreter.eval():N/A

Blocked Thread Call Stack

java.util.Vector.indexOf():408
java.util.Vector.indexOf():382
java.util.Vector.removeElement():641
bsh.classpath.ClassManagerImpl.addListener():N/A
bsh.BshClassManager.addCMListener():N/A
bsh.NameSpace.<init>():N/A
bsh.BshMethod.invokeDeclaredMethod():N/A
bsh.Name.invokeLocalMethod():N/A
bsh.Name.invokeMethod():N/A
bsh.BSHMethodInvocation.eval():N/A
bsh.BSHPrimaryExpression.eval():N/A
bsh.Interpreter.eval():N/A
bsh.Interpreter.eval():N/A
bsh.Interpreter.eval():N/A

I have checked the source code for the latest version (v2.0 b6) and it also seems to have the same issue. As you can see beanshell uses Vector on listeners objects. Obviously, Vector is "overprotected" on its internals.

The master branch seems to have this issue fixed but I am not sure if the fix is available to be used. The release date of BSH v3.0 is not yet decided and this issue is impacting us badly.

Is there a way to port this fix to v2.0 b6 - can you please help? The priority of this issue is high as it is degrading the performance of our application.

Thanks!

@nickl-
Copy link
Member

nickl- commented Jul 18, 2019

The master branch seems to have this issue fixed but I am not sure if the fix is available to be used. The release date of BSH v3.0 is not yet decided and this issue is impacting us badly.

The only version of BeanShell we recommend and can support is a manual build of master.
All I can suggest is for you ship the BSH 3.0.0-SNAPSHOT jar with your application then you don't need a release.

Is there a way to port this fix to v2.0 b6 - can you please help?

You can read through the roadmap and to see where we are and hopefully you can grasp the impossibility of what you are requesting. We are so far removed from the old trees. 2 separate development trees merged, that there is no way in the world to piece port anything back. You are welcome to try.

The priority of this issue is high as it is degrading the performance of our application.

You certainly have a priority to change as you are using a beta and very broken library. There has been many issues fixed not just this one you are facing.

Perhaps this is a difference in philosophy but I cannot release a beta, let alone depend on beta libraries for my apps, We will only know that we have a stable release once all the outstanding issues are resolved. The only way we will resolve all these issues is if more people make it a priority to help us work through them. They are all orphans ported from the source forge project without owners it makes our task even harder.

To be clear:
We won't release if all the outstanding issues aren't resolved or they will never be resolved. If you are eager to see a release of BeanShell 3.0.0 then take ownership of some of these issues and help us to work through them.

Closed: Fixed in HEAD

@nickl- nickl- closed this as completed Jul 18, 2019
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

2 participants