Like with any Software, when configured or used incorrectly, performance can be one of the first things to suffer. Smooks is no different in this regard.
This guide is written with Smooks 1.1 in mind. However most tips also apply to older versions of Smooks.
General performance Tips for Smooks:
- Cache and Reuse the Smooks Object. Initialization of Smooks takes some time and therefore it is important that it is reused.
- Only use the HTMLReportGenerator in development. When enabled, the HTMLReportGenerator incurs a significant performance overhead and with large message, can even result in OutOfMemory exceptions.
- If possible, use SAX filtering. However, you need to check that all Smooks Cartridges in use are SAX compatible. SAX processing is a lot faster than DOM processing and has a consistently small memory footprint. It is mandatory for processing large messages. See the Filtering Process Selection section.
- Contextual selectors can obviously have a negative effect on performance e.g. evaluating a match for a selector like "a/b/c/d/e" will obviously require more processing than that of a selector like "d/e". Obviously there will be situations where your data model will require deep selectors, but where it does not, you should try to remove them for the sake of performance.
Every cartridge can have its own performance optimization tips.
- If possible don't use the Virtual Bean Model. Create Beans instead of maps. Creating and adding data to Maps is a lot slower the creating simple POJO's and calling the setter methods.