-
Notifications
You must be signed in to change notification settings - Fork 267
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
Add a simple cache for ComparableVersions #870
Add a simple cache for ComparableVersions #870
Conversation
versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java
Outdated
Show resolved
Hide resolved
This can improve performance in pathetic corner cases by up to 50%.
I was looking into moving this to Maven level. However: Neither ComparableVersion nor DefaultArtifactVersion are immutable: parseVersion will mutate their state. If this is the case, they mustn't be cached. In the plugin, we must therefore forbid ComparableVersion users from ever using parseVersion() on the instance retrieved from cache. |
@ajarmoniuk Oh right, |
@TobiX well, that's indeed unfortunate. I wanted to promote your cache to maven-core, but looked into it closer and discovered that it's in fact mutable (because of that method). The interface is a bit... botched and it would be really nice to change it, but - Maven is big and who knows who depends on it. What's more -- I saw that we could actually cache DefaultArtifactVersion instances, since they are also immutable except for that unfortunate method, which is also part of the interface. And we're actually constructing a lot more of those objects, and use them for comparison. So, instead, I've introuced this change: #898 we're caching DefaultArtifactVersions instead and only in the plugin -- on condition that we will never call |
### What changes were proposed in this pull request? This pr aims upgrade `versions-maven-plugin` to 2.14.2 ### Why are the changes needed? New version bring some improvement like [Add a simple cache for ComparableVersions ](mojohaus/versions#870) The full release notes as follows: - https://github.com/mojohaus/versions/releases/tag/2.14.2 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - GA `Dependencies test` should work normally - Manually check `./dev/test-dependencies.sh --replace-manifest`, run successful Closes #39784 from LuciferYang/SPARK-42226. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
This is a simple fix for #869.
This can improve performance in pathetic corner cases by up to 50%. From some example executions (something similar as the pathetic case in #869):
Before:
After:
In this first implementation, the cache is unbounded. In all my tests it never grew over ~1500 entries, but it might keep some memory active in pathetic cases...
PS: I used a ConcurrentHashMap, because I don't know how parallel (if at all?) Maven can run this code...