Repository navigation
Conversation
Avoid copying the function map and generating role closures on compiled matcher cache hits. Keep eval expressions bound to the current request. Add request-binding regressions and ACL/RBAC benchmarks. Verified with go vet ./... and go test -race ./... on this branch.
Member
|
Thanks for spotting this. The optimization has been applied in 3bf20dc with a slightly different shape: the function map construction is moved into a shared |
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.
Every enforcement currently copies the function map and allocates role-function closures before checking the compiled matcher cache. When an ordinary matcher is already compiled, those newly built functions are discarded.
This change constructs the function map and role closures only in the expression-compilation branch.
eval()expressions continue to bind the current request on each enforcement, so cached expressions never capture a previous request's parameters. Existing matcher invalidation and role-function cache behavior are preserved. No public API, dependency, or minimum Go version changes.Validation
go vet ./...go test -race ./...with this patch applied independentlyeval()requests and a custom matcher function registered after warmup, including repeated use of the compiled custom matcher.Engine-only benchmarks on Apple M4, macOS arm64, Go 1.26.2, using identical one-rule workloads on base
c92cc6aand the candidate. Decision caching is not enabled; the compiled matcher is warmed before timing. Five samples,-benchtime=500ms -count=5 -cpu=10; figures are medians:These show approximately 28–30% lower enforcement latency for the measured small-policy workloads. They do not predict end-to-end application latency or gains for large policy sets where scanning dominates.
Reproduce with the added benchmarks on both revisions: