Open
Conversation
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.
Hi, we are using CanCanCan in rails project with 200+ ability rules and there are many pages that do many
can?checks when being rendered. We noticed that thecan?checks take up significant part of our response time.Here is attempt to speed things up. From our testing, the most significant change would be to cache and shorten
subject.ancestorsinalternative_subjectsbut that would be bigger change and might break some edge case usage of this gem so it is not included.As you can see below, speedup varies between 20-70%. Every commit includes different optimization and can be reverted if the change is not ok.
Simple benchmark (which just creates small and big ability class with some classes and checks). It attempts to simulate different types of abilities and workflow but is very basic and definitely could be improved:
Results:
CanCanCan 3.6.0:
These changes: