Skip to content

perf: Performance Enhancement - #144

Merged
hsluoyz merged 2 commits into
apache:masterfrom
lezli01:performance_enhancement
Aug 23, 2021
Merged

perf: Performance Enhancement#144
hsluoyz merged 2 commits into
apache:masterfrom
lezli01:performance_enhancement

Conversation

@lezli01

@lezli01 lezli01 commented Aug 16, 2021

Copy link
Copy Markdown
Contributor

Fix: #143

  • Having the list of functions growing with every enforcement makes the context creation slower and slower, every enforcement is linearly slower than the previous.

  • Having a 100k string vector reserved makes enforcement very slow and it is invaluable.

@lezli01
lezli01 force-pushed the performance_enhancement branch from c88c7e2 to 83f066b Compare August 16, 2021 11:06
@lezli01 lezli01 changed the title Performance enhancement performance_enhancement Aug 16, 2021
Comment thread casbin/util/split.cpp Outdated
@lezli01
lezli01 force-pushed the performance_enhancement branch from a08cac4 to 2bbbd76 Compare August 16, 2021 11:20

@EmperorYP7 EmperorYP7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks for pointing it out and creating a PR 😄

By the way, we use semantic pull requests for this project, so you might want to sign-off all your commits and change the title to something like:

chore: Performance Enhancement

@lezli01 lezli01 changed the title performance_enhancement chore: Performance Enhancement Aug 16, 2021
@lezli01
lezli01 force-pushed the performance_enhancement branch from 2bbbd76 to e845107 Compare August 16, 2021 11:38
Laszló Szabó added 2 commits August 16, 2021 13:42
Signed-off-by: Laszló Szabó <lszabo@us.opswat.com>
Signed-off-by: Laszló Szabó <lszabo@us.opswat.com>
@lezli01
lezli01 force-pushed the performance_enhancement branch from e845107 to b9c3705 Compare August 16, 2021 11:42
@lezli01 lezli01 changed the title chore: Performance Enhancement perf: Performance Enhancement Aug 16, 2021
@lezli01
lezli01 requested a review from EmperorYP7 August 16, 2021 14:12

@EmperorYP7 EmperorYP7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@hsluoyz

hsluoyz commented Aug 16, 2021

Copy link
Copy Markdown
Member

@EmperorYP7

Copy link
Copy Markdown
Contributor

plz fix: https://github.com/casbin/casbin-cpp/pull/144/checks?check_run_id=3340218672

@hsluoyz I think we should re-trigger the CI as it was interrupted due to reasons outside the scope of the project. (Maybe something’s up with GH Actions)

@lezli01

lezli01 commented Aug 16, 2021

Copy link
Copy Markdown
Contributor Author

@lezli01 plz fix: https://github.com/casbin/casbin-cpp/pull/144/checks?check_run_id=3340218672

Yeah it seems something off with CI, my changes should not change behaviour, only increase performance.

@lezli01

lezli01 commented Aug 17, 2021

Copy link
Copy Markdown
Contributor Author

I checked it multiple times, it is working locally.

2021-08-17T06:47:20+02:00
Running D:\projects\casbin-cpp\build\tests\benchmarks\casbin_benchmark.exe
Run on (8 X 3000 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x8)
  L1 Instruction 32 KiB (x8)
  L2 Unified 256 KiB (x8)
  L3 Unified 12288 KiB (x1)
------------------------------------------------------------------------------------
Benchmark                                          Time             CPU   Iterations
------------------------------------------------------------------------------------
BenchmarkRaw                                   0.441 ns        0.438 ns   1000000000
BenchmarkBasicModel                           447698 ns       444984 ns         1545
BenchmarkRBACModel                            696869 ns       683594 ns         1120
BenchmarkRBACModelSmall                      4464868 ns      4492188 ns          160
BenchmarkRBACModelMedium                    40686959 ns     40441176 ns           17
BenchmarkRBACModelWithDomains                 724854 ns       714983 ns          896
BenchmarkKeyMatchModel                        675957 ns       683594 ns         1120
BenchmarkRBACModelWithDeny                    715132 ns       714983 ns          896
BenchmarkPriorityModel                        676896 ns       669643 ns         1120
BenchmarkCachedBasicModel                        147 ns          148 ns      4977778
BenchmarkCachedRBACModel                         146 ns          148 ns      4977778
BenchmarkCachedRBACModelSmall                    150 ns          146 ns      4480000
BenchmarkCachedRBACModelWithResourceRoles        147 ns          148 ns      4977778
BenchmarkCachedRBACModelWithDomains              161 ns          164 ns      4480000
BenchmarkCachedKeyMatchModel                     236 ns          231 ns      3446154
BenchmarkCachedRBACModelWithDeny                 149 ns          146 ns      4480000
BenchmarkCachedPriorityModel                     147 ns          148 ns      4977778
BenchmarkVectorOperations                        156 ns          157 ns      4480000
BenchmarkHasPolicySmall                        17733 ns        17648 ns        40727
BenchmarkHasPolicyMedium                      180033 ns       180303 ns         4073
BenchmarkHasPolicyLarge                      1784243 ns      1801273 ns          373
BenchmarkAddPolicySmall                       237140 ns       237165 ns         8960
BenchmarkAddPolicyMedium                      459813 ns       463846 ns         2358
BenchmarkAddPolicyLarge                      1778339 ns      1759383 ns          373
BenchmarkRemovePolicySmall                       370 ns          377 ns      1947826
BenchmarkRemovePolicyMedium                   169050 ns       168795 ns         4073
BenchmarkRemovePolicyLarge                   1795674 ns      1801273 ns          373
BenchmarkRoleManagerSmall                      10806 ns        10882 ns        74667
BenchmarkRoleManagerMedium                    124498 ns       125558 ns         5600

@lezli01

lezli01 commented Aug 21, 2021

Copy link
Copy Markdown
Contributor Author

Is it hanging?

@hsluoyz

hsluoyz commented Aug 21, 2021

Copy link
Copy Markdown
Member

@EmperorYP7

@EmperorYP7

Copy link
Copy Markdown
Contributor

@hsluoyz kindly re-run all jobs under GitHub Actions for this PR.

@EmperorYP7

Copy link
Copy Markdown
Contributor

This is ready to be merged now.

@hsluoyz
hsluoyz merged commit 8891fa9 into apache:master Aug 23, 2021
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.38.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance issues

3 participants