A Groovy Fix to Improve OFBiz Performance

Jacopo CappellatoPublished: Updated:

A Groovy Fix to Improve OFBiz PerformanceRecently (in rev. 1537086 for trunk and rev. 1537092 for 13.07) I upgraded the Groovy jar bundled in Apache OFBiz from 1.8.6 to the latest release 2.1.9.

I would like to highlight a specific enhancement included in this release, that was actually the main reason I did the upgrade, because it may improve the performance of OFBiz instances exposed to medium/high load.

At HotWax Media we regularly develop and run a series of load tests on OFBiz instances, and we have some procedures to analyze the OFBiz performance under various conditions and loads; when we spot bottlenecks, bugs, or parts of the system that can be improved we look to enhance the system.

Recently, a group of our load tests indicated that after a few hours of medium/heavy load, the system’s response time started to increase and the system started to become unresponsive. I did some research and realized that the problem was not in the OFBiz code, but instead was in the code bundled in the Groovy distribution that OFBiz was using. After analyzing the source code from the Groovy site, I discovered that the issue was due to a sub optimal implementation of thread safety in one of the Groovy classes (ClassLoaderForClassArtifacts): for anyone interested, the details are described in the ticket I have submitted to the Groovy community:

http://jira.codehaus.org/browse/GROOVY-6364

The problem was not actually limited to the 1.8 Groovy branch that OFBiz was using: it was present in all groovy branches including the trunk.
I then implemented a solution for the same (where I have refactored the implementation of thread safety in the class) and submitted a git pull request to see the changes included in the releases:

https://github.com/groovy/groovy-core/pull/256

The contribution has been well accepted and has been available since Groovy 2.1.8, as you can see from the release notes:

http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=10242&version=19570

If you are running an OFBiz instance that may be exposed to medium/high load I would recommend that you upgrade to a Groovy release greater or equal to 2.1.8; or, if you are running Groovy 1.8.* and you want to stick to that release branch, just wait for the bug fix release 1.8.10. That will be the first that includes the aforementioned fix (however I don’t know when it will be released, you will have to ask to the Groovy community); alternatively, you can get the source code and backport my fix (see https://github.com/groovy/groovy-core/pull/256), it should be rather easy to do this.

Jacopo Cappellato About Jacopo Cappellato
Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.

Leave a Reply

Your email address will not be published. Required fields are marked *