lukecwik commented on code in PR #25354:
URL: https://github.com/apache/beam/pull/25354#discussion_r1103400750


##########
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:
   This looks much better since the variation in the runs is smaller but 5% is 
still not small.
   
   Hopefully marking the fields final will address that but if not we might 
want to go with the subclass route:
   ```
   SamplingAndMetricTrackingFnDataReceiver extends MetricTrackingFnDataReceiver 
{
   
   public void accept(WindowedValue<T> value) {
     sample(value);
     super.accept(value);
   }
   ```
   
   Or take a look at the profiling information. If you follow the instructions 
here to install cloud profiler locally
   
https://github.com/apache/beam/blob/b64526a3a2429d30535d5cd52d99521878dd3d2c/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy#L1549
   and then authenticate with gcloud you can run (replacing the GCP project 
with one that you have access to) will upload the results to Google Cloud 
Profiler:
   ./gradlew -info :sdks:java:harness:jmh:jmh 
-Pbenchmark=ProcessBundleBenchmark.testLargeBundle -PgcpProject=...



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