[ 
https://issues.apache.org/jira/browse/MBUILDCACHE-25?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Ashitkin updated MBUILDCACHE-25:
------------------------------------------
    Description: 
In forked executions present in build, project goes through full lifecycle 
multiple times - one time for project itself + 1 time for each forked execution 
(could be 5, 10 - depends on configuration):

* checksum will be calculated multiple times
* artifacts uploaded multiple times
The issue is manifested by multiple cache calculation log records for the same 
project:
{noformat}
LOGGER.info( "Going to calculate checksum for project [groupId=" + 
project.getGroupId()
        + ", artifactId=" + project.getArtifactId() + "]" );{noformat}
The issue initially observed with PMD and Spotbugs plugins
h3. Impact

No functional impact observed, just unnecessary performance penalty on cache
h3. Cause 

For every forked execution MojoExecutor clones project per forked execution. 
Each forked project goes through full cache lifecycle:
{code:java}
// public List<MavenProject> executeForkedExecutions( MojoExecution 
mojoExecution, MavenSession session,
                                                   ProjectIndex projectIndex )
    throws LifecycleExecutionException
{
...
    Map<String, List<MojoExecution>> forkedExecutions = 
mojoExecution.getForkedExecutions();

    if ( !forkedExecutions.isEmpty() )
    {
        ...
        try
        {
            for ( Map.Entry<String, List<MojoExecution>> fork : 
forkedExecutions.entrySet() )
            {

                MavenProject executedProject = forkedProject.clone();

                forkedProject.setExecutionProject( executedProject );

                List<MojoExecution> mojoExecutions = fork.getValue();
                ...
                try
                {
                    ...
                    // here cloned project enters cache as a standalone project
                    execute( session, mojoExecutions, projectIndex );{code}
Additional notes: the cloning doesn't affect effective pome, so checksum is 
stable and the same in all calculations

Proposed solution: reuse calculated inputs from cache

 

  was:
In forked executions present in build, project checksum will be calculated 
multiple times, one time for project itself + 1 time for each forked execution 
(could be 5, 10 - any times)
The issue is manifested by multiple cache calculation log records for the same 
project:
{noformat}
LOGGER.info( "Going to calculate checksum for project [groupId=" + 
project.getGroupId()
        + ", artifactId=" + project.getArtifactId() + "]" );{noformat}
The issue initially observed with PMD and Spotbugs plugins
h3. Impact

No functional impact observed, just performance penalty on cache in case of 
initial calculation
h3. Cause 

For every forked execution MojoExecutor clones project per forked execution. 
Each forked project goes through full cache lifecycle:
{code:java}
// public List<MavenProject> executeForkedExecutions( MojoExecution 
mojoExecution, MavenSession session,
                                                   ProjectIndex projectIndex )
    throws LifecycleExecutionException
{
...
    Map<String, List<MojoExecution>> forkedExecutions = 
mojoExecution.getForkedExecutions();

    if ( !forkedExecutions.isEmpty() )
    {
        ...
        try
        {
            for ( Map.Entry<String, List<MojoExecution>> fork : 
forkedExecutions.entrySet() )
            {

                MavenProject executedProject = forkedProject.clone();

                forkedProject.setExecutionProject( executedProject );

                List<MojoExecution> mojoExecutions = fork.getValue();
                ...
                try
                {
                    ...
                    // here cloned project enters cache as a standalone project
                    execute( session, mojoExecutions, projectIndex );{code}
Additional notes: the cloning doesn't affect effective pome, so checksum is 
stable and the same in all calculations

Proposed solution: reuse calculated inputs from cache

 


> Project processed multiple time in presence of forked executions
> ----------------------------------------------------------------
>
>                 Key: MBUILDCACHE-25
>                 URL: https://issues.apache.org/jira/browse/MBUILDCACHE-25
>             Project: Maven Build Cache Extension
>          Issue Type: Bug
>            Reporter: Alexander Ashitkin
>            Priority: Minor
>
> In forked executions present in build, project goes through full lifecycle 
> multiple times - one time for project itself + 1 time for each forked 
> execution (could be 5, 10 - depends on configuration):
> * checksum will be calculated multiple times
> * artifacts uploaded multiple times
> The issue is manifested by multiple cache calculation log records for the 
> same project:
> {noformat}
> LOGGER.info( "Going to calculate checksum for project [groupId=" + 
> project.getGroupId()
>         + ", artifactId=" + project.getArtifactId() + "]" );{noformat}
> The issue initially observed with PMD and Spotbugs plugins
> h3. Impact
> No functional impact observed, just unnecessary performance penalty on cache
> h3. Cause 
> For every forked execution MojoExecutor clones project per forked execution. 
> Each forked project goes through full cache lifecycle:
> {code:java}
> // public List<MavenProject> executeForkedExecutions( MojoExecution 
> mojoExecution, MavenSession session,
>                                                    ProjectIndex projectIndex )
>     throws LifecycleExecutionException
> {
> ...
>     Map<String, List<MojoExecution>> forkedExecutions = 
> mojoExecution.getForkedExecutions();
>     if ( !forkedExecutions.isEmpty() )
>     {
>         ...
>         try
>         {
>             for ( Map.Entry<String, List<MojoExecution>> fork : 
> forkedExecutions.entrySet() )
>             {
>                 MavenProject executedProject = forkedProject.clone();
>                 forkedProject.setExecutionProject( executedProject );
>                 List<MojoExecution> mojoExecutions = fork.getValue();
>                 ...
>                 try
>                 {
>                     ...
>                     // here cloned project enters cache as a standalone 
> project
>                     execute( session, mojoExecutions, projectIndex );{code}
> Additional notes: the cloning doesn't affect effective pome, so checksum is 
> stable and the same in all calculations
> Proposed solution: reuse calculated inputs from cache
>  



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

Reply via email to