When updating a very large Journal Article with many versions, update times take longer.
This is due to how we are retrieving the display article from JournalArticleLocalServiceImpl.fetchDisplayArticle(). In this method, we retrieve all versions from the article's resource, then determine the latest visible version. However, when article version numbers reach high numbers, this retrieval begins to scale with the large volume of data being stored to memory, causing slow performance.
The solution is now to introduce a configuration which allows for a cap to be placed on how many versions an article can have. Any article version over this cap will be expired, starting with the lowest version number.
Steps to reproduce:
- Copy com.liferay.journal.configuration.JournalServiceConfiguration.configinto the osgi/configs folder. This configuration helps isolate this specific method's slow performance
- Set indexer.enabled[com.liferay.journal.model.JournalArticle]=false in your portal-ext.properties file
- Copy/paste the AddHighVersionedArticle.groovy script in server admin. Modify values if needed, otherwise script will take a few minutes with default values.
- Execute the script
Expected results: As version numbers increase, the time it takes to update an article shouldn't increase by much.
Actual results: Update times increase drastically every few-hundred versions.
Once the solution has been committed, the configuration "maxVersionCount" under com.liferay.journal.configuration.JournalServiceConfiguration can be set to an integer value, capping how many approved versions one article can have at a time. Once capped, performance can be improved since less articles will be fetched and stored into memory at once.
Reproduced on master: 8c6388b2ddd7a5cb16c9492347d7204b001438dd