You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andrzej Jarmoniuk (Jira)" <ji...@apache.org> on 2023/01/03 19:56:00 UTC

[jira] [Comment Edited] (MNG-7659) ComparableVersion cache

    [ https://issues.apache.org/jira/browse/MNG-7659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17653824#comment-17653824 ] 

Andrzej Jarmoniuk edited comment on MNG-7659 at 1/3/23 7:55 PM:
----------------------------------------------------------------

I think it should be safe on condition that the cached objects are immutable. 

-ComparableVersion is effectively immutable (not stated in the contract, but has no mutating API). And the cache is basically the lookup table between the constructor argument and its value.-

Neither ComparableVersion nor DefaultArtifactVersion are immutable: {{parseVersion}} will mutate their state. If this is the case, they mustn't be cached.

Unless the API is changed, but I doubt that is likely.

[~sjaranowski] what do you think?


was (Author: ajarmoniuk):
I think it should be safe on condition that the cached objects are immutable. 

~~ComparableVersion is effectively immutable (not stated in the contract, but has no mutating API). And the cache is basically the lookup table between the constructor argument and its value.~~ 

Neither ComparableVersion nor DefaultArtifactVersion are immutable: {{parseVersion}} will mutate their state. If this is the case, they mustn't be cached.

Unless the API is changed, but I doubt that is likely.

[~sjaranowski] what do you think?

> ComparableVersion cache
> -----------------------
>
>                 Key: MNG-7659
>                 URL: https://issues.apache.org/jira/browse/MNG-7659
>             Project: Maven
>          Issue Type: Improvement
>    Affects Versions: 3.8.7
>            Reporter: Andrzej Jarmoniuk
>            Priority: Minor
>
> Tobias Gruetzmacher has raised an issue with Versions Maven Plugin - [Performance issue with many versions/artifacts #869|https://github.com/mojohaus/versions/issues/869], where he points out that we're creating lots of ComparableVersion objects (which happens especially during ArtifactVersion comparison), which affects performance. He proposed creating a simple cache for these objects.
> This proved to increase performance in some Versions Maven Plugin jobs almost twofold.
> What do you guys think of introducing this to Maven? 
> The cache should probably be restricted in size (e.g. use LRUMap from commons collections), so that it won't leak memory when used with mvnd.
> Simple implementation is here: https://github.com/mojohaus/versions/pull/870
> Using LRUMap: https://github.com/mojohaus/versions/pull/893
> The cache could alternatively be owned by DefaultArtifactVersion, where the construction of ComparableVersion is taking place. 
> I'm querying for opinions on this; if this gains approval, I could implement it. Ultimately I'd like to get rid of the ComparableVersion duplicate in Versions Maven Plugin.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)