Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IncrementalIndex performance regression #12048

Conversation

clintropolis
Copy link
Member

@clintropolis clintropolis commented Dec 9, 2021

Description

This PR fixes a performance regression caused by #11853, where adding type information to the RowBasedColumnSelectorFactory of IncrementalIndex was done by using the getColumnCapabilities method the latter had, which built a hashmap of all the capabilities and then translated that into a RowSignature. This turned out to be very dramatically expensive.

To fix this, IncrementalIndex now just implements ColumnInspector so that it can cut out the middle-man and serve as the ColumnInspector for the RowBasedColumnSelectorFactory.

Before:
Screen Shot 2021-12-09 at 2 27 38 PM

After:
Screen Shot 2021-12-09 at 2 27 28 PM

Zoomed into sink.add:
before:
Screen Shot 2021-12-09 at 2 28 40 PM

after:
Screen Shot 2021-12-09 at 2 28 31 PM

Task run times are shorter too:
before:
Screen Shot 2021-12-09 at 2 24 21 PM
after:
Screen Shot 2021-12-09 at 2 27 00 PM


This PR has:

  • been self-reviewed.
  • 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
  • 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 is met.
  • added integration tests.
  • been tested in a test Druid cluster.

* IncrementalIndex is now a ColumnInspector
* fixes performance regression from using map of ColumnCapabilities from IncrementalIndex as a RowSignature
Copy link
Contributor

@cheddar cheddar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (timeAndMetricsColumnCapabilities.containsKey(columnName)) {
return timeAndMetricsColumnCapabilities.get(columnName);
}
if (dimensionDescs.containsKey(columnName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the code in IncrementalIndex, sometimes dimensionDescs is accessed with synchronization. Sometimes it is not. Assuming that it's okay to access it without synchronization, this looks good. Have we verified that we will already be in a synchronized block once we get to this method?

Copy link
Member Author

@clintropolis clintropolis Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, will have a look. timeAndMetricsColumnCapabilities would also have this problem potentially? nevermind, it doesn't change after constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think it should be synchronized anyway because callers would not expect this method to not be threadsafe. it doesn't seem to cause a performance impact afaict:

without:
Screen Shot 2021-12-09 at 3 30 16 PM

with:
Screen Shot 2021-12-09 at 3 30 04 PM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I didn't trust any of the users of dimensionDescs that weren't obviously safe so adjusted a couple of other locations as well before I did the measurement in my previous comment

@clintropolis clintropolis merged commit 244c255 into apache:master Dec 10, 2021
@clintropolis clintropolis deleted the more-chill-incremental-index-column-capabilities branch December 10, 2021 06:04
@abhishekagarwal87 abhishekagarwal87 added this to the 0.23.0 milestone May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants