Skip to content

Commit

Permalink
feat: improve performance by pre-compiling regexes (#1439)
Browse files Browse the repository at this point in the history
* perf: Precompile regexps

* perf: Cache dynamic regexps
  • Loading branch information
surik authored Sep 16, 2024
1 parent 62cea26 commit c55ed50
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
6 changes: 5 additions & 1 deletion model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,14 @@ func (model Model) SortPoliciesByPriority() error {
return nil
}

var (
pPattern = regexp.MustCompile("^p_")
rPattern = regexp.MustCompile("^r_")
)

func (model Model) ToText() string {
tokenPatterns := make(map[string]string)

pPattern, rPattern := regexp.MustCompile("^p_"), regexp.MustCompile("^r_")
for _, ptype := range []string{"r", "p"} {
for _, token := range model[ptype][ptype].Tokens {
tokenPatterns[token] = rPattern.ReplaceAllString(pPattern.ReplaceAllString(token, "p."), "r.")
Expand Down
57 changes: 36 additions & 21 deletions util/builtin_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,31 @@ import (
)

var (
keyMatch4Re *regexp.Regexp = regexp.MustCompile(`{([^/]+)}`)
keyMatch2Re = regexp.MustCompile(`:[^/]+`)
keyMatch3Re = regexp.MustCompile(`\{[^/]+\}`)
keyMatch4Re = regexp.MustCompile(`{([^/]+)}`)
keyMatch5Re = regexp.MustCompile(`\{[^/]+\}`)
keyGet2Re1 = regexp.MustCompile(`:[^/]+`)
keyGet3Re1 = regexp.MustCompile(`\{[^/]+?\}`) // non-greedy match of `{...}` to support multiple {} in `/.../`
reCache = map[string]*regexp.Regexp{}
reCacheMu = sync.RWMutex{}
)

func mustCompileOrGet(key string) *regexp.Regexp {
reCacheMu.RLock()
re, ok := reCache[key]
reCacheMu.RUnlock()

if !ok {
re = regexp.MustCompile(key)
reCacheMu.Lock()
reCache[key] = re
reCacheMu.Unlock()
}

return re
}

// validate the variadic parameter size and type as string.
func validateVariadicArgs(expectedLen int, args ...interface{}) error {
if len(args) != expectedLen {
Expand Down Expand Up @@ -117,8 +139,7 @@ func KeyGetFunc(args ...interface{}) (interface{}, error) {
func KeyMatch2(key1 string, key2 string) bool {
key2 = strings.Replace(key2, "/*", "/.*", -1)

re := regexp.MustCompile(`:[^/]+`)
key2 = re.ReplaceAllString(key2, "$1[^/]+$2")
key2 = keyMatch2Re.ReplaceAllString(key2, "$1[^/]+$2")

return RegexMatch(key1, "^"+key2+"$")
}
Expand All @@ -140,13 +161,12 @@ func KeyMatch2Func(args ...interface{}) (interface{}, error) {
// if the pathVar == "resource", then "resource1" will be returned.
func KeyGet2(key1, key2 string, pathVar string) string {
key2 = strings.Replace(key2, "/*", "/.*", -1)

re := regexp.MustCompile(`:[^/]+`)
keys := re.FindAllString(key2, -1)
key2 = re.ReplaceAllString(key2, "$1([^/]+)$2")
keys := keyGet2Re1.FindAllString(key2, -1)
key2 = keyGet2Re1.ReplaceAllString(key2, "$1([^/]+)$2")
key2 = "^" + key2 + "$"
re2 := regexp.MustCompile(key2)
values := re2.FindAllStringSubmatch(key1, -1)

re := mustCompileOrGet(key2)
values := re.FindAllStringSubmatch(key1, -1)
if len(values) == 0 {
return ""
}
Expand Down Expand Up @@ -175,9 +195,7 @@ func KeyGet2Func(args ...interface{}) (interface{}, error) {
// For example, "/foo/bar" matches "/foo/*", "/resource1" matches "/{resource}".
func KeyMatch3(key1 string, key2 string) bool {
key2 = strings.Replace(key2, "/*", "/.*", -1)

re := regexp.MustCompile(`\{[^/]+\}`)
key2 = re.ReplaceAllString(key2, "$1[^/]+$2")
key2 = keyMatch3Re.ReplaceAllString(key2, "$1[^/]+$2")

return RegexMatch(key1, "^"+key2+"$")
}
Expand All @@ -200,12 +218,11 @@ func KeyMatch3Func(args ...interface{}) (interface{}, error) {
func KeyGet3(key1, key2 string, pathVar string) string {
key2 = strings.Replace(key2, "/*", "/.*", -1)

re := regexp.MustCompile(`\{[^/]+?\}`) // non-greedy match of `{...}` to support multiple {} in `/.../`
keys := re.FindAllString(key2, -1)
key2 = re.ReplaceAllString(key2, "$1([^/]+?)$2")
keys := keyGet3Re1.FindAllString(key2, -1)
key2 = keyGet3Re1.ReplaceAllString(key2, "$1([^/]+?)$2")
key2 = "^" + key2 + "$"
re2 := regexp.MustCompile(key2)
values := re2.FindAllStringSubmatch(key1, -1)
re := mustCompileOrGet(key2)
values := re.FindAllStringSubmatch(key1, -1)
if len(values) == 0 {
return ""
}
Expand Down Expand Up @@ -246,7 +263,7 @@ func KeyMatch4(key1 string, key2 string) bool {
return "([^/]+)"
})

re = regexp.MustCompile("^" + key2 + "$")
re = mustCompileOrGet("^" + key2 + "$")
matches := re.FindStringSubmatch(key1)
if matches == nil {
return false
Expand Down Expand Up @@ -296,9 +313,7 @@ func KeyMatch5(key1 string, key2 string) bool {
}

key2 = strings.Replace(key2, "/*", "/.*", -1)

re := regexp.MustCompile(`\{[^/]+\}`)
key2 = re.ReplaceAllString(key2, "$1[^/]+$2")
key2 = keyMatch5Re.ReplaceAllString(key2, "$1[^/]+$2")

return RegexMatch(key1, "^"+key2+"$")
}
Expand Down

2 comments on commit c55ed50

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: c55ed50 Previous: 62cea26 Ratio
BenchmarkCachedRaw 17.64 ns/op 0 B/op 0 allocs/op 18.19 ns/op 0 B/op 0 allocs/op 0.97
BenchmarkCachedRaw - ns/op 17.64 ns/op 18.19 ns/op 0.97
BenchmarkCachedRaw - B/op 0 B/op 0 B/op 1
BenchmarkCachedRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkCachedBasicModel 184.7 ns/op 104 B/op 4 allocs/op 183.5 ns/op 104 B/op 4 allocs/op 1.01
BenchmarkCachedBasicModel - ns/op 184.7 ns/op 183.5 ns/op 1.01
BenchmarkCachedBasicModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedBasicModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModel 182.6 ns/op 104 B/op 4 allocs/op 180.6 ns/op 104 B/op 4 allocs/op 1.01
BenchmarkCachedRBACModel - ns/op 182.6 ns/op 180.6 ns/op 1.01
BenchmarkCachedRBACModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelSmall 189.7 ns/op 104 B/op 4 allocs/op 184.3 ns/op 104 B/op 4 allocs/op 1.03
BenchmarkCachedRBACModelSmall - ns/op 189.7 ns/op 184.3 ns/op 1.03
BenchmarkCachedRBACModelSmall - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelSmall - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelMedium 193.6 ns/op 104 B/op 4 allocs/op 192.1 ns/op 104 B/op 4 allocs/op 1.01
BenchmarkCachedRBACModelMedium - ns/op 193.6 ns/op 192.1 ns/op 1.01
BenchmarkCachedRBACModelMedium - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelMedium - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelLarge 169.2 ns/op 96 B/op 3 allocs/op 163.6 ns/op 96 B/op 3 allocs/op 1.03
BenchmarkCachedRBACModelLarge - ns/op 169.2 ns/op 163.6 ns/op 1.03
BenchmarkCachedRBACModelLarge - B/op 96 B/op 96 B/op 1
BenchmarkCachedRBACModelLarge - allocs/op 3 allocs/op 3 allocs/op 1
BenchmarkCachedRBACModelWithResourceRoles 187.2 ns/op 104 B/op 4 allocs/op 193.1 ns/op 104 B/op 4 allocs/op 0.97
BenchmarkCachedRBACModelWithResourceRoles - ns/op 187.2 ns/op 193.1 ns/op 0.97
BenchmarkCachedRBACModelWithResourceRoles - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithResourceRoles - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDomains 191.5 ns/op 120 B/op 4 allocs/op 200.1 ns/op 120 B/op 4 allocs/op 0.96
BenchmarkCachedRBACModelWithDomains - ns/op 191.5 ns/op 200.1 ns/op 0.96
BenchmarkCachedRBACModelWithDomains - B/op 120 B/op 120 B/op 1
BenchmarkCachedRBACModelWithDomains - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedABACModel 2793 ns/op 1539 B/op 18 allocs/op 3054 ns/op 1535 B/op 18 allocs/op 0.91
BenchmarkCachedABACModel - ns/op 2793 ns/op 3054 ns/op 0.91
BenchmarkCachedABACModel - B/op 1539 B/op 1535 B/op 1.00
BenchmarkCachedABACModel - allocs/op 18 allocs/op 18 allocs/op 1
BenchmarkCachedKeyMatchModel 192 ns/op 152 B/op 4 allocs/op 212 ns/op 152 B/op 4 allocs/op 0.91
BenchmarkCachedKeyMatchModel - ns/op 192 ns/op 212 ns/op 0.91
BenchmarkCachedKeyMatchModel - B/op 152 B/op 152 B/op 1
BenchmarkCachedKeyMatchModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedRBACModelWithDeny 183.1 ns/op 104 B/op 4 allocs/op 193.4 ns/op 104 B/op 4 allocs/op 0.95
BenchmarkCachedRBACModelWithDeny - ns/op 183.1 ns/op 193.4 ns/op 0.95
BenchmarkCachedRBACModelWithDeny - B/op 104 B/op 104 B/op 1
BenchmarkCachedRBACModelWithDeny - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedPriorityModel 179.2 ns/op 104 B/op 4 allocs/op 189.7 ns/op 104 B/op 4 allocs/op 0.94
BenchmarkCachedPriorityModel - ns/op 179.2 ns/op 189.7 ns/op 0.94
BenchmarkCachedPriorityModel - B/op 104 B/op 104 B/op 1
BenchmarkCachedPriorityModel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkCachedWithEnforceContext 297.4 ns/op 240 B/op 5 allocs/op 315.7 ns/op 240 B/op 5 allocs/op 0.94
BenchmarkCachedWithEnforceContext - ns/op 297.4 ns/op 315.7 ns/op 0.94
BenchmarkCachedWithEnforceContext - B/op 240 B/op 240 B/op 1
BenchmarkCachedWithEnforceContext - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkCachedRBACModelMediumParallel 176.4 ns/op 105 B/op 4 allocs/op 171.7 ns/op 105 B/op 4 allocs/op 1.03
BenchmarkCachedRBACModelMediumParallel - ns/op 176.4 ns/op 171.7 ns/op 1.03
BenchmarkCachedRBACModelMediumParallel - B/op 105 B/op 105 B/op 1
BenchmarkCachedRBACModelMediumParallel - allocs/op 4 allocs/op 4 allocs/op 1
BenchmarkHasPolicySmall 507.2 ns/op 150 B/op 6 allocs/op 536.5 ns/op 150 B/op 6 allocs/op 0.95
BenchmarkHasPolicySmall - ns/op 507.2 ns/op 536.5 ns/op 0.95
BenchmarkHasPolicySmall - B/op 150 B/op 150 B/op 1
BenchmarkHasPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyMedium 544.2 ns/op 157 B/op 6 allocs/op 610.4 ns/op 157 B/op 6 allocs/op 0.89
BenchmarkHasPolicyMedium - ns/op 544.2 ns/op 610.4 ns/op 0.89
BenchmarkHasPolicyMedium - B/op 157 B/op 157 B/op 1
BenchmarkHasPolicyMedium - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkHasPolicyLarge 561.5 ns/op 165 B/op 7 allocs/op 590.5 ns/op 165 B/op 7 allocs/op 0.95
BenchmarkHasPolicyLarge - ns/op 561.5 ns/op 590.5 ns/op 0.95
BenchmarkHasPolicyLarge - B/op 165 B/op 165 B/op 1
BenchmarkHasPolicyLarge - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicySmall 559.1 ns/op 152 B/op 6 allocs/op 581.2 ns/op 152 B/op 6 allocs/op 0.96
BenchmarkAddPolicySmall - ns/op 559.1 ns/op 581.2 ns/op 0.96
BenchmarkAddPolicySmall - B/op 152 B/op 152 B/op 1
BenchmarkAddPolicySmall - allocs/op 6 allocs/op 6 allocs/op 1
BenchmarkAddPolicyMedium 639.1 ns/op 169 B/op 7 allocs/op 757.5 ns/op 171 B/op 7 allocs/op 0.84
BenchmarkAddPolicyMedium - ns/op 639.1 ns/op 757.5 ns/op 0.84
BenchmarkAddPolicyMedium - B/op 169 B/op 171 B/op 0.99
BenchmarkAddPolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkAddPolicyLarge 1310 ns/op 464 B/op 9 allocs/op 1298 ns/op 448 B/op 9 allocs/op 1.01
BenchmarkAddPolicyLarge - ns/op 1310 ns/op 1298 ns/op 1.01
BenchmarkAddPolicyLarge - B/op 464 B/op 448 B/op 1.04
BenchmarkAddPolicyLarge - allocs/op 9 allocs/op 9 allocs/op 1
BenchmarkRemovePolicySmall 509.5 ns/op 166 B/op 7 allocs/op 547.8 ns/op 166 B/op 7 allocs/op 0.93
BenchmarkRemovePolicySmall - ns/op 509.5 ns/op 547.8 ns/op 0.93
BenchmarkRemovePolicySmall - B/op 166 B/op 166 B/op 1
BenchmarkRemovePolicySmall - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyMedium 583.2 ns/op 175 B/op 7 allocs/op 628 ns/op 175 B/op 7 allocs/op 0.93
BenchmarkRemovePolicyMedium - ns/op 583.2 ns/op 628 ns/op 0.93
BenchmarkRemovePolicyMedium - B/op 175 B/op 175 B/op 1
BenchmarkRemovePolicyMedium - allocs/op 7 allocs/op 7 allocs/op 1
BenchmarkRemovePolicyLarge 1388 ns/op 284 B/op 12 allocs/op 1164 ns/op 279 B/op 12 allocs/op 1.19
BenchmarkRemovePolicyLarge - ns/op 1388 ns/op 1164 ns/op 1.19
BenchmarkRemovePolicyLarge - B/op 284 B/op 279 B/op 1.02
BenchmarkRemovePolicyLarge - allocs/op 12 allocs/op 12 allocs/op 1
BenchmarkRaw 17.66 ns/op 0 B/op 0 allocs/op 18.19 ns/op 0 B/op 0 allocs/op 0.97
BenchmarkRaw - ns/op 17.66 ns/op 18.19 ns/op 0.97
BenchmarkRaw - B/op 0 B/op 0 B/op 1
BenchmarkRaw - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkBasicModel 3716 ns/op 1509 B/op 17 allocs/op 3874 ns/op 1502 B/op 17 allocs/op 0.96
BenchmarkBasicModel - ns/op 3716 ns/op 3874 ns/op 0.96
BenchmarkBasicModel - B/op 1509 B/op 1502 B/op 1.00
BenchmarkBasicModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkRBACModel 5448 ns/op 2066 B/op 35 allocs/op 5734 ns/op 2053 B/op 35 allocs/op 0.95
BenchmarkRBACModel - ns/op 5448 ns/op 5734 ns/op 0.95
BenchmarkRBACModel - B/op 2066 B/op 2053 B/op 1.01
BenchmarkRBACModel - allocs/op 35 allocs/op 35 allocs/op 1
BenchmarkRBACModelSizes/small 50128 ns/op 20271 B/op 480 allocs/op 51141 ns/op 20201 B/op 480 allocs/op 0.98
BenchmarkRBACModelSizes/small - ns/op 50128 ns/op 51141 ns/op 0.98
BenchmarkRBACModelSizes/small - B/op 20271 B/op 20201 B/op 1.00
BenchmarkRBACModelSizes/small - allocs/op 480 allocs/op 480 allocs/op 1
BenchmarkRBACModelSizes/medium 498273 ns/op 191782 B/op 4828 allocs/op 538514 ns/op 191784 B/op 4829 allocs/op 0.93
BenchmarkRBACModelSizes/medium - ns/op 498273 ns/op 538514 ns/op 0.93
BenchmarkRBACModelSizes/medium - B/op 191782 B/op 191784 B/op 1.00
BenchmarkRBACModelSizes/medium - allocs/op 4828 allocs/op 4829 allocs/op 1.00
BenchmarkRBACModelSizes/large 5167806 ns/op 1900583 B/op 48199 allocs/op 5780629 ns/op 1901508 B/op 48223 allocs/op 0.89
BenchmarkRBACModelSizes/large - ns/op 5167806 ns/op 5780629 ns/op 0.89
BenchmarkRBACModelSizes/large - B/op 1900583 B/op 1901508 B/op 1.00
BenchmarkRBACModelSizes/large - allocs/op 48199 allocs/op 48223 allocs/op 1.00
BenchmarkRBACModelSmall 61231 ns/op 20291 B/op 615 allocs/op 61570 ns/op 20264 B/op 615 allocs/op 0.99
BenchmarkRBACModelSmall - ns/op 61231 ns/op 61570 ns/op 0.99
BenchmarkRBACModelSmall - B/op 20291 B/op 20264 B/op 1.00
BenchmarkRBACModelSmall - allocs/op 615 allocs/op 615 allocs/op 1
BenchmarkRBACModelMedium 568391 ns/op 194523 B/op 6018 allocs/op 604710 ns/op 194611 B/op 6018 allocs/op 0.94
BenchmarkRBACModelMedium - ns/op 568391 ns/op 604710 ns/op 0.94
BenchmarkRBACModelMedium - B/op 194523 B/op 194611 B/op 1.00
BenchmarkRBACModelMedium - allocs/op 6018 allocs/op 6018 allocs/op 1
BenchmarkRBACModelLarge 5983377 ns/op 1933154 B/op 60290 allocs/op 6142297 ns/op 1934305 B/op 60334 allocs/op 0.97
BenchmarkRBACModelLarge - ns/op 5983377 ns/op 6142297 ns/op 0.97
BenchmarkRBACModelLarge - B/op 1933154 B/op 1934305 B/op 1.00
BenchmarkRBACModelLarge - allocs/op 60290 allocs/op 60334 allocs/op 1.00
BenchmarkRBACModelWithResourceRoles 5295 ns/op 2738 B/op 28 allocs/op 5485 ns/op 2719 B/op 28 allocs/op 0.97
BenchmarkRBACModelWithResourceRoles - ns/op 5295 ns/op 5485 ns/op 0.97
BenchmarkRBACModelWithResourceRoles - B/op 2738 B/op 2719 B/op 1.01
BenchmarkRBACModelWithResourceRoles - allocs/op 28 allocs/op 28 allocs/op 1
BenchmarkRBACModelWithDomains 5066 ns/op 1826 B/op 25 allocs/op 5348 ns/op 1819 B/op 25 allocs/op 0.95
BenchmarkRBACModelWithDomains - ns/op 5066 ns/op 5348 ns/op 0.95
BenchmarkRBACModelWithDomains - B/op 1826 B/op 1819 B/op 1.00
BenchmarkRBACModelWithDomains - allocs/op 25 allocs/op 25 allocs/op 1
BenchmarkABACModel 2830 ns/op 1537 B/op 17 allocs/op 2914 ns/op 1528 B/op 17 allocs/op 0.97
BenchmarkABACModel - ns/op 2830 ns/op 2914 ns/op 0.97
BenchmarkABACModel - B/op 1537 B/op 1528 B/op 1.01
BenchmarkABACModel - allocs/op 17 allocs/op 17 allocs/op 1
BenchmarkABACRuleModel 4021723 ns/op 1330094 B/op 40092 allocs/op 4095359 ns/op 1316533 B/op 40090 allocs/op 0.98
BenchmarkABACRuleModel - ns/op 4021723 ns/op 4095359 ns/op 0.98
BenchmarkABACRuleModel - B/op 1330094 B/op 1316533 B/op 1.01
BenchmarkABACRuleModel - allocs/op 40092 allocs/op 40090 allocs/op 1.00
BenchmarkKeyMatchModel 6184 ns/op 3070 B/op 37 allocs/op 6341 ns/op 3051 B/op 37 allocs/op 0.98
BenchmarkKeyMatchModel - ns/op 6184 ns/op 6341 ns/op 0.98
BenchmarkKeyMatchModel - B/op 3070 B/op 3051 B/op 1.01
BenchmarkKeyMatchModel - allocs/op 37 allocs/op 37 allocs/op 1
BenchmarkRBACModelWithDeny 7036 ns/op 2487 B/op 49 allocs/op 7183 ns/op 2467 B/op 49 allocs/op 0.98
BenchmarkRBACModelWithDeny - ns/op 7036 ns/op 7183 ns/op 0.98
BenchmarkRBACModelWithDeny - B/op 2487 B/op 2467 B/op 1.01
BenchmarkRBACModelWithDeny - allocs/op 49 allocs/op 49 allocs/op 1
BenchmarkPriorityModel 4209 ns/op 1766 B/op 22 allocs/op 4394 ns/op 1754 B/op 22 allocs/op 0.96
BenchmarkPriorityModel - ns/op 4209 ns/op 4394 ns/op 0.96
BenchmarkPriorityModel - B/op 1766 B/op 1754 B/op 1.01
BenchmarkPriorityModel - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkRBACModelWithDomainPatternLarge 13501 ns/op 8693 B/op 72 allocs/op 24595 ns/op 16711 B/op 164 allocs/op 0.55
BenchmarkRBACModelWithDomainPatternLarge - ns/op 13501 ns/op 24595 ns/op 0.55
BenchmarkRBACModelWithDomainPatternLarge - B/op 8693 B/op 16711 B/op 0.52
BenchmarkRBACModelWithDomainPatternLarge - allocs/op 72 allocs/op 164 allocs/op 0.44
BenchmarkRoleManagerSmall 72109 ns/op 11955 B/op 797 allocs/op 71739 ns/op 11954 B/op 797 allocs/op 1.01
BenchmarkRoleManagerSmall - ns/op 72109 ns/op 71739 ns/op 1.01
BenchmarkRoleManagerSmall - B/op 11955 B/op 11954 B/op 1.00
BenchmarkRoleManagerSmall - allocs/op 797 allocs/op 797 allocs/op 1
BenchmarkRoleManagerMedium 732165 ns/op 125914 B/op 8741 allocs/op 742295 ns/op 125913 B/op 8741 allocs/op 0.99
BenchmarkRoleManagerMedium - ns/op 732165 ns/op 742295 ns/op 0.99
BenchmarkRoleManagerMedium - B/op 125914 B/op 125913 B/op 1.00
BenchmarkRoleManagerMedium - allocs/op 8741 allocs/op 8741 allocs/op 1
BenchmarkRoleManagerLarge 7964602 ns/op 1349926 B/op 89741 allocs/op 9529544 ns/op 1349924 B/op 89741 allocs/op 0.84
BenchmarkRoleManagerLarge - ns/op 7964602 ns/op 9529544 ns/op 0.84
BenchmarkRoleManagerLarge - B/op 1349926 B/op 1349924 B/op 1.00
BenchmarkRoleManagerLarge - allocs/op 89741 allocs/op 89741 allocs/op 1
BenchmarkBuildRoleLinksWithPatternLarge 331510685 ns/op 90236379 B/op 3599770 allocs/op 6490055533 ns/op 5333333872 B/op 60945594 allocs/op 0.05107979173897155
BenchmarkBuildRoleLinksWithPatternLarge - ns/op 331510685 ns/op 6490055533 ns/op 0.05107979173897155
BenchmarkBuildRoleLinksWithPatternLarge - B/op 90236379 B/op 5333333872 B/op 0.016919319353648744
BenchmarkBuildRoleLinksWithPatternLarge - allocs/op 3599770 allocs/op 60945594 allocs/op 0.05906530339174314
BenchmarkBuildRoleLinksWithDomainPatternLarge 12068710 ns/op 4708833 B/op 145247 allocs/op 178446545 ns/op 141263329 B/op 1676405 allocs/op 0.06763207435593667
BenchmarkBuildRoleLinksWithDomainPatternLarge - ns/op 12068710 ns/op 178446545 ns/op 0.06763207435593667
BenchmarkBuildRoleLinksWithDomainPatternLarge - B/op 4708833 B/op 141263329 B/op 0.033333725272749304
BenchmarkBuildRoleLinksWithDomainPatternLarge - allocs/op 145247 allocs/op 1676405 allocs/op 0.08664195107984049
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge 341165478 ns/op 91964061 B/op 3679273 allocs/op 6523634217 ns/op 5474425808 B/op 62556841 allocs/op 0.052296843546340115
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - ns/op 341165478 ns/op 6523634217 ns/op 0.052296843546340115
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - B/op 91964061 B/op 5474425808 B/op 0.016798850550793692
BenchmarkBuildRoleLinksWithPatternAndDomainPatternLarge - allocs/op 3679273 allocs/op 62556841 allocs/op 0.058814878455899014
BenchmarkHasLinkWithPatternLarge 1146 ns/op 177 B/op 13 allocs/op 10895 ns/op 7593 B/op 111 allocs/op 0.11
BenchmarkHasLinkWithPatternLarge - ns/op 1146 ns/op 10895 ns/op 0.11
BenchmarkHasLinkWithPatternLarge - B/op 177 B/op 7593 B/op 0.023310944290794153
BenchmarkHasLinkWithPatternLarge - allocs/op 13 allocs/op 111 allocs/op 0.12
BenchmarkHasLinkWithDomainPatternLarge 478.7 ns/op 80 B/op 5 allocs/op 495.6 ns/op 80 B/op 5 allocs/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - ns/op 478.7 ns/op 495.6 ns/op 0.97
BenchmarkHasLinkWithDomainPatternLarge - B/op 80 B/op 80 B/op 1
BenchmarkHasLinkWithDomainPatternLarge - allocs/op 5 allocs/op 5 allocs/op 1
BenchmarkHasLinkWithPatternAndDomainPatternLarge 1116 ns/op 177 B/op 13 allocs/op 10972 ns/op 7589 B/op 111 allocs/op 0.10
BenchmarkHasLinkWithPatternAndDomainPatternLarge - ns/op 1116 ns/op 10972 ns/op 0.10
BenchmarkHasLinkWithPatternAndDomainPatternLarge - B/op 177 B/op 7589 B/op 0.02332323099222559
BenchmarkHasLinkWithPatternAndDomainPatternLarge - allocs/op 13 allocs/op 111 allocs/op 0.12

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: c55ed50 Previous: 62cea26 Ratio
BenchmarkRemovePolicyLarge 1388 ns/op 284 B/op 12 allocs/op 1164 ns/op 279 B/op 12 allocs/op 1.19
BenchmarkRemovePolicyLarge - ns/op 1388 ns/op 1164 ns/op 1.19

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.