Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoize Authorization.access #364

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Memoize Authorization.access #364

merged 1 commit into from
Dec 2, 2020

Conversation

mike-marcacci
Copy link
Member

Because Authorization.access is called at least once for every entity returned in a request, it is a very hot path. Computing scope intersections is a reasonably expensive operation, and the async nature of the backing entities (grant, user, roles) makes this method relatively slow even when those are memoized and db calls can be avoided.

An executor is already the context used for memoization of database calls, and this expands that to include memoization of calls to Authorization.access.

Because Authorization.access is called at least once for every entity returned in a request, it is a very hot path. Computing scope intersections is a reasonably expensive operation, and the async nature of the backing entities (grant, user, roles) makes this method relatively slow even when those are memoized and db calls can be avoided.

An executor is already the context used for memoization of database calls, and this expands that to include memoization of calls to `Authorization.access`.
@mike-marcacci
Copy link
Member Author

mike-marcacci commented Nov 30, 2020

In local tests, this provides up to a 7x performance improvement when returning long lists not already filtered for access using SQL. Switching relational lists to use SQL would likely yield another ~1.5x performance improvement, but requires significant additional effort. Paginated lists obviously stand to gain even more from translation to SQL, and this continues to be tracked by #220.

@ebrown32 ebrown32 merged commit 1bb8ce8 into master Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants