GroupBy Optimization: Trim on the Fly
Description
Group-by issue: If there are too many groups, then it takes up too much memory and the garbage collection process becomes a major performance bottleneck.
Current Approach: When the number of groups reaches a limit (by default 100k), the key generator stops to add new groups. Produces inaccurate results since we only calculate the first 100k groups
trim on the fly approach: Whenever the number of groups reaches the limit (by default 100k now), trim the results to 5k using OrderBy information. - Pays the overhead of orderBy and trimming, so it’s expensive if the cardinality is relatively low (< 5m), but boost the performance when it’s large - Threshold and trim size are configurable
Detailed benchmark number will be added later
Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
- [ ] Yes (Please label as
backward-incompat, and complete the section below on Release Notes)
Does this PR fix a zero-downtime upgrade introduced earlier?
- [ ] Yes (Please label this as
backward-incompat, 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
release-notesand complete the section on Release Notes)
Release Notes
Documentation
Codecov Report
:exclamation: No coverage uploaded for pull request base (
master@0d96c7f). Click here to learn what that means. The diff coverage is32.22%.
:exclamation: Current head 7d22607 differs from pull request most recent head a17aae5. Consider uploading reports for the commit a17aae5 to get more accurate results
@@ Coverage Diff @@
## master #7219 +/- ##
=========================================
Coverage ? 29.25%
Complexity ? 83
=========================================
Files ? 1495
Lines ? 74034
Branches ? 10730
=========================================
Hits ? 21660
Misses ? 50414
Partials ? 1960
| Flag | Coverage Δ | |
|---|---|---|
| integration2 | 29.25% <32.22%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...e/pinot/common/minion/MergeRollupTaskMetadata.java | 0.00% <0.00%> (ø) |
|
| ...e/pinot/common/minion/MinionTaskMetadataUtils.java | 55.00% <ø> (ø) |
|
| ...ot/common/request/context/RequestContextUtils.java | 74.12% <0.00%> (ø) |
|
| ...inot/common/tier/TimeBasedTierSegmentSelector.java | 0.00% <0.00%> (ø) |
|
| ...n/utils/LikeToRegexpLikePatternConverterUtils.java | 0.00% <0.00%> (ø) |
|
| ...e/pinot/controller/helix/SegmentStatusChecker.java | 57.25% <0.00%> (ø) |
|
| ...e/assignment/segment/OfflineSegmentAssignment.java | 17.32% <0.00%> (ø) |
|
| ...realtime/segment/DefaultFlushThresholdUpdater.java | 83.33% <ø> (ø) |
|
| ...segment/SegmentSizeBasedFlushThresholdUpdater.java | 0.00% <ø> (ø) |
|
| ...core/retention/strategy/TimeRetentionStrategy.java | 10.00% <0.00%> (ø) |
|
| ... and 63 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 0d96c7f...a17aae5. Read the comment docs.
Interesting contribution. Do you think this mode could be enabled using a hint so it won't break backward compatibility?
Right now we have different behavior within segment vs cross segments, which is a kind of confusing:
- Within segment, there is no on-the-fly trim, and we simply ignore groups when it is over the threshold
- Cross segment, we perform on-the-fly trim, and keep trimming the groups when it is over the threshold
- The threshold is different within/cross segment, and is configured with different keys
IMO it is easier to use if we make the behavior consistent: Always trim on-the-fly when the threshold is reached, and trim the inner segment result before doing the cross-segment merge. Essentially make the server side segment merge behavior the same as broker side server result merge.