[ 
https://issues.apache.org/jira/browse/BEAM-6612?focusedWorklogId=196074&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-196074
 ]

ASF GitHub Bot logged work on BEAM-6612:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Feb/19 01:59
            Start Date: 08/Feb/19 01:59
    Worklog Time Spent: 10m 
      Work Description: ajamato commented on pull request #7764: [BEAM-6612] 
Modify QueueingBeamFnDataClient to become MetricsBeamFnDataClient and make all 
processElement() calls occur in parallel again.
URL: https://github.com/apache/beam/pull/7764#discussion_r254934808
 
 

 ##########
 File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/MetricsPCollectionConsumerRegistry.java
 ##########
 @@ -0,0 +1,131 @@
+/*
+ * 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.fn.harness.data;
+
+import java.io.Closeable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.MonitoringInfo;
+import org.apache.beam.runners.core.metrics.ExecutionStateTracker;
+import org.apache.beam.runners.core.metrics.MetricsContainerImpl;
+import org.apache.beam.runners.core.metrics.MetricsContainerStepMapEnvironment;
+import org.apache.beam.runners.core.metrics.SimpleExecutionState;
+import org.apache.beam.runners.core.metrics.SimpleMonitoringInfoBuilder;
+import org.apache.beam.runners.core.metrics.SimpleStateRegistry;
+import org.apache.beam.sdk.fn.data.FnDataReceiver;
+import org.apache.beam.sdk.metrics.MetricsEnvironment;
+import org.apache.beam.sdk.util.WindowedValue;
+
+/**
+ * The {@code MetricsPCollectionConsumerRegistry} is used to maintain a 
collection of consuming
+ * FnDataReceiver for each pCollectionId. Registering with this class allows 
inserting an element
+ * count counter for every pCollection. The consumers are wrapped with extra 
logic to collect user
+ * metrics, execution time metrics and element count metrics.
+ */
+public class MetricsPCollectionConsumerRegistry extends 
PCollectionConsumerRegistry {
+
+  private Map<String, ElementCountFnDataReceiver> 
pCollectionIdsToWrappedConsumer;
+  private SimpleStateRegistry executionStates = new SimpleStateRegistry();
+
+  public MetricsPCollectionConsumerRegistry() {
 
 Review comment:
   I made this class access its ExecutionStateTracker and 
MetricContainerStepMap from the thead local variable injected in 
MetricsBeamFnDataClient. This removed the params from the ctor :), but it now 
relies on the thread local variable.
   
   I also put some of the logic in a base class PCollectionConsumerRegistry, as 
most tests use this class just to setup the consumers properly, and do not need 
metrics. Most of the unit tests use the base PCollectionConsumerRegistryclass, 
eliminating the need to setup the thead local variables in those tests.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 196074)
    Time Spent: 20m  (was: 10m)

> Remove QueueingBeamFnDataClient
> -------------------------------
>
>                 Key: BEAM-6612
>                 URL: https://issues.apache.org/jira/browse/BEAM-6612
>             Project: Beam
>          Issue Type: New Feature
>          Components: java-fn-execution
>            Reporter: Alex Amato
>            Assignee: Alex Amato
>            Priority: Major
>              Labels: triaged
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Remove QueueingBeamFnDataClient, which made process() calls all run on the 
> same thread.
> [~lcwik] and I came up with this design thinking that it was required to 
> process the bundle in parallel anyways, and we would have good performance. 
> However after speaking to Ken, there is no requirement for a bundle or key to 
> be processed in parallel. Elements are either iterables or single elements 
> which defines the needs for processing a group of elements on the same thread.
> Simply performing this change will lead to the following issues:
> (1) MetricsContainerImpl and MetricsContainer are not thread safe, so when 
> the process() functions enter the metric container context, they will be 
> accessing an thread-unsafe collection in parallel
> (2) An ExecutionStateTracker will be needed in every thread, So we will need 
> to
> create an instance and activate it in every GrpC thread which receives a new 
> element.
> (Will this get sampled properly, since the trackers will be short lived).
> (3) The SimpleExecutionStates being used will need to be thread safe as well? 
> I don't think so, because I don't think that the ExecutionStateSampler 
> invokes them in parallel.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to