Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Replace strings with byte slices for filters #23

Merged
merged 3 commits into from
Mar 28, 2017

Conversation

robskillington
Copy link
Contributor

@robskillington robskillington commented Mar 23, 2017

This change makes all APIs that interact with metric IDs and tags from string arguments to byte slices. This helps us use a lower common denominator for components that don't need any string representation of IDs but still need filtering capabilities. We've seen in benchmarks this drastically reduces overhead in our more high throughput components.

cc @xichen2020 @martin-mao @kobolog @kobolog

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.724% when pulling 803b9e3 on r/replace-strings-with-byte-slices into a343d25 on master.

@robskillington
Copy link
Contributor Author

Note: still need to account for utf8 rune size in the slicing inside some of the filters.

rules/rule.go Outdated
@@ -330,52 +346,35 @@ func (rs *ruleSet) rollupResults(id string) []RollupResult {
}

type matchedValue struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are doing N^2 passes below, this struct is no longer needed.

}
// toRollupResults encodes rollup target name and values into ids for each rollup target
func (rs *ruleSet) toRollupResults(id []byte, targets []RollupTarget) []RollupResult {
// NB(r): This is n^2 however this should be quite fast still as
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we replacing one-pass scan with n-pass scans? Is it to save the memory allocation for the map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mainly because using bytes makes this need to use a map of hashed IDs which seems more expensive overall in terms of creation and computation than simply just n^2 on a small set of matched rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, fair enough, if the number of rollup rules gets out of hand we can revisit

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 88.66% when pulling 5a8262c on r/replace-strings-with-byte-slices into a343d25 on master.

Copy link
Contributor

@xichen2020 xichen2020 left a comment

Choose a reason for hiding this comment

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

LGTM

@robskillington
Copy link
Contributor Author

Opened issue #24 to tackle UTF8 in future.

@robskillington robskillington merged commit 5046342 into master Mar 28, 2017
@robskillington robskillington deleted the r/replace-strings-with-byte-slices branch March 28, 2017 14:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants