jasonk000 opened a new pull request #12109:
URL: https://github.com/apache/druid/pull/12109
### Description
Following from #12105 with 1-20% CPU in `DimensionDictionary`, there are
some improvements to be made to the `add()` path on the
`StringDimensionIndexer`.
There are three sub-changes:
#### Introduce a new benchmark
`StringDimensionIndexerProcessBenchmark` in
cff7a6caaab2d28218ab01655c44d24e99c40e0c covers the `StringDimensionIndexer`
`processRowValsToUnsortedEncodedKeyComponent` for throughput.
#### Optimise `StringDimensionIndexer` -> `DimensionDictionary` boundary
in 400f0a5137264d9c4f0a88dc346b6730458b1b09 introduce an `AddResult` class
to combine the result of both (a) what is the index of the result, and (b) was
the result a new addition or refers to a previous element.
This results in a ~30% improvement on this codepath single threaded, and
~70% by bypassing multiple `size()` calls to determine whether the dictionary
has changed.
#### Switch lock implementation in `DimensionDictionary` to `StampedLock`
In aea89f5c502317b69957fbf592d84e4e9ee3f9a5 introduce improved concurrency
under multiple-reader scenarios, and scenarios where `add()` of existing
elements. Results in 3x improvement in contended situation.
#### Refactor
Slight refactor in 3e5c410047a74b3cae8044070260384803a2e1e5 to simplify flow
in `StringDimensionIndexer`.
<!-- 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.
- [x] 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.
- [x] 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. -> nb: partly, have not tested
`StampedLock` in prod
--
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]