Spring Batch 4.2.0.RC1 published , this is a use Spring framework written in Java and off-line and batch applications. This update mainly improved performance for the core framework.
Then look at the specific improvements, including a total of four aspects:
- Step Partitioning feature enhancements
- Improved Job Stop
- Faster Writes with the
JpaItemWriter
- Optimized Bean Mapping with the
BeanWrapperFieldSetMapper
Step Partitioning feature enhancements
All along, Spring Batch framework are not good to start partitioned step optimization carried out. In this version, the team depth study of the zoning process in order to identify the root cause of this performance issue. One of the main steps of the process is to find a partition step (partitioned step to see whether the current execution restarting) the last execution. Thus the team discovered last step execution loads all the step to perform all tasks from execution in a given memory instance, which significantly reduces the efficiency.
To this end, the team uses a SQL query (query the database level) to replace these codes, only to return last step executed. The end result is very good, according to the partitioned-step-benchmark benchmark results, using this method step execution is divided into 5000 partition will eventually speed increased nearly 10-fold:
Improved Job Stop function
Improvement of the above and this function is similar, but also through the use SQL queries to improve the efficiency, the final results are as follows
Use JpaItemWritershi
faster write
JpaItemWritershi
Using the javax.persistence.EntityManager#merge
function to write entries in JPA persistence context. When the state entry is an update of known or unknown state, which is meaningful. But in many of the known data and the new data should be considered as inserting data file extraction tasks, use javax.persistence.EntityManager#merge
efficiency is not high.
In this release, the team JpaItemWriter
introduced a new option for use in the above scenario persist
, rather than merge
. With this option, according to jpa-writer-benchmark benchmark, file extraction tasks JpaItemWriter
in the database insert one million entries 2 times faster than before.
Use BeanWrapperFieldSetMapper
of Bean Mapping optimization
BeanWrapperFieldSetMapper
Provides a very useful feature, it allows us to use fuzzy matching a given JavaBean (hump named, nested attributes, etc.) of the field name. When the field name matches the name of the column, it can be prepared by distanceLimit
the parameters set to zero to enable exact match.
This release fixes BeanWrapperFieldSetMapper
performance issues, according to bean-mapping-benchmark benchmark test results, entry of the mapping speed 1.5 times faster than before.
Finally, all benchmark tests are Macbook Pro (16GB RAM, 2.9 GHz Intel Core i7 CPU, MacOS Mojave 10.14.5, Oracle JDK 1.8.0_201) carried equipment. Relevant benchmark source code as follows:
- partitioned-step-benchmark: https://github.com/benas/spring-batch-sandbox/tree/master/batch2716
- stop-benchmark: https://github.com/benas/spring-batch-sandbox/tree/master/batch2422
- jpa-writer-benchmark: https://github.com/benas/spring-batch-sandbox/tree/master/batch2462
- bean-mapping-benchmark: https://github.com/benas/spring-batch-sandbox/tree/master/batch1801
下一个版本是 Spring Batch 4.2.0 的候选版,将于 9 月 30 日发布。