You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Slawomir Jaranowski (Jira)" <ji...@apache.org> on 2022/05/27 19:28:00 UTC

[jira] [Commented] (MENFORCER-420) Reuse getDependenciesToCheck results across rules

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

Slawomir Jaranowski commented on MENFORCER-420:
-----------------------------------------------

I afraid that we have one instance of plexus container during whole Maven session. 
When we store items in plexus context they will be available for all plugin execution in all Maven projects.

For huge project with many modules and many dependencies usage of memory may increment.

As I understand you want to cache multiple execution of rule {{bannedDependencies}} during one plugin execution.

For such purpose I propose to add  a method to {{EnforcerRuleHelper}} - we have one instance of {{EnforcerRuleHelper}} during executing all rules by one plugin execution.
After plugin finish {{EnforcerRuleHelper}} instance will be dropped from memory.

We can add method like: 

{code}
<T> T EnforcerRuleHelper.getCache( String key, Supplier<T> producer );
{code}




> Reuse getDependenciesToCheck results across rules
> -------------------------------------------------
>
>                 Key: MENFORCER-420
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-420
>             Project: Maven Enforcer Plugin
>          Issue Type: Improvement
>          Components: Standard Rules
>            Reporter: Joseph Walton
>            Priority: Minor
>
> We have a build with a significant number of dependencies, and also a large number of {{<bannedDependencies/>}} rules. Together, they lead to a build where Enforcer takes tens of minutes.
> Looking into bottlenecks, we found that {{AbstractBanDependencies#getDependenciesToCheck}} was taking a significant proportion of the build time (tens of percent). This method is called once per rule, so it's recalculating the dependencies for every rule across every execution.
> Introducing a cache, to reuse the dependencies one they'd been calculated for a module, dropped the time spent in banned dependency enforcement by about 75%, which was reflected as a 60% improvement in the time of that build.
> Our local implementation used the {{org.codehaus.plexus.context.Context}} to store the dependencies keyed by the concatenation of {{MavenProject#getId}} and {{searchTransitive}}; there may be a more appropriate scope to avoid edge cases with complex configurations.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)