Skip to content
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

Support assembling and archiving repositories in parallel #2850

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

HannesWell
Copy link
Member

Assembling and arching repositories is a relatively long running task and repository-projects are usually build as one of the last projects in the reactor. So the chances are relatively high, that (if multiple projects are present) multiple repositories are assembled at the same. Therefore it should be possible to build multiple repositories in parallel and there should not be one global lock for each repository-related mojo.

@HannesWell HannesWell force-pushed the parallelRepos branch 2 times, most recently from ad62fbd to c58f295 Compare September 23, 2023 23:41
@HannesWell HannesWell changed the title Support assembling and archiving repositories concurrently Support assembling and archiving repositories in parallel Sep 23, 2023
@github-actions
Copy link

github-actions bot commented Sep 24, 2023

Test Results

   561 files  ±0     561 suites  ±0   5h 11m 11s ⏱️ +48s
   364 tests ±0     358 ✔️ ±0    6 💤 ±0  0 ±0 
1 092 runs  ±0  1 073 ✔️ ±0  19 💤 ±0  0 ±0 

Results for commit f934b1e. ± Comparison against base commit e154832.

♻️ This comment has been updated with latest results.

import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.tycho.core.maven.AbstractP2Mojo;

public abstract class AbstractRepositoryMojo extends AbstractP2Mojo {
private static final Map<File, Lock> REPOSITORY_LOCK = new ConcurrentHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tycho has a FileLockService can we probably reuse that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into that, but since the FileLockService creates a lock-file in the directory to lock this is not usable in cases where for example a repository is zipped, because then the lock file ends up in the zipped repository.
Furthermore a inter-process file locking does not seem to be necessary because the resources are within the projects being build and the goal is only to prevent illegal concurrent access in the same build-process. One should not run multiple build processes at the same time for the same or even sub-directories any way. So having a file-locking seems to be too much for me and an in-memory locking is sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But with #2853 we could simply add another method like FileLockService.lockForThisProcess or similar that only does an ordinary in-process/memory locking without creating any files.

Copy link
Member

@laeubi laeubi Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into that, but since the FileLockService creates a lock-file in the directory to lock this is not usable in cases where for example a repository is zipped, because then the lock file ends up in the zipped repository.

Have you tested this? The zipping of repository is taking place in a separate step where the lock file should already be deleted (or can be deleted).

One should not run multiple build processes at the same time for the same or even sub-directories any way

I think you are aware of murphy's law ;-)

So having a file-locking seems to be too much for me and an in-memory locking is sufficient.

If we can reuse something that offers even more we should use that instead of inventing another approach that offers weaker guarantees.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you have refactored the lock do you think it could be used here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into that, but since the FileLockService creates a lock-file in the directory to lock this is not usable in cases where for example a repository is zipped, because then the lock file ends up in the zipped repository.

Have you tested this? The zipping of repository is taking place in a separate step where the lock file should already be deleted (or can be deleted).

I haven't tried it yet. But with this zipping the repo would also be guarded with a lock-file, which would create the file before the zipping starts and deletes it only afterwards. And in between the directory content is zipped. Therefore expect that the lock-file will be included. But I'll try it.

One should not run multiple build processes at the same time for the same or even sub-directories any way

I think you are aware of murphy's law ;-)

It could definitively happen, but one should not do it. So its then the users fault. :)

So having a file-locking seems to be too much for me and an in-memory locking is sufficient.

If we can reuse something that offers even more we should use that instead of inventing another approach that offers weaker guarantees.

In generally that's right. But as written above, I'm not yet sure if this is really suitable. If it is not suitable, I would just add the method as something like lockVirtually() to the FileLockerService.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not loose anything using the function as-is ... any complication like "virtual" make it just confusing so if we zip the content it should be easy to exclude the lockfile anyways.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would see the opposite as more complicated since the exclusion then would need to be kept in sync if the lock-file changes one day.
And which file is locked eventually is an implementation detail of the locker and consumer not interested in inter-process locking should not have to care about that.

@HannesWell HannesWell force-pushed the parallelRepos branch 2 times, most recently from 55ed2de to 80a94c1 Compare September 27, 2023 19:58
Assembling and arching repositories is a relatively long running task
and repository-projects are usually build as one of the last projects in
the reactor. So the chances are relatively high, that (if multiple
projects are present) multiple repositories are assembled at the same.
Therefore it should be possible to build multiple repositories in
parallel and there should not be one global lock for each
repository-related mojo.
@laeubi laeubi merged commit 7d1eb64 into eclipse-tycho:master Oct 23, 2023
10 checks passed
@HannesWell HannesWell deleted the parallelRepos branch October 23, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants