Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-12127] Remove delegation for counters in PCollectionConsumerRegistry where the unbound container is known at counter construction. #14473

Merged
merged 1 commit into from Apr 12, 2021

Conversation

scwhittle
Copy link
Contributor

This showed up as 20% of sdk cpu on a nexmark query2 benchmark.

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK ULR Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status Build Status --- Build Status ---
Java Build Status Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status --- Build Status Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

…istry where the container is known at counter construction.

This showed up as 20% of sdk cpu on a nexmark query2 benchmark.
@scwhittle
Copy link
Contributor Author

R: @kennknowles

@kennknowles kennknowles self-requested a review April 8, 2021 17:19
@kennknowles
Copy link
Member

@kileys also recently did some work in/around the PCollectionConsumerRegistry and counters.

@kennknowles
Copy link
Member

Just pattern matching the code and topic. I don't know if there is a best owner but I want more eyes than just my own.

Copy link
Member

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change generally looks good to me. Two things that I don't know enough to ascertain:

  • is it really a behavioral noop?
  • what tests would I run to check?

@@ -213,38 +211,39 @@ public MetricTrackingFnDataReceiver(
this.pTransformId = consumerAndMetadata.getPTransformId();
HashMap<String, String> labels = new HashMap<String, String>();
labels.put(Labels.PCOLLECTION, pCollectionId);

// Collect the metric in a metric container which is not bound to the step name.
// This is required to count elements from impulse steps, which will produce elements outside
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the detailed comment, but I still don't actually understand what it means :-(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really either, I just moved it from below.

Maybe we can do better and we can somehow ensure it only happens for impulse steps

@@ -213,38 +211,39 @@ public MetricTrackingFnDataReceiver(
this.pTransformId = consumerAndMetadata.getPTransformId();
HashMap<String, String> labels = new HashMap<String, String>();
labels.put(Labels.PCOLLECTION, pCollectionId);

// Collect the metric in a metric container which is not bound to the step name.
// This is required to count elements from impulse steps, which will produce elements outside
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really either, I just moved it from below.

Maybe we can do better and we can somehow ensure it only happens for impulse steps

this.delegate.accept(input);
}
// Increment the counter for each window the element occurs in.
this.unboundedElementCountCounter.inc(input.getWindows().size());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my reasoning on why this was a no-op:

  • the scoped metric containers stuffs in thread-local and delegating counter pulls it out
  • the scoping is not transitive, only the last scope matters
  • we are now caching the unboundedMetricContainer.getCounter() result instead of recalculating it every accept. However the contaner appears to reset counters but not remove them.

I was hoping existing tests would cover correctness since I'm not familiar with this code.

@kileys can you take a look? Thanks

@kileys
Copy link
Contributor

kileys commented Apr 8, 2021

I'm not super familiar with the metrics container, but I checked that the element count and estimated size still show up in the Dataflow UI.

@scwhittle
Copy link
Contributor Author

Friendly ping

@kennknowles kennknowles merged commit 1d5f887 into apache:master Apr 12, 2021
@kennknowles
Copy link
Member

CC @amaliujia

@scwhittle scwhittle deleted the non_delegating_counter branch May 3, 2021 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants