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/12/13 17:57:37 UTC

[GitHub] [beam] lukecwik commented on a change in pull request #16207: Memoize some objects for timer processing to reduce overhead.

lukecwik commented on a change in pull request #16207:
URL: https://github.com/apache/beam/pull/16207#discussion_r767974645



##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiTimerBundleTracker.java
##########
@@ -153,6 +153,10 @@ public FnApiTimerBundleTracker(
             });
   }
 
+  public void resetModifications() {

Review comment:
       nit: resetModifications -> reset

##########
File path: runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/SimpleStateRegistry.java
##########
@@ -64,12 +65,13 @@ public void reset() {
     for (SimpleExecutionState state : executionStates) {
       if (state.getTotalMillis() != 0) {
         String shortId = state.getTotalMillisShortId(shortIds);
-        if (result.containsKey(shortId)) {
-          // This can happen due to flatten unzipping.
-          result.put(shortId, state.mergeTotalMillisPayload(result.get(shortId)));
-        } else {
-          result.put(shortId, state.getTotalMillisPayload());
-        }
+        result.compute(shortId, (String k, @Nullable ByteString existing) -> {
+          if (existing != null) {
+            return state.mergeTotalMillisPayload(existing);

Review comment:
       ```suggestion
               // This can happen due to flatten unzipping.
               return state.mergeTotalMillisPayload(existing);
   ```




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