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

Use petgraph inside DefaultRoleManager to model relations #293

Merged
merged 2 commits into from
Jun 16, 2022

Conversation

kbalt
Copy link
Contributor

@kbalt kbalt commented May 12, 2022

This relation model is built after the Go implementation, but uses edges inside the graph to model relations instead of having each role store pointers in maps.

Edges with the EdgeVariant::Link are relations which in Go are modeled by the roles and users map.
Edges with the EdgeVariant::Match are relations which is Go are modeled by the matched and matchedBy map.

This change brings significant speedups in benchmarks when compared against the master branch.

This relation model is built after the Go implementation, but uses
edges inside the graph to model relations instead of having each
role store pointers in maps.

Edges with the `EdgeVariant::Link` are relations which in Go are modeled by the
`roles` and `users` map.
Edges with the `EdgeVariant::Match` are relations which is Go are modeled by the
`matched` and `matchedBy` map.

This change brings significant speedups in benchmarks when compared against the master branch.

Co-authored-by: valkum <r.floren@heinlein-video.de>
@casbin-bot
Copy link
Member

@smrpn @hackerchai @PsiACE @GopherJ please review

@CLAassistant
Copy link

CLAassistant commented May 12, 2022

CLA assistant check
All committers have signed the CLA.

@hsluoyz
Copy link
Member

hsluoyz commented May 12, 2022

@kbalt fix:

image

@hsluoyz
Copy link
Member

hsluoyz commented May 12, 2022

@PsiACE

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #293 (c111b47) into master (41db260) will increase coverage by 0.49%.
The diff coverage is 93.72%.

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   81.02%   81.52%   +0.49%     
==========================================
  Files          23       23              
  Lines        3342     3480     +138     
==========================================
+ Hits         2708     2837     +129     
- Misses        634      643       +9     
Impacted Files Coverage Δ
src/adapter/file_adapter.rs 61.45% <0.00%> (+0.63%) ⬆️
src/rbac/default_role_manager.rs 96.29% <95.23%> (-1.83%) ⬇️
src/rbac_api.rs 89.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41db260...c111b47. Read the comment docs.

@PsiACE
Copy link
Contributor

PsiACE commented May 12, 2022

Great, thank you very much for your contribution! I will check it tomorrow, can you let ci pass first?

@kbalt
Copy link
Contributor Author

kbalt commented May 30, 2022

@PsiACE Any updates on this?

@PsiACE
Copy link
Contributor

PsiACE commented May 30, 2022

@PsiACE Any updates on this?

I apologise for some changes in my role that caused me to forget to give feedback earlier.

The PR looks great and I will be approving it. But before we merge, I'd like @hackerchai to help review it again.

@greenhandatsjtu
Copy link
Contributor

LGTM

@PsiACE PsiACE merged commit 4a661f3 into casbin:master Jun 16, 2022
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.

None yet

6 participants