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 2022/06/01 22:04:17 UTC

[GitHub] [beam] TheNeuralBit commented on a diff in pull request #17771: [BEAM-14408] Add basic byte size estimation for batches

TheNeuralBit commented on code in PR #17771:
URL: https://github.com/apache/beam/pull/17771#discussion_r887338327


##########
sdks/python/apache_beam/runners/worker/opcounters.py:
##########
@@ -219,9 +219,14 @@ def update_from_batch(self, windowed_batch):
     assert self.producer_batch_converter is not None
     assert isinstance(windowed_batch, windowed_value.HomogeneousWindowedBatch)
 
-    self.element_counter.update(
-        self.producer_batch_converter.get_length(windowed_batch.values))
-    # TODO(BEAM-14408): Update byte size estimate
+    batch_length = self.producer_batch_converter.get_length(
+        windowed_batch.values)
+    self.element_counter.update(batch_length)
+
+    mean_element_size = self.producer_batch_converter.estimate_byte_size(
+        windowed_batch.values) / batch_length
+    for _ in range(batch_length):
+      self.mean_byte_counter.update(mean_element_size)

Review Comment:
   Added `Counter.update_n` to address this.



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