kfaraz opened a new pull request #12073:
URL: https://github.com/apache/druid/pull/12073
Fixes #12022
### Description
The existing implementation in `OnHeapIncrementalIndex` tends to
over-estimate memory usage
thus leading to more persistence cycles than necessary during ingestion. A
more accurate estimation
of mem usage would also free it up for other purposes.
The current estimation essentially involves getting the max row size for
aggregator and multiplying it by the number of rows to get the total estimated
size. This PR replaces the max multiplication mechanism with getting the actual
incremental memory used by an aggregator at each row/invocation of aggregate.
<hr>
### Changes
- Add method `AggregatorFactory.factorizeWithSize()` that returns a
`SizedAggregator`
- `SizedAggregator` contains the aggregator instance and a long
representing the initial memory in bytes used by the aggregator.
- Add method `Aggregator.aggregateWithSize()` which returns a long
representing the incremental memory used by the aggregator in that invocation.
The default impl of `aggregateWithSize()` calls `aggregate()` and returns 0.
- Remove the method `DimensionIndexer.estimateEncodedKeyComponentSize()`
- Update the method `DimensionIndexer.getUnsortedEncodedValueFromSorted()`
to return generic class `EncodedDimensionValue<EncodedType>` which contains:
- `EncodedType value`: e.g. int[] for StringDimIndexer, Long for
LongDimIndexer
- `long incrementalSize`: The delta in size required for the value.
- Update `OnHeapIncrementalIndex` to use the new estimations only if
`estimateMaxMemory` is false.
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
(Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
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]