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

Reduce map allocations when computing the TagSets of a measurement #7470

Merged
merged 1 commit into from
Oct 17, 2016

Conversation

jsternberg
Copy link
Contributor

Instead of assigning a boolean value of true to the filter expressions
when there was no meaningful expression, this drops a boolean expression
of true from the filter expressions so we don't have to perform a map
assignment. This allows us to reduce allocations and assignments when a
WHERE clause only contains tag comparisons and no field comparisons.

@jwilder
Copy link
Contributor

jwilder commented Oct 17, 2016

@benbjohnson can you take a look?

Copy link
Contributor

@benbjohnson benbjohnson left a comment

Choose a reason for hiding this comment

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

The code lgtm although I think getting rid of i/j would help prevent subtle bugs in the future.

}
}
return ids, filters
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify this and remove i/j by using the first element of lids and rids and reslicing.

e.g.

for len(lids) > 0 && len(rids) > 0 {
    lid, rid := lids[0], rids[0]
    if lid == rid {
        // ...compare

        lids, rids = lids[1:], rids[1:]
    } else if lid < rid {
        lids = lids[1:]
    } else {
        rids = rids[1:]
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jsternberg jsternberg force-pushed the js-reduce-map-operations-in-tag-sets branch from 607b7a8 to 78ff932 Compare October 17, 2016 16:41
@jsternberg jsternberg force-pushed the js-reduce-map-operations-in-tag-sets branch from 78ff932 to d29fc65 Compare October 17, 2016 17:07
Instead of assigning a boolean value of true to the filter expressions
when there was no meaningful expression, this drops a boolean expression
of true from the filter expressions so we don't have to perform a map
assignment. This allows us to reduce allocations and assignments when a
`WHERE` clause only contains tag comparisons and no field comparisons.
@jsternberg jsternberg force-pushed the js-reduce-map-operations-in-tag-sets branch from d29fc65 to 41e4e73 Compare October 17, 2016 17:13
@jsternberg jsternberg merged commit 19b1a66 into master Oct 17, 2016
@jsternberg jsternberg deleted the js-reduce-map-operations-in-tag-sets branch October 17, 2016 17:26
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.

3 participants