You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Hervé Boutemy (JIRA)" <ji...@apache.org> on 2019/05/17 09:11:00 UTC

[jira] [Comment Edited] (COMPRESS-485) Reproducible Builds: keep entries order when gathering ScatterZipOutputStream content in ParallelScatterZipCreator

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

Hervé Boutemy edited comment on COMPRESS-485 at 5/17/19 9:10 AM:
-----------------------------------------------------------------

I didn't change anything in the parallel execution code: it works exactly the same way it worked before =
1. entries are compressed to a temporary file per thread, stored as {{List<ScatterZipOutputStream> streams}}: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L55 (initialized from ThreadLocal code: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L82 )
2. then temporary files are merged into the target full zip file https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L257

I just used the fact that the entries to be compressed were perfectly kept in a list = {{private final List<Future<Object>> futures = new ArrayList<>();}}: see https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L58

de-facto, we have the order in memory, it was just not used when gathering compressed content: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L257

then instead of iterating on {{ScatterZipOutputStream streams}}, I iterate on the list: https://github.com/apache/commons-compress/pull/78/commits/ee88360bb377d3816115dc33e2b999d1902034dc#diff-f65928086a3bd28a1beff1c6e37b7306R261

pretty basic in fact once you understand that the algorithm is split in 2 phases (scatter then gather) and the gather implementation was just written as simply as possible because at the time it was written, order was not an issue: if there is a value in keeping order (and there is), it's just the gathering iteration order that has to be changed, not the parallel scatter compression


was (Author: hboutemy):
I didn't change anything in the parallel execution code: it works exactly the same way it worked before =
1. entries are compressed to a temporary file per thread, stored as {{List<ScatterZipOutputStream> streams}}: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L55 (initialized from ThreadLocal code: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L82 )
2. then temporary files are merged into the target full zip file https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L257

I just used the fact that the entries to be compressed were perfectly kept in a list = {{private final List<Future<Object>> futures = new ArrayList<>();}}: see https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L58

de-facto, we have the order in memory, it was just not used when gathering compressed content: https://github.com/apache/commons-compress/blob/rel/1.18/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java#L257

then instead of iterating on {{ScatterZipOutputStream streams}}, I iterate on the list: https://github.com/apache/commons-compress/pull/78/commits/ee88360bb377d3816115dc33e2b999d1902034dc#diff-f65928086a3bd28a1beff1c6e37b7306R261

> Reproducible Builds: keep entries order when gathering ScatterZipOutputStream content in ParallelScatterZipCreator
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-485
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-485
>             Project: Commons Compress
>          Issue Type: Improvement
>          Components: Archivers
>    Affects Versions: 1.18
>            Reporter: Hervé Boutemy
>            Priority: Major
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> currently, zip files created using ParallelScatterZipCreator have random order.
> This is causing issues when trying to do Reproducible Builds with Maven MNG-6276
> Studying ParallelScatterZipCreator, entries are kept sorted in memory in futures list: instead of writing each full scatter in sequence, iterating over futures should permit to write each zip entry in original order, without changing the API or any performance of the gathering process



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)