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
Conversation
…istry where the container is known at counter construction. This showed up as 20% of sdk cpu on a nexmark query2 benchmark.
R: @kennknowles |
@kileys also recently did some work in/around the |
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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 :-(
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
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. |
Friendly ping |
CC @amaliujia |
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:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.