casbin / casbin-rs

An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
https://casbin.org
Apache License 2.0
861 stars 74 forks source link

perf: use parking_lot::RwLock #260

Closed PsiACE closed 3 years ago

PsiACE commented 3 years ago

parking_lot::RwLock performs better than std::sync::RwLock in most benchmarks.

Since parking_lot has been indirectly dependent, there is no need to sacrifice compilation time.

PsiACE commented 3 years ago

Ah oh, I forgot to fix the tests, please wait a moment .

GopherJ commented 3 years ago

LGTM, can you also put a bench mark number?

codecov[bot] commented 3 years ago

Codecov Report

Merging #260 (f73c447) into master (95d6e17) will decrease coverage by 0.15%. The diff coverage is 96.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #260      +/-   ##
==========================================
- Coverage   79.99%   79.83%   -0.16%     
==========================================
  Files          22       22              
  Lines        3429     3387      -42     
==========================================
- Hits         2743     2704      -39     
+ Misses        686      683       -3     
Impacted Files Coverage Δ
src/cached_enforcer.rs 4.16% <ø> (ø)
src/model/default_model.rs 92.58% <ø> (ø)
src/model/assertion.rs 56.33% <83.33%> (-3.92%) :arrow_down:
src/rbac_api.rs 94.04% <97.77%> (-0.16%) :arrow_down:
src/enforcer.rs 85.54% <100.00%> (ø)
src/macros.rs 50.00% <100.00%> (ø)
src/rbac/default_role_manager.rs 93.63% <100.00%> (+0.63%) :arrow_up:

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 95d6e17...f73c447. Read the comment docs.

PsiACE commented 3 years ago

@GopherJ

sample

Benchmarking benchmark_raw: Collecting 100 samples in estimated 5.0000 s (463M                                                                                benchmark_raw           time:   [10.885 ns 11.116 ns 11.338 ns]
                        change: [+7.7891% +8.9840% +10.274%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 22 outliers among 100 measurements (22.00%)
  2 (2.00%) low severe
  1 (1.00%) low mild
  6 (6.00%) high mild
  13 (13.00%) high severe

Benchmarking benchmark_basic_model: Collecting 100 samples in estimated 5.0151                                                                                benchmark_basic_model   time:   [5.8741 us 5.8890 us 5.9069 us]
                        change: [+7.5016% +7.8456% +8.1929%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 5 outliers among 100 measurements (5.00%)
  4 (4.00%) high mild
  1 (1.00%) high severe

Benchmarking benchmark_rbac_model: Collecting 100 samples in estimated 5.0405 s                                                                               benchmark_rbac_model    time:   [10.014 us 10.046 us 10.084 us]
                        change: [-4.1556% -2.6800% -1.2908%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  3 (3.00%) high mild
  4 (4.00%) high severe

Benchmarking benchmark_role_manager_small: Collecting 100 samples in estimated                                                                                benchmark_role_manager_small                        
                        time:   [49.360 us 49.433 us 49.513 us]
                        change: [-15.583% -14.335% -13.136%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  2 (2.00%) high mild
  2 (2.00%) high severe

Benchmarking benchmark_role_manager_small #2: Collecting 100 samples in estimat                                                                               benchmark_role_manager_small #2                        
                        time:   [123.86 us 124.18 us 124.52 us]
                        change: [-7.6496% -5.5435% -3.8255%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high severe

Benchmarking benchmark_role_manager_large: Collecting 100 samples in estimated                                                                                benchmark_role_manager_large                        
                        time:   [5.4921 ms 5.5407 ms 5.5958 ms]
                        change: [-22.112% -20.441% -18.595%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 18 outliers among 100 measurements (18.00%)
  12 (12.00%) high mild
  6 (6.00%) high severe

Benchmarking benchmark_role_manager_medium: Collecting 100 samples in estimated                                                                               benchmark_role_manager_medium                        
                        time:   [489.76 us 490.67 us 491.84 us]
                        change: [-11.754% -11.168% -10.599%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  6 (6.00%) high mild
  6 (6.00%) high severe

Benchmarking benchmark_rbac_model_medium: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 6.3s, enable flat sampling, or reduce sample count to 60.
Benchmarking benchmark_rbac_model_medium: Collecting 100 samples in estimated 6                                                                               benchmark_rbac_model_medium                        
                        time:   [1.2290 ms 1.2320 ms 1.2350 ms]
                        change: [+1.3989% +2.1883% +3.1067%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) high mild
  6 (6.00%) high severe

Benchmarking b_benchmark_rbac_model_large: Collecting 100 samples in estimated                                                                                b_benchmark_rbac_model_large                        
                        time:   [13.557 ms 13.607 ms 13.661 ms]
                        change: [-9.3406% -7.4781% -5.8936%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  8 (8.00%) high mild
  3 (3.00%) high severe

Benchmarking benchmark_rbac_with_resource_roles: Collecting 100 samples in esti                                                                               benchmark_rbac_with_resource_roles                        
                        time:   [7.2379 us 7.2535 us 7.2699 us]
                        change: [-9.7487% -8.9238% -8.1440%] (p = 0.00 < 0.05)
                        Performance has improved.

Benchmarking benchmark_rbac_model_with_domains: Collecting 100 samples in estim                                                                               benchmark_rbac_model_with_domains                        
                        time:   [9.6038 us 9.6272 us 9.6554 us]
                        change: [-3.0848% -2.4865% -1.9689%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  1 (1.00%) high mild
  8 (8.00%) high severe

Benchmarking benchmark_abac_model: Collecting 100 samples in estimated 5.0015 s                                                                               benchmark_abac_model    time:   [4.4193 us 4.4254 us 4.4317 us]
                        change: [-2.5934% -1.7307% -0.9038%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high severe

Benchmarking benchmark_key_match: Collecting 100 samples in estimated 5.0530 s                                                                                benchmark_key_match     time:   [21.474 us 21.523 us 21.579 us]
                        change: [-0.0306% +0.5070% +1.1377%] (p = 0.09 > 0.05)
                        No change in performance detected.
Found 11 outliers among 100 measurements (11.00%)
  3 (3.00%) high mild
  8 (8.00%) high severe

Benchmarking benchmark_rbac_with_deny: Collecting 100 samples in estimated 5.02                                                                               benchmark_rbac_with_deny                        
                        time:   [13.705 us 13.722 us 13.738 us]
                        change: [-1.9141% -1.5176% -1.0564%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) high mild
  1 (1.00%) high severe

Benchmarking benchmark priority model: Collecting 100 samples in estimated 5.00                                                                               benchmark priority model                        
                        time:   [6.9144 us 6.9249 us 6.9367 us]
                        change: [-9.3214% -7.0656% -5.2333%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  1 (1.00%) low mild
  1 (1.00%) high mild
  3 (3.00%) high severe