You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[refactoring] running Spring Boot 3 open-rewrite migration recipes takes very long #863
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?
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)
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.
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.
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.
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:
Artifacts POMs
Artifacts maven metadata (contains available versions per maven repo)
Both of these cases are covered quite well by OR:
I have verified that artifact's POMs are fetched from the local maven repo if pom file exists.
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 :-\
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...
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.
Activity
martinlippert commentedon Nov 4, 2022
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)
BoykoAlex commentedon Nov 4, 2022
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.
martinlippert commentedon Nov 4, 2022
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.
BoykoAlex commentedon Nov 30, 2022
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.
martinlippert commentedon Dec 2, 2022
Something to further investigate in the 4.17.1 release cycle.
BoykoAlex commentedon Feb 2, 2023
I have investigated this and the reason for the first upgrade being slow and consecutive fast is the
MavenPomCachemaintained 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:Both of these cases are covered quite well by OR:
There is
RocksdbMavenPomCacheavailable 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 :-\
BoykoAlex commentedon Feb 2, 2023
Tried RocksDB in branch rocksdb. I did not see any advantage over
InMemoryMavenPomCachewith spring-petclinic under test.The numbers for
InMemoryMavenPomCache:If extra remote repos removed from the petclinic pom migration takes 6s in the cold case.
I'd say we should continue with
InMemoryMavenPomCacheand leave stuff as is as this is the fastest it gets it seems. Unless I messed something up with the way i usedRocksdbMavenPomCache...martinlippert commentedon Mar 7, 2023
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.