Performance improvement for step execution retrieval #4208
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is for versions 4.3.x and addresses #3790 and #4135.
Using
JobExplorer::getStepExecution
for multiple step executions is not ideal. Each invocation will retrieve the corresponding job execution which in turn triggers the retrieval of all step executions of the job execution. IfJobExplorer::getStepExecution
is used for all step executions, this leads to efforts and memory consumption that scale quadratically in the number of step executions.The idea of the PR is to only call
JobExplorer::getJobExecution
and get the step executions from the returned job execution. The PR is intended to be conservative in its changes due to the late stage of the 4.3.x releases. That's why the filtering on the step execution ids are implemented although I'm not 100% sure that they are actually needed in every case.I tested the change locally with the reproducing project provided here: #3790 (comment) With 250 MB of heap, the application no longer crashes and the memory profile looks much better.
For Spring Batch 5, it makes sense to forward port the change, I think. It should also be considered to deprecate
JobExplorer::getStepExecution
and provide a way to retrieve aStepExecution
from aJobExecution
by id instead.