Skip to content

Optimize enforcement performance via matcher expression caching#1617

Open
Copilot wants to merge 5 commits intomasterfrom
copilot/improve-enforcement-performance
Open

Optimize enforcement performance via matcher expression caching#1617
Copilot wants to merge 5 commits intomasterfrom
copilot/improve-enforcement-performance

Conversation

Copy link
Contributor

Copilot AI commented Dec 21, 2025

Enforcement was recompiling matcher expressions and rebuilding token maps on every call, causing ~60% overhead.

Changes

  • Cached matcher compilation: Store precompiled govaluate expressions keyed by (expression, rType, pType) to handle multiple contexts
  • Cached token maps: Build request/policy token index maps once instead of per-enforcement
  • Cached eval() detection: Store hasEval flag to avoid repeated string scanning
  • Smart compilation strategy:
    • Non-eval matchers: fully cached expression
    • Eval matchers: cached token maps + per-request recompilation (eval function is request-dependent)
type cachedMatcherExpression struct {
    expression *govaluate.EvaluableExpression  // nil for eval() expressions
    hasEval    bool
    rTokens    map[string]int
    pTokens    map[string]int
}

Cache invalidated on model/policy changes via existing invalidateMatcherMap() calls.

Performance

Metric Before After Δ
ns/op 3384 1882 -44%
B/op 1506 1048 -30%
allocs/op 18 15 -17%

All tests pass including PBAC (eval-based) models.

Original prompt

This section details on the original issue you should resolve

<issue_title>[feature] improve enforcement performance</issue_title>
<issue_description>need to improve enforcement performance, some possible optimizing methods including precompiling the matcher expressions and others.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLAassistant commented Dec 21, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hsluoyz hsluoyz marked this pull request as ready for review December 21, 2025 12:31
…oken maps

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Dec 21, 2025

Benchmark Comparison

Comparing base branch (b3f4490)
vs PR branch (deafdf8)

goos: linux
goarch: amd64
pkg: github.com/casbin/casbin/v3
cpu: AMD EPYC 7763 64-Core Processor                
                                                 │ base-bench.txt │             pr-bench.txt             │
                                                 │     sec/op     │    sec/op     vs base                │
CachedRaw-4                                          17.62n ± ∞ ¹   19.09n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedBasicModel-4                                   166.5n ± ∞ ¹   170.0n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModel-4                                    167.6n ± ∞ ¹   169.4n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelSmall-4                               175.7n ± ∞ ¹   178.7n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMedium-4                              180.5n ± ∞ ¹   189.4n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelLarge-4                               160.0n ± ∞ ¹   158.1n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithResourceRoles-4                   168.6n ± ∞ ¹   178.2n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDomains-4                         179.8n ± ∞ ¹   179.9n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedABACModel-4                                    2.789µ ± ∞ ¹   1.904µ ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedKeyMatchModel-4                                186.2n ± ∞ ¹   186.9n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDeny-4                            169.8n ± ∞ ¹   169.4n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedPriorityModel-4                                168.9n ± ∞ ¹   170.4n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedWithEnforceContext-4                           287.9n ± ∞ ¹   300.6n ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMediumParallel-4                      179.2n ± ∞ ¹   177.0n ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicySmall-4                                     497.2n ± ∞ ¹   499.2n ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyMedium-4                                    549.7n ± ∞ ¹   535.8n ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyLarge-4                                     553.1n ± ∞ ¹   588.1n ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicySmall-4                                     517.5n ± ∞ ¹   518.5n ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyMedium-4                                    593.7n ± ∞ ¹   599.8n ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyLarge-4                                     1.301µ ± ∞ ¹   1.288µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicySmall-4                                  542.6n ± ∞ ¹   491.8n ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicyMedium-4                                 557.1n ± ∞ ¹   561.9n ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicyLarge-4                                  616.9n ± ∞ ¹   651.1n ± ∞ ¹       ~ (p=1.000 n=1) ²
Raw-4                                                17.63n ± ∞ ¹   17.65n ± ∞ ¹       ~ (p=1.000 n=1) ²
BasicModel-4                                         3.571µ ± ∞ ¹   2.109µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModel-4                                          5.325µ ± ∞ ¹   3.842µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelSizes/small-4                               47.65µ ± ∞ ¹   47.50µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelSizes/medium-4                              493.8µ ± ∞ ¹   489.3µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelSizes/large-4                               5.369m ± ∞ ¹   5.289m ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelSmall-4                                     57.47µ ± ∞ ¹   58.95µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelMedium-4                                    563.5µ ± ∞ ¹   563.3µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelLarge-4                                     5.871m ± ∞ ¹   5.792m ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelWithResourceRoles-4                         5.238µ ± ∞ ¹   3.602µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelWithDomains-4                               5.079µ ± ∞ ¹   2.994µ ± ∞ ¹       ~ (p=1.000 n=1) ²
ABACModel-4                                          2.798µ ± ∞ ¹   1.894µ ± ∞ ¹       ~ (p=1.000 n=1) ²
ABACRuleModel-4                                      4.143m ± ∞ ¹   4.183m ± ∞ ¹       ~ (p=1.000 n=1) ²
KeyMatchModel-4                                      6.051µ ± ∞ ¹   4.246µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelWithDeny-4                                  6.787µ ± ∞ ¹   5.241µ ± ∞ ¹       ~ (p=1.000 n=1) ²
PriorityModel-4                                      4.127µ ± ∞ ¹   2.604µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RBACModelWithDomainPatternLarge-4                    13.26µ ± ∞ ¹   11.52µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerSmall-4                                   69.31µ ± ∞ ¹   71.38µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerMedium-4                                  732.0µ ± ∞ ¹   719.2µ ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerLarge-4                                   8.017m ± ∞ ¹   7.788m ± ∞ ¹       ~ (p=1.000 n=1) ²
BuildRoleLinksWithPatternLarge-4                     336.9m ± ∞ ¹   340.9m ± ∞ ¹       ~ (p=1.000 n=1) ²
BuildRoleLinksWithDomainPatternLarge-4               12.10m ± ∞ ¹   12.01m ± ∞ ¹       ~ (p=1.000 n=1) ²
BuildRoleLinksWithPatternAndDomainPatternLarge-4     341.7m ± ∞ ¹   347.4m ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithPatternLarge-4                            1.121µ ± ∞ ¹   1.131µ ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithDomainPatternLarge-4                      478.9n ± ∞ ¹   486.9n ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithPatternAndDomainPatternLarge-4            1.123µ ± ∞ ¹   1.140µ ± ∞ ¹       ~ (p=1.000 n=1) ²
ConcurrentHasLinkWithMatching-4                      1.968µ ± ∞ ¹   2.089µ ± ∞ ¹       ~ (p=1.000 n=1) ²
EnforcementPerformance-4                                            3.722µ ± ∞ ¹
EnforcementWithMultipleContexts-4                                   3.335µ ± ∞ ¹
EnforcementScalability/Small-4                                      7.361µ ± ∞ ¹
EnforcementScalability/Medium-4                                     64.36µ ± ∞ ¹
EnforcementScalability/Large-4                                      2.014m ± ∞ ¹
geomean                                              5.343µ         5.802µ        -6.53%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                                 │ base-bench.txt │             pr-bench.txt              │
                                                 │      B/op      │     B/op       vs base                │
CachedRaw-4                                           0.000 ± ∞ ¹     0.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedBasicModel-4                                    104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModel-4                                     104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelSmall-4                                104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMedium-4                               104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelLarge-4                                96.00 ± ∞ ¹     96.00 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithResourceRoles-4                    104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDomains-4                          120.0 ± ∞ ¹     120.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedABACModel-4                                   1.503Ki ± ∞ ¹   1.005Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
CachedKeyMatchModel-4                                 152.0 ± ∞ ¹     152.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDeny-4                             104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedPriorityModel-4                                 104.0 ± ∞ ¹     104.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedWithEnforceContext-4                            240.0 ± ∞ ¹     240.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMediumParallel-4                       105.0 ± ∞ ¹     105.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicySmall-4                                      150.0 ± ∞ ¹     150.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyMedium-4                                     157.0 ± ∞ ¹     157.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyLarge-4                                      165.0 ± ∞ ¹     165.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicySmall-4                                      152.0 ± ∞ ¹     152.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyMedium-4                                     169.0 ± ∞ ¹     169.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyLarge-4                                      447.0 ± ∞ ¹     450.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
RemovePolicySmall-4                                   166.0 ± ∞ ¹     166.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicyMedium-4                                  173.0 ± ∞ ¹     174.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
RemovePolicyLarge-4                                   181.0 ± ∞ ¹     181.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
Raw-4                                                 0.000 ± ∞ ¹     0.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
BasicModel-4                                        1.468Ki ± ∞ ¹   1.013Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModel-4                                         2.010Ki ± ∞ ¹   1.545Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/small-4                              19.72Ki ± ∞ ¹   19.04Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/medium-4                             187.2Ki ± ∞ ¹   186.2Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/large-4                              1.812Mi ± ∞ ¹   1.810Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSmall-4                                    19.79Ki ± ∞ ¹   19.11Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelMedium-4                                   190.1Ki ± ∞ ¹   188.8Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelLarge-4                                    1.844Mi ± ∞ ¹   1.842Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithResourceRoles-4                        2.661Ki ± ∞ ¹   2.187Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDomains-4                              1.778Ki ± ∞ ¹   1.334Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
ABACModel-4                                          1530.0 ± ∞ ¹    1021.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
ABACRuleModel-4                                     1.258Mi ± ∞ ¹   1.261Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
KeyMatchModel-4                                     2.984Ki ± ∞ ¹   2.565Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDeny-4                                 2.415Ki ± ∞ ¹   1.943Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
PriorityModel-4                                     1.717Ki ± ∞ ¹   1.256Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDomainPatternLarge-4                   8.480Ki ± ∞ ¹   8.075Ki ± ∞ ¹       ~ (p=1.000 n=1) ³
RoleManagerSmall-4                                  11.67Ki ± ∞ ¹   11.67Ki ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerMedium-4                                 123.0Ki ± ∞ ¹   123.0Ki ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerLarge-4                                  1.287Mi ± ∞ ¹   1.287Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
BuildRoleLinksWithPatternLarge-4                    85.85Mi ± ∞ ¹   85.70Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
BuildRoleLinksWithDomainPatternLarge-4              4.489Mi ± ∞ ¹   4.483Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
BuildRoleLinksWithPatternAndDomainPatternLarge-4    87.58Mi ± ∞ ¹   87.41Mi ± ∞ ¹       ~ (p=1.000 n=1) ³
HasLinkWithPatternLarge-4                             176.0 ± ∞ ¹     176.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithDomainPatternLarge-4                       80.00 ± ∞ ¹     80.00 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithPatternAndDomainPatternLarge-4             177.0 ± ∞ ¹     176.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
ConcurrentHasLinkWithMatching-4                       622.0 ± ∞ ¹     622.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
EnforcementPerformance-4                                            1.545Ki ± ∞ ¹
EnforcementWithMultipleContexts-4                                   1.391Ki ± ∞ ¹
EnforcementScalability/Small-4                                      2.709Ki ± ∞ ¹
EnforcementScalability/Medium-4                                     19.04Ki ± ∞ ¹
EnforcementScalability/Large-4                                      413.5Ki ± ∞ ¹
geomean                                                         ⁴                  -5.33%               ⁴
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal
³ need >= 4 samples to detect a difference at alpha level 0.05
⁴ summaries must be >0 to compute geomean

                                                 │ base-bench.txt │             pr-bench.txt             │
                                                 │   allocs/op    │  allocs/op    vs base                │
CachedRaw-4                                           0.000 ± ∞ ¹    0.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedBasicModel-4                                    4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModel-4                                     4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelSmall-4                                4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMedium-4                               4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelLarge-4                                3.000 ± ∞ ¹    3.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithResourceRoles-4                    4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDomains-4                          4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedABACModel-4                                     18.00 ± ∞ ¹    15.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
CachedKeyMatchModel-4                                 4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelWithDeny-4                             4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedPriorityModel-4                                 4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedWithEnforceContext-4                            5.000 ± ∞ ¹    5.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
CachedRBACModelMediumParallel-4                       4.000 ± ∞ ¹    4.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicySmall-4                                      6.000 ± ∞ ¹    6.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyMedium-4                                     6.000 ± ∞ ¹    6.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasPolicyLarge-4                                      7.000 ± ∞ ¹    7.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicySmall-4                                      6.000 ± ∞ ¹    6.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyMedium-4                                     7.000 ± ∞ ¹    7.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
AddPolicyLarge-4                                      9.000 ± ∞ ¹    9.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicySmall-4                                   7.000 ± ∞ ¹    7.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicyMedium-4                                  7.000 ± ∞ ¹    7.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
RemovePolicyLarge-4                                   8.000 ± ∞ ¹    8.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
Raw-4                                                 0.000 ± ∞ ¹    0.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
BasicModel-4                                          17.00 ± ∞ ¹    14.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModel-4                                           35.00 ± ∞ ¹    32.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/small-4                                480.0 ± ∞ ¹    477.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/medium-4                              4.828k ± ∞ ¹   4.825k ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSizes/large-4                               48.17k ± ∞ ¹   48.14k ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelSmall-4                                      615.0 ± ∞ ¹    612.0 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelMedium-4                                    6.018k ± ∞ ¹   6.015k ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelLarge-4                                     60.30k ± ∞ ¹   60.29k ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithResourceRoles-4                          28.00 ± ∞ ¹    25.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDomains-4                                25.00 ± ∞ ¹    22.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
ABACModel-4                                           17.00 ± ∞ ¹    14.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
ABACRuleModel-4                                      40.09k ± ∞ ¹   40.09k ± ∞ ¹       ~ (p=1.000 n=1) ³
KeyMatchModel-4                                       37.00 ± ∞ ¹    34.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDeny-4                                   49.00 ± ∞ ¹    46.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
PriorityModel-4                                       22.00 ± ∞ ¹    19.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RBACModelWithDomainPatternLarge-4                     72.00 ± ∞ ¹    69.00 ± ∞ ¹       ~ (p=1.000 n=1) ³
RoleManagerSmall-4                                    797.0 ± ∞ ¹    797.0 ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerMedium-4                                  8.741k ± ∞ ¹   8.741k ± ∞ ¹       ~ (p=1.000 n=1) ²
RoleManagerLarge-4                                   89.74k ± ∞ ¹   89.74k ± ∞ ¹       ~ (p=1.000 n=1) ²
BuildRoleLinksWithPatternLarge-4                     3.600M ± ∞ ¹   3.600M ± ∞ ¹       ~ (p=1.000 n=1) ³
BuildRoleLinksWithDomainPatternLarge-4               145.2k ± ∞ ¹   145.2k ± ∞ ¹       ~ (p=1.000 n=1) ³
BuildRoleLinksWithPatternAndDomainPatternLarge-4     3.679M ± ∞ ¹   3.679M ± ∞ ¹       ~ (p=1.000 n=1) ³
HasLinkWithPatternLarge-4                             13.00 ± ∞ ¹    13.00 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithDomainPatternLarge-4                       5.000 ± ∞ ¹    5.000 ± ∞ ¹       ~ (p=1.000 n=1) ²
HasLinkWithPatternAndDomainPatternLarge-4             13.00 ± ∞ ¹    13.00 ± ∞ ¹       ~ (p=1.000 n=1) ²
ConcurrentHasLinkWithMatching-4                       21.00 ± ∞ ¹    21.00 ± ∞ ¹       ~ (p=1.000 n=1) ²
EnforcementPerformance-4                                             32.00 ± ∞ ¹
EnforcementWithMultipleContexts-4                                    27.00 ± ∞ ¹
EnforcementScalability/Small-4                                       71.00 ± ∞ ¹
EnforcementScalability/Medium-4                                      617.0 ± ∞ ¹
EnforcementScalability/Large-4                                      16.04k ± ∞ ¹
geomean                                                         ⁴                 -2.47%               ⁴
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal
³ need >= 4 samples to detect a difference at alpha level 0.05
⁴ summaries must be >0 to compute geomean

🤖 This comment will be automatically updated with the latest benchmark results.

Copilot AI and others added 3 commits December 21, 2025 12:39
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve enforcement performance with optimization methods Optimize enforcement performance via matcher expression caching Dec 21, 2025
Copilot AI requested a review from hsluoyz December 21, 2025 12:43
@hsluoyz hsluoyz force-pushed the master branch 3 times, most recently from c622095 to b190fce Compare January 6, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] improve enforcement performance

3 participants