scwhittle commented on code in PR #33755:
URL: https://github.com/apache/beam/pull/33755#discussion_r1928466854


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/WorkIdWithShardingKey.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.streaming;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+abstract class WorkIdWithShardingKey {
+
+  public static WorkIdWithShardingKey.Builder builder() {
+    return new AutoValue_WorkIdWithShardingKey.Builder();
+  }
+
+  public abstract long shardingKey();
+
+  public abstract long cacheToken();

Review Comment:
   should this contain a WorkId instead of cacheToken and workToken? would 
prevent possible fields missing added to one and not other.



##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/ActiveWorkState.java:
##########
@@ -124,11 +144,18 @@ private static String elapsedString(Instant start, 
Instant end) {
    */
   synchronized ActivateWorkResult activateWorkForKey(ExecutableWork 
executableWork) {
     ShardedKey shardedKey = executableWork.work().getShardedKey();
+    WorkIdWithShardingKey workIdWithShardingKey =

Review Comment:
   could build this outside synchronized block



##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/ActiveWorkState.java:
##########
@@ -69,6 +68,9 @@ public final class ActiveWorkState {
   @GuardedBy("this")
   private final Map<ShardedKey, Deque<ExecutableWork>> activeWork;

Review Comment:
   Seems like we could have a single data structure:
   Map<Long /*sharding key*/, LinkedHashMap<WorkId, ExecutableWork>>
   
   That means we don't parallelism sharding key collisions but we also don't 
expect those (and if it does happen the serialization isn't that big a deal) 
and it seems like it would make the map operations cheaper to just use the 
sharding key.
   
   The LinkedHashMap could be used as a Deque since it has insertion ordering 
and could be used for lookup for failing.



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