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

Add concurrent access flag to the PlexusIoProxyResourceCollection #1

Merged

Conversation

plamentotev
Copy link
Member

Plexus Archiver added support for concurrent zip creation that does lead to a regression - adding the content of tar archive to a zip file is no longer possible as the tar archive is not thread safe. There are two bug reports about that: codehaus-plexus/plexus-archiver#10 and MASSEMBLY-789

There are two ways to solve this - either the tar code must be made thread safe or the zip archiver should be able to add some of the entries in non-concurrent way.

Tar archives does not have indexes for entries. And even if they did (one could be build while iterating over the entries) you can't just skip to the location of the entry as usually the tar are archived. You must decompress the tar file (at least until the entry) for every entry. Another possibility is to unpack the tar archive to a temporary location and then build the index while iterating over the entries. This index could be used to access directly the entry of the unpacked tar file.
Both of this solutions require a lot of unnecessary CPU and/or IO usage so I think the end result will be worse performance even with the concurrent zip utilization of all available cores.

I think the better solution is to acknowledge that there are some resource collections that should be accessed in non-concurrent way so the concurrent jar creator (or any other code that works with such collections) access them in single thread manner. The big question is how. With this pull request I'm proposing to add a new method to the PlexusIoProxyResourceCollection interface. What do you think?

I also considered adding new marker interface. But there is heavy usage of proxies for resources and resource collections and I think even if implemented would not result in good and easy to maintain code.

In practice it turns out that the PlexusIoProxyResourceCollection
implementations are accessed by multiple threads but some of them
(for example PlexusIoTarFileResourceCollection part of plexus-archiver)
are not thread-safe.

Add flag that indicates if the PlexusIoTarFileResourceCollection
implementation supports concurrent access or not.
@krosenvold krosenvold merged commit 1239a0c into codehaus-plexus:master Dec 11, 2015
@krosenvold
Copy link
Member

Great stuff, thanks a lot !

@plamentotev plamentotev deleted the concurrent-access-flag branch February 21, 2016 20:14
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.

None yet

2 participants