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

[Feature] GetImplicitPermissionsForUser optimize 99% latency by avoid using roleManager.hasLinkHelper #1346

Open
csdz opened this issue Dec 17, 2023 · 1 comment

Comments

@csdz
Copy link

csdz commented Dec 17, 2023

model description

pType 'p'

In my rbac policy, ptype 'p' may have same v0 (policyid) among different rules,such as:

--- definition
ptype, policy_id, resource_id, action, effect, condition, tenant (about 13000rules)
--- rules preview
p,p1,*,*,allow,{},o0
p,p2,*,account:*,allow,{},o0
p,p2,*,platform:*,allow,{},o0

pType 'g'

and g ptype has simple model that is:

--- defnition
user_id, policy_id, tenant_id (about 30000 rules)
user_id, group_id, tenant_id (about 1000 rules)
group_id, policy_id, tenant_id (about 5000 rules)
---
g,u123,p1,o0
g,u123,g1,o0
g,g1,p2,o0

matchers

matchers definition is:

m = regexMatch(r.obj, p.obj) && \
regexMatch(r.act, p.act) && \
matchFunc(r.cond, p.cond) && \
g(r.sub, p.sub, r.dom)

performance analyze

called GetImplicitPermissionsForUser takes about 15-20 seconds, and got pprof cpu profile as belows. 80% of time cost is calling function roleManager.hasLinkHelper len(model["p"]["p"].Policy) times:
image

desired solution

GetImplicitPermissionsForUser can fetch policy-role, whose role is relate to policy_id, by GetImplicitRolesForUser firstly, then collect policies which matches policy-role in for-loop.
It's would optimize 99% latency of function GetImplicitPermissionsForUser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants