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

Optimizations for LexicographicTopNs #1603

Merged
merged 1 commit into from
Aug 11, 2015

Conversation

nishantmonu51
Copy link
Member

  1. LexicographicTopNMetricSpec.comparator - Avoid String conversion to bytes if reference is equal
  2. TopNLexicographicResultBuilder - borrow optimizations from topNNumericResultBuilder
    -- change storage structure to PriorityQueue
    -- Only add to pQueue when required
    -- Add Loop unrolling for metrics addition
    -- Re-orders Queue on build() call.
  3. Minor Spelling correction in DimValueHolder

@Override
public int compare(DimValHolder o1, DimValHolder o2)
{
return comparator.compare(o1.getDimName(), o2.getDimName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to account for null here?

Copy link
Contributor

Choose a reason for hiding this comment

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

nvmnd, is done in comparator

@drcrallen
Copy link
Contributor

Squash and I'm 👍

}

private boolean shouldAdd(String dimName)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to avoid copy pasting the code and reuse the code from the other topnresultbuilders?

Copy link
Member Author

Choose a reason for hiding this comment

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

they look similar but differ in actual implementation.

@xvrl xvrl modified the milestone: 0.8.1 Aug 10, 2015
final boolean belowThreshold = pQueue.size() < this.threshold;
final boolean belowMax = belowThreshold
|| this.comparator.compare(pQueue.peek().getTopNMetricVal(), dimName) < 0;
return belowMax && comparator.compare(dimName, previousStop) > 0;
Copy link
Member

Choose a reason for hiding this comment

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

the implementation in TopNNumericResultBuilder doesn't seem to have the added && comparator.compare(dimName, previousStop) > 0. Do you mind adding a comment to explain why it's needed?

final boolean belowMax = belowThreshold
|| this.comparator.compare(pQueue.peek().getTopNMetricVal(), dimName) < 0;
// Only add if dimName is after previousStop
return belowMax && comparator.compare(dimName, previousStop) > 0;
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to optimize the case where previousStop is null and shortcut the comparison altogether? Seems expensive to call comparator.compare every time?

Copy link
Member Author

Choose a reason for hiding this comment

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

added the check.

initial review for perf optimizations for lexicographic TopNs

fix compilation

create map with proper size

review comment

review comment

review comments
xvrl added a commit that referenced this pull request Aug 11, 2015
@xvrl xvrl merged commit fbdb841 into apache:master Aug 11, 2015
@xvrl xvrl deleted the optimize-lexicographic-topN branch August 11, 2015 20:35
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.

None yet

3 participants