Skip to content

Optimize for single TransactionSynchronization #27335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

marschall
Copy link
Contributor

Optimize TransactionSynchronizationManager.getSynchronizations() to
avoid sorting and ArrayList creation in case of a single
TransactionSynchronization.

Optimize TransactionSynchronizationManager.getSynchronizations() to
avoid sorting and ArrayList creation in case of a single
TransactionSynchronization.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 30, 2021
@marschall
Copy link
Contributor Author

marschall commented Aug 30, 2021

Spring Batch registers a single TransactionSynchronization in TaskletStep#doExecute(StepExecution). In certain extreme cases the ArrayList and Object[] creation can become noticeable. This PR optimizes the case of a single TransactionSynchronization, avoids the sorting and instead calls Collections#singletonList(Object).

Before:

TransactionSynchronizationManager_getSynchronizations

After:

after-patch

@rstoyanchev rstoyanchev added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Nov 11, 2021
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 26, 2023
@snicoll snicoll self-assigned this Aug 26, 2023
@snicoll snicoll added this to the 6.1.0-RC1 milestone Aug 26, 2023
snicoll pushed a commit that referenced this pull request Aug 26, 2023
Optimize TransactionSynchronizationManager.getSynchronizations() to
avoid sorting and ArrayList creation in case of a single
TransactionSynchronization.

See gh-27335
@snicoll snicoll closed this in 16cb296 Aug 26, 2023
@marschall
Copy link
Contributor Author

Thank you for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants