You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/08/04 04:13:15 UTC
[GitHub] [incubator-pinot] mayankshriv opened a new pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
mayankshriv opened a new pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798
…sketches and unions.
* In a case with large number of predicates in the post-aggregation-expression (with OR's), we tend
to end up with a lot of empty sketches (and unions) when not every row matches each predicate.
This causes an overhead of creating sketches and union'ing them, leading to potentially huge performance hit.
* In this PR, we improve this behavior by:
- Filtering out empty unions/sketchs when extracting aggregation results.
- Careful merging of results in `merge()` with mininmal unions (only when necessary).
* We could also perform lazy creation of unions (to ensure that they are not empty), but that would mean
a hash-map lookup per row. This will penalize the general case when there's less number of emtpy unions.
So this approach was not taken.
* We saw an overall improvement in latency of about 50%, for cases with:
- Large number of predicates, and
- Large number of segments, and
- Small number of matches per predicate per segment.
## Description
Add a description of your PR here.
A good description should include pointers to an issue or design document, etc.
## Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
* [ ] Yes (Please label as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
Does this PR fix a zero-downtime upgrade introduced earlier?
* [ ] Yes (Please label this as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
Does this PR otherwise need attention when creating release notes? Things to consider:
- New configuration options
- Deprecation of configurations
- Signature changes to public methods/interfaces
- New plugins added or old plugins removed
* [ ] Yes (Please label this PR as **<code>release-notes</code>** and complete the section on Release Notes)
## Release Notes
If you have tagged this as either backward-incompat or release-notes,
you MUST add text here that you would like to see appear in release notes of the
next release.
If you have a series of commits adding or enabling a feature, then
add this section only in final commit that marks the feature completed.
Refer to earlier release notes to see examples of text
## Documentation
If you have introduced a new feature or configuration, please add it to the documentation as well.
See https://docs.pinot.apache.org/developers/developers-and-contributors/update-document
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798#discussion_r465294347
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
##########
@@ -387,12 +386,17 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult
public Map<String, Sketch> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
Map<Predicate, Union> unionMap = aggregationResultHolder.getResult();
if (unionMap == null || unionMap.isEmpty()) {
- return Collections.emptyMap();
+ return null;
Review comment:
Yes, see merge(), there's a null check there. I had added `Collections.emptyMap()` in the previous PR, only to realize that it could be null. You are right it doesn't have to be null, but having it null saves a few cpu cycles in merge, I guess (not that it improves anything).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
siddharthteotia commented on a change in pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798#discussion_r465201499
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
##########
@@ -387,12 +386,17 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult
public Map<String, Sketch> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
Map<Predicate, Union> unionMap = aggregationResultHolder.getResult();
if (unionMap == null || unionMap.isEmpty()) {
- return Collections.emptyMap();
+ return null;
Review comment:
Is the caller already good with null? I mean it doesn't have to be changed to handle null return from this function?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798#discussion_r465294347
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
##########
@@ -387,12 +386,17 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult
public Map<String, Sketch> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
Map<Predicate, Union> unionMap = aggregationResultHolder.getResult();
if (unionMap == null || unionMap.isEmpty()) {
- return Collections.emptyMap();
+ return null;
Review comment:
Yes, see merge(), there's a null check there. I had added `Collections.emptyMap()` in the previous PR, only to realize that it could be null.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798#discussion_r465297357
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
##########
@@ -387,12 +386,17 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult
public Map<String, Sketch> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
Map<Predicate, Union> unionMap = aggregationResultHolder.getResult();
if (unionMap == null || unionMap.isEmpty()) {
- return Collections.emptyMap();
+ return null;
Review comment:
On second thought, perhaps emptyMap() is better to avoid null checks in callers. Updated.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798#discussion_r465294347
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/DistinctCountThetaSketchAggregationFunction.java
##########
@@ -387,12 +386,17 @@ public void aggregateGroupByMV(int length, int[][] groupKeysArray, GroupByResult
public Map<String, Sketch> extractAggregationResult(AggregationResultHolder aggregationResultHolder) {
Map<Predicate, Union> unionMap = aggregationResultHolder.getResult();
if (unionMap == null || unionMap.isEmpty()) {
- return Collections.emptyMap();
+ return null;
Review comment:
Yes, see merge(), there's a null check there. I had added `Collections.emptyMap()` in the previous PR, only to realize that it could be null. You are right it doesn't have to be null, but having it null saves a few cpu cycles in merge, I guess.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [incubator-pinot] mayankshriv merged pull request #5798: Improve performance of DistinctCountThetaSketch by eliminating empty …
Posted by GitBox <gi...@apache.org>.
mayankshriv merged pull request #5798:
URL: https://github.com/apache/incubator-pinot/pull/5798
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org