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 2020/05/27 04:14:44 UTC

[GitHub] [beam] steveniemitz commented on a change in pull request #11823: [BEAM-7568] Avoid re-encoding value state cells each commit

steveniemitz commented on a change in pull request #11823:
URL: https://github.com/apache/beam/pull/11823#discussion_r430837481



##########
File path: runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillStateInternals.java
##########
@@ -410,14 +416,18 @@ protected WorkItemCommitRequest persistDirectly(WindmillStateCache.ForKey cache)
         return WorkItemCommitRequest.newBuilder().buildPartial();
       }
 
-      ByteString.Output stream = ByteString.newOutput();
-      if (value != null) {
-        coder.encode(value, stream, Coder.Context.OUTER);
+      ByteString encoded = null;
+      if (cachedSize == -1 || modified) {

Review comment:
       agreed, it took me awhile to reason this out w/ the different code paths that can affect the values here.  I'm reasonably sure you don't need the `cachedSize == -1` branch but, it's been working like this for ~1 year so I didn't want to tempt fate.
   
   There's also the case where this is the first write, but `valueIsKnown = false` (because `isNewKey = false`), so we end up with a read that doesn't return anything.
   
   Thanks for the quick reviews!




----------------------------------------------------------------
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:
users@infra.apache.org