Skip to content
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

Performance Improvement: optimized DatabaseChangeLog.normalizePath() #3853

Merged
merged 3 commits into from Mar 17, 2023

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Feb 22, 2023

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

PR #3063 improved performance of DatabaseChangeLog.normalizePath() by no longer re-compiling regular expressions, but it is a method that is called often and with a large changelog it still appears to be a bottleneck.

This PR replaces the regular expressions with more efficient "replace" calls and/or adds a "if it might be a problem" gate around the regexp call.

From testing, it removed about half the time spent based on profiling data from #3816

Fixes partially #3816

Things to be aware of

It may be possible to reduce the number of calls to this function in the first place as well. As part of the review process, it is probably worth looking to see if we keep re-calling normalizePath for the same paths over and over or not.

In testing this, the customer reported that it caused some validation errors (see #3816). I'm not sure how it could off hand, since it's just in the normalizePath, it's possibly causing some changesets to be identical now? So needs a bit more unit testing

Things to worry about

Not much, there are existing tests around the normalizePath() which would fail as I pulled out each regexp before replacing it with a comparable replace() call

Additional Context

@github-actions
Copy link

github-actions bot commented Feb 22, 2023

Unit Test Results

  5 317 files  ±0    5 317 suites  ±0   38m 12s ⏱️ + 1m 33s
  4 902 tests ±0    4 683 ✔️ ±0     219 💤 ±0  0 ±0 
62 672 runs  ±0  56 635 ✔️ ±0  6 037 💤 ±0  0 ±0 

Results for commit af1410a. ± Comparison against base commit 5ac168a.

♻️ This comment has been updated with latest results.

@nvoxland nvoxland changed the title Replaced regular expressions with replacement for peformance reasons Performance Improvement: optimized DatabaseChangeLog.normalizePath() Feb 22, 2023
@filipelautert filipelautert self-assigned this Mar 1, 2023
@nvoxland
Copy link
Contributor Author

nvoxland commented Mar 7, 2023

The validation errors appear to be caused by a separate change that was already in master. #3881

…rmance

# Conflicts:
#	liquibase-core/src/main/java/liquibase/changelog/DatabaseChangeLog.java
Copy link
Collaborator

@filipelautert filipelautert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the performance back!

Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is a performance improvement to avoid a processing bottleneck while loading large changelogs.

  • Functional and test harness executions passing.
  • No additional testing required.

APPROVED

@filipelautert filipelautert merged commit eb361cb into master Mar 17, 2023
@filipelautert filipelautert deleted the normalizePath-performance branch March 17, 2023 18:18
@filipelautert filipelautert added this to the 4.21.0 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants