Repository navigation
Conversation
decide() caches results per role/resource/privilege after the existence checks. The memo is cleared by every mutator, disabled once any assertion is registered or a name contains a NUL byte, bypassed for an empty privilege and capped at 4096 entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Permission::decide()caches results per role/resource/privilege, aftercheckRole()/checkResource()so exceptions are unchanged. Cleared by all 7 mutators; disabled for the instance once any assertion exists or a role/resource name contains NUL; bypassed for privilege ''; capped at 4096 entries.Why
Menus and templates ask the same
isAllowed()questions many times per request; each walks role and resource inheritance.Measured
10 roles, 30 resources, 200 rules, user with 2 roles, 100 checks (60 % repeats):
User::isAllowed128 -> 52 us,Permission::isAllowed72 -> 20 usEquivalence: 10 000 seeds with mutations, assertions, Resource objects, Principal and voters; identical results.
Details: https://github.com/subnette/rfc-performance/blob/perf/round-2/docs/perf/round-2.md (round 3 numbers measured on current upstream master).
Tests
vendor/bin/tester tests -s -Con master: OK (78 tests)Trade-off to decide: slower when no check repeats.