You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/08/05 20:11:45 UTC

[GitHub] [beam] robertwb commented on a change in pull request #15271: Decreasing peak memory usage for `beam.TupleCombineFn`.

robertwb commented on a change in pull request #15271:
URL: https://github.com/apache/beam/pull/15271#discussion_r683755346



##########
File path: sdks/python/apache_beam/transforms/combiners.py
##########
@@ -616,10 +621,23 @@ def create_accumulator(self, *args, **kwargs):
     return [c.create_accumulator(*args, **kwargs) for c in self._combiners]
 
   def merge_accumulators(self, accumulators, *args, **kwargs):
-    return [
-        c.merge_accumulators(a, *args, **kwargs) for c,
-        a in zip(self._combiners, zip(*accumulators))
-    ]
+    # Make sure that `accumulators` is an iterator (so that the position is
+    # remembered).
+    accumulators = iter(accumulators)
+    result = next(accumulators)
+    while True:
+      # Load accumulators into memory and merge in batches to decrease peak
+      # memory usage.
+      accumulators_batch = list(

Review comment:
       Just a thought, should the size of this list be a function of the number of accumulators as well? 




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org