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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to