Skip to content

[refactoring] running Spring Boot 3 open-rewrite migration recipes takes very long #863

Closed

Description

@martinlippert

Using the standard petclinic example and running the "upgrade to Spring Boot 3" recipe takes very very long. We need to improve this. A few thoughts here:

  • maybe not use a modal dialog? (this feels very old school and you cannot do anything anymore in between, but not sure about the consequences)
  • does open-rewrite resolve the maven project from scratch again? If so, can we skip that step somehow and tell open-rewrite that we have the resolved classpath of the project already to speed things up?

Activity

  1. added
    for: eclipse
    for: vscode
    on Nov 4, 2022
  2. added this to the 4.17.0.RELEASE milestone on Nov 4, 2022
  3. martinlippert commented on Nov 4, 2022

    @martinlippert
    MemberAuthor

    In case we can't speed things up, we should at least have a meaningful progress message that tells the user what is going on that the moment behind the scenes and which step exactly takes a long time at the moment (parsing, downloading dependencies, whatever)

  4. BoykoAlex commented on Nov 4, 2022

    @BoykoAlex
    Contributor

    I pass list of JARs to the Maven Project parser but still calculates dependencies without downloading them. I'll double-check if there is anything i can do to speed this up.
    The progress used to state which stage it was on (still does in VSCode). I have switched to lsp4e handling of progress messages and now the stage progress messages are gone. I can look into reanimating specific stage messages.

  5. martinlippert commented on Nov 4, 2022

    @martinlippert
    MemberAuthor

    This is probably not the highest priority at the moment, but we should take a look into this to find out what is causing the performance issue.

    It felt to me like the first time I executed this recipe it was super slow, but the performance improved over time - for whatever reason. Let's investigate why this was slow (I can take a look into this and play around with it a bit) - nothing you need to tackle immediately I would say.

  6. BoykoAlex commented on Nov 30, 2022

    @BoykoAlex
    Contributor

    Rewrite downloads dependencies POM's (probably metadata as well). This seem to take time. The POM's (and other files) are in the local maven repo - we need to find a way to take advantage of this fact.

  7. martinlippert commented on Dec 2, 2022

    @martinlippert
    MemberAuthor

    Something to further investigate in the 4.17.1 release cycle.

  8. BoykoAlex commented on Feb 2, 2023

    @BoykoAlex
    Contributor

    I have investigated this and the reason for the first upgrade being slow and consecutive fast is the MavenPomCache maintained by OR in memory at runtime. There are primarily two kinds of data that the cache keeps and fetching these kinds of data appears to be time consuming:

    1. Artifacts POMs
    2. Artifacts maven metadata (contains available versions per maven repo)

    Both of these cases are covered quite well by OR:

    1. I have verified that artifact's POMs are fetched from the local maven repo if pom file exists.
    2. Doesn't make sense to keep available versions metadata locally as versions change and local metadata needs to be removed at some point. Jiust impossible to manage.

    There is RocksdbMavenPomCache available in OR code that would speed up 1. I'm yet to verify how much that helps but provided that the db files don't take a lot of space it could be an option.

    Now, spring-petclinic, surprisingly, is rather far from the regular boot project upgrade scenario. It has two extra remote repositories defined in the pom: Spring Milestones and Spring Snapshots. Maven recipes often try to see available versions for artifacts, especially for the Boot 3 upgrade. This results in a lot of HTTP traffic to fetch maven metadata for artifacts, for each artifact from each remote repository. Therefore the first time is slow but then the second time obviously data is cached for each repo and things are lightning fast.

    Metadata download issue can only be addressed by reducing number of requests to download metadata which falls down to individual maven recipes to take better care not to ask for available versions without the need. I have little faith in this task :-\

  9. BoykoAlex commented on Feb 2, 2023

    @BoykoAlex
    Contributor

    Tried RocksDB in branch rocksdb. I did not see any advantage over InMemoryMavenPomCache with spring-petclinic under test.

    • Cold case with DB being filled: 8-9s closer to 9
    • Cold case with DB already filled: 8s
    • Pom cache warm 3.4s

    The numbers for InMemoryMavenPomCache:

    • Cold case: 8s
    • Warm case: 3.4s

    If extra remote repos removed from the petclinic pom migration takes 6s in the cold case.

    I'd say we should continue with InMemoryMavenPomCache and leave stuff as is as this is the fastest it gets it seems. Unless I messed something up with the way i used RocksdbMavenPomCache...

  10. martinlippert commented on Mar 7, 2023

    @martinlippert
    MemberAuthor

    This performs a lot faster compared to the time when I filed this issue, so I think we can close this item and mark it as fixed for now. If there are further optimizations coming up, they can be captured in separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsefor: vscodetheme: performancetheme: refactoringtype: enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions