LakshSingla opened a new pull request #12001: URL: https://github.com/apache/druid/pull/12001
### Description `DruidSchema` consists of a concurrent HashMap of `DataSource` -> `Segement` -> `AvailableSegmentMetadata`. `AvailableSegmentMetadata` contains `RowSignature` of the segment, and for each segment, a new object is getting created. RowSignature is an immutable class, and hence it can be interned, and this can lead to huge savings of memory being used in broker, since a lot of the segments of a table would potentially have same RowSignature. Following are some heap dumps of the broker attached for some experiments. The data being ingested is the quickstart `wikipedia` data, but the secondary partition is dynamic with 1 max row per segment, to generate a lot of segments which the `DruidSchema` would have to cache. Also, the configuration used is `start-single-server-small`. For the normal testing `apache-druid-0.22.0` was used while the patch was tested on top of the `master` branch (shouldn't cause much difference). 1. No additional columns were appended to the existing columns of the wiki data. #### Non Interned   #### Interned   2. 51 addititonal columns were appended to the original columns with names "random-#" to increase the memory footprint of the RowSignature. #### Non Interned   #### Interned   This change precomputes the hash of the RowSignature, since its an immutable object, as well as uses an interner in the DruidSchema to generate the AvailableSegmentMetadata objects. Benchmark was added to see the effect of interning on the time required to create the DruidSchema object. It can be removed in the end, if not required. <hr> ##### Key changed/added classes in this PR * `DruidSchema` - Intern the RowSignature * `RowSignature` - Precompute the hash function <hr> <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. --> This PR has: - [x] 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. - [x] 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) - [x] 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. - [x] 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]
