Bean Scripting Framework Performance Problems
Posted by Dean Wampler Fri, 02 Mar 2007 16:03:00 GMT
A Contract4J5 user reported performance problems using Groovy. After some investigation, it appears that using the Bean Scripting Framework (BSF) increases the overhead of script evaluation by a factor of 3 or so! The overhead for script evaluation is already very high (roughly a factor of 7-10 times slower compared to no contracts). Scripting is expensive if used heavily, as it is in C4J!!
I’m not sure why BSF’s overhead is so high, but I’m going to implement support for Groovy and JRuby that bypasses BSF. This may take a while to complete, as I have a busy few weeks ahead.
The older non-BSF integration with Jexl is still in the distribution (although it’s currently marked as deprecated). If you want to use it, put the following code in your main or similar initialization methods:
Contract4J c4j = Contract4J.getInstance();
ContractEnforcer ce = c4j.getContractEnforcer();
ce.setExpressionInterpreter (new JexlExpressionInterpreter());Correction: You can also use the properties file configurator or the Spring configuration file options to specify Jexl without the BSF wrapper.
You’ll get warnings that JexlExpressionInterpreter is deprecated. You can safely ignore them. I’ll remove that javadoc tag in the next minor update.
Longer term, I’m trying to improve the use of caching to further reduce the overhead of C4J.
