H-Chris233 commented on PR #422:
URL: https://github.com/apache/casbin-rs/pull/422#issuecomment-5308611948
### Local benchmark verification
Environment: local Windows machine (noisy, ±20–30% run-to-run), 3 alternating
rounds per scenario with `--measurement-time 10`.
| Optimization | Scenario | base `5b382a7` | PR `86e8ccc` | Change |
|---|---|---|---|---|
| ③ static regex | `key_get2` micro-bench (100× samples) | 95.1 µs | 39.7 µs
| **−58%** |
| ③ static regex | `key_match4` micro-bench | 89.3 µs | 50.9 µs | **−43%** |
| ② p_eft index | deny-effect model, 10k policies, full scan | 7.62 ms |
7.12 ms | **−6.5%** |
| ① early return | cached basic/abac cache-hit (`--features cached`) | 453 /
506 ns | 455 / 497 ns | no significant change (within noise) |
Findings:
- **Regex static-fication (③) is real and reproducible**: −43% to −58% on
`key_get2` / `key_match4`. Note it only affects `key_get2` / `key_get3` /
`key_match4` / `key_match5` — `keyMatch2` / `keyMatch3` already used the
pre-existing static `MAT_B` / `MAT_P`, so usual RBAC benchmarks don't
exercise this change (consistent with CI showing no change there).
- **p_eft index (②) gives a small consistent gain (−6.5%)** in a full-scan
deny model with a large policy set; models that break early (the common
`some(where (p.eft == allow))` case) only call `position` 1–3 times, so the
gain is negligible there.
- **The claimed 36–45% on cached cache-hits (①) did not reproduce locally**:
the early return removes `try_into_vec` + a duplicate `cache.get`, worth
~5–15% of the ~450 ns hit path, which is below measurement noise on this
machine. A quieter environment or a dedicated micro-benchmark would be
needed to confirm it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]