lukecwik commented on code in PR #25354: URL: https://github.com/apache/beam/pull/25354#discussion_r1102053721
########## sdks/java/harness/src/main/java/org/apache/beam/fn/harness/debug/DataSamplingDescriptorModifier.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.debug; + +import org.apache.beam.fn.harness.ProcessBundleDescriptorModifier; +import org.apache.beam.model.fnexecution.v1.BeamFnApi; +import org.apache.beam.model.pipeline.v1.RunnerApi; + +/** + * Modifies the given ProcessBundleDescriptor by adding a DataSampling operation as a consumer to + * every PCollection. + */ +public class DataSamplingDescriptorModifier implements ProcessBundleDescriptorModifier { Review Comment: I was thinking that you would update `PCollectionConsumerRegistry#MetricTrackingFnDataReceiver` and `PCollectionConsumerRegistry#MultiplexingMetricTrackingFnDataReceiver` and add an `if(sampling) { doSampling }` to them. The `if` should be really cheap since the value should always be false or true so the JVMs ability to predict the branch should be very high. Alternatively you could also create a sub-class of the three receivers there to add sampling as necessary. You can validate the `if` approach by running the JMH benchmark: ``` ./gradlew -info :sdks:java:harness:jmh:jmh -Pbenchmark=ProcessBundleBenchmark.testLargeBundle ``` -- 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]
