robertwb commented on a change in pull request #11205: [BEAM-9578] Enumerating artifacts is too expensive in Java URL: https://github.com/apache/beam/pull/11205#discussion_r403405278
########## File path: runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/Environments.java ########## @@ -214,24 +220,90 @@ public static Environment createProcessEnvironment( pathsToStage.addAll(stagingFiles); } - ImmutableList.Builder<ArtifactInformation> filesToStage = ImmutableList.builder(); + ImmutableList.Builder<Supplier<ArtifactInformation>> lazyArtifactsBuilder = + ImmutableList.builder(); for (String path : pathsToStage) { Review comment: Don't we want this for loop to be lazy? Rather than introducing intermediate streams of Suppliers, I think we could just rename the existing `getArtifacts()` something like `getNonDeferredArtifacts()` and then call it during resolution. ``` if (key.equals(deferredArtifactPayload.getKey())) { return getNonDeferredArtifacts(options); } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services