mrhhsg opened a new pull request, #71387:
URL: https://github.com/apache/doris/pull/71387
### What problem does this PR solve?
Issue Number: None
Related PR: #69284
Cherry-picked from #69284 to `branch-4.1`.
Problem Summary:
TDigest eagerly reserves centroid buffers proportional to compression when
constructed. Aggregations retain one digest per group, so many small groups
reserve substantially more memory than their data requires.
- Allocate processed and unprocessed centroid buffers on demand instead of
preallocating them in the constructor.
- Remove exact-size reservations in `mergeUnprocessed()` so repeated small
merges can use amortized vector growth rather than repeatedly copying the full
buffer.
- Preserve compression thresholds, quantile calculations, and the serialized
format.
Backport adaptations:
Resolve the constructor and window-test context conflicts using the existing
`branch-4.1` implementation. Keep its camelCase APIs, map the added threshold
assertions to `maxProcessed()` and `maxUnprocessed()`, and update the
retained-window buffer assertion so it no longer requires eager allocation. No
unrelated master refactoring is included.
### Release note
Reduce eager TDigest buffer allocations for approximate percentile and
quantile aggregations with many small groups.
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test
Local validation:
- ASAN BE unit-test build succeeded; all **32 tests from 4 test suites
passed**.
```bash
./run-be-ut.sh --run
--filter='TDigestTest.*:QuantileStateTest.*:AggregateFunctionQuantileStateTest.*:*AggregateFunctionQuantileStateRangeTest.*'
-j 48
```
- Targeted clang-format 16 check, repository format check, and
committed-diff whitespace check passed.
```bash
clang-format --dry-run --Werror be/src/util/tdigest.h
be/test/exprs/aggregate/agg_percentile_test.cpp be/test/util/tdigest_test.cpp
bash build-support/check-format.sh
```
- The complete backport diff was checked against #69284, accounting for the
branch-specific accessor names.
- SQL regression tests were not run.
- Behavior changed:
- [ ] No.
- [x] Yes. Centroid buffer allocation is deferred; compression
thresholds and quantile results are unchanged.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]