diff --git a/helper/rollup/remote.go b/helper/rollup/remote.go
index 1b39a335..32a92804 100644
--- a/helper/rollup/remote.go
+++ b/helper/rollup/remote.go
@@ -143,7 +143,7 @@ func remoteLoad(addr string, tlsConf *tls.Config, table string) (*Rules, error)
},
nil,
)
- if err != nil {
+ if err != nil && strings.Contains(err.Error(), " Missing columns: 'rule_type' ") {
// for old version
query = `SELECT
regexp,
diff --git a/helper/rollup/remote_test.go b/helper/rollup/remote_test.go
index 50fe8fb5..4e1c0bfb 100644
--- a/helper/rollup/remote_test.go
+++ b/helper/rollup/remote_test.go
@@ -237,7 +237,7 @@ func TestParseJsonTyped(t *testing.T) {
}`
expected := &Rules{
- Splitted: true,
+ Separated: true,
Pattern: []Pattern{
{
Regexp: "^hourly",
diff --git a/helper/rollup/rules.go b/helper/rollup/rules.go
index 40f1005a..887a7508 100644
--- a/helper/rollup/rules.go
+++ b/helper/rollup/rules.go
@@ -144,7 +144,7 @@ type Pattern struct {
type Rules struct {
Pattern []Pattern `json:"pattern"`
Updated int64 `json:"updated"`
- Splitted bool `json:"-"`
+ Separated bool `json:"-"`
PatternPlain []Pattern `json:"-"`
PatternTagged []Pattern `json:"-"`
}
@@ -211,17 +211,17 @@ func (r *Rules) compile() (*Rules, error) {
r.PatternPlain = make([]Pattern, 0)
r.PatternTagged = make([]Pattern, 0)
- r.Splitted = false
+ r.Separated = false
for i := range r.Pattern {
if err := r.Pattern[i].compile(); err != nil {
return r, err
}
- if !r.Splitted && r.Pattern[i].RuleType != RuleAll {
- r.Splitted = true
+ if !r.Separated && r.Pattern[i].RuleType != RuleAll {
+ r.Separated = true
}
}
- if r.Splitted {
+ if r.Separated {
for i := range r.Pattern {
switch r.Pattern[i].RuleType {
case RulePlain:
@@ -275,7 +275,7 @@ func (r *Rules) withSuperDefault() *Rules {
// Lookup returns precision and aggregate function for metric name and age
func (r *Rules) Lookup(metric string, age uint32, verbose bool) (precision uint32, ag *Aggr, aggrPattern, retentionPattern *Pattern) {
- if r.Splitted {
+ if r.Separated {
if strings.Contains(metric, "?") {
return lookup(metric, age, r.PatternTagged, verbose)
}
diff --git a/helper/rollup/rules_test.go b/helper/rollup/rules_test.go
index f96df94b..e3dfdeef 100644
--- a/helper/rollup/rules_test.go
+++ b/helper/rollup/rules_test.go
@@ -383,3 +383,464 @@ func TestRules_RollupPoints(t *testing.T) {
})
}
}
+
+var benchConfig = `
+
+
+ ^hourly
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ ^live
+
+ 0
+ 1
+
+
+
+ \.fake1\..*\.Fake1\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ \.fake2\..*\.Fake2\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ \.fake3\..*\.Fake3\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ \.fake4\..*\.Fake4\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ total$
+ sum
+
+
+ min$
+ min
+
+
+ max$
+ max
+
+
+ total?
+ sum
+
+
+ min\?
+ min
+
+
+ max\?
+ max
+
+
+ ^hourly
+ sum
+
+
+ avg
+
+ 0
+ 42
+
+
+ 60
+ 10
+
+
+
+ `
+
+var benchConfigSeparated = `
+
+
+ plain
+ ^hourly
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ plain
+ ^live
+
+ 0
+ 1
+
+
+
+ plain
+ \.fake1\..*\.Fake1\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ tagged
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ plain
+ \.fake2\..*\.Fake2\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ tagged
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ plain
+ \.fake3\..*\.Fake3\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ tagged
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ plain
+ \.fake4\..*\.Fake4\.
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ tagged
+
+
+ 3600
+ 60
+
+
+ 86400
+ 3600
+
+
+
+ plain
+ total$
+ sum
+
+
+ plain
+ min$
+ min
+
+
+ plain
+ max$
+ max
+
+
+ tagged
+ total?
+ sum
+
+
+ tagged
+ min\?
+ min
+
+
+ tagged
+ max\?
+ max
+
+
+ tagged
+ ^hourly
+ sum
+
+
+ avg
+
+ 0
+ 42
+
+
+ 60
+ 10
+
+
+
+ `
+
+func BenchmarkLookupSum(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.sum", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupSumSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.sum", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupSumTagged(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("sum?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupSumTaggedSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("sum?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupMax(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.max", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupMaxSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.max", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupMaxTagged(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("max?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupMaxTaggedSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("max?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupDefault(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.p95", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupDefaultSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("test.p95", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupDefaultTagged(b *testing.B) {
+ r, err := parseXML([]byte(benchConfig))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("p95?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
+
+func BenchmarkLookupDefaultTaggedSeparated(b *testing.B) {
+ r, err := parseXML([]byte(benchConfigSeparated))
+ require.NoError(b, err)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ precision, ag, _, _ := r.Lookup("p95?env=test&tag=Fake5", 1, false)
+ _ = precision
+ _ = ag
+ }
+}
diff --git a/helper/rollup/xml_test.go b/helper/rollup/xml_test.go
index 0e22a06e..485412aa 100644
--- a/helper/rollup/xml_test.go
+++ b/helper/rollup/xml_test.go
@@ -178,7 +178,7 @@ func TestParseXMLTyped(t *testing.T) {
`
expected := (&Rules{
- Splitted: true,
+ Separated: true,
Pattern: []Pattern{
{
Regexp: "click_cost", Function: "any", Retention: []Retention{