fixes performance regression with AR relations#34503
Closed
gingerlime wants to merge 1 commit intorails:masterfrom
Closed
fixes performance regression with AR relations#34503gingerlime wants to merge 1 commit intorails:masterfrom
gingerlime wants to merge 1 commit intorails:masterfrom
Conversation
* After introducing cache versioning, even with cache versioning off there's a performance regression when passing an Active Record relation to cache * This happens in ActiveSupport::Cache inside `normalize_version` * This method would check if the relation responds to cache_version and if not, would recrusively normalize it with `to_a` * This would lead to the relation being retrieved from database and enumerated, causing the performance regression * This fix simply adds `cache_version` returning `nil` to Active Record relations * This is a temporary stopgap, until relation cache versioning is implemented. See rails#34378
Member
|
Thank you for the PR. We prefer to not implement stopgap solutions in the codebase. Let's wait for #34378 |
Contributor
Author
|
This bug can cause quite severe performance regression from my experience, and it largely goes unnoticed, unless you actively measure performance. Hope that #34378 gets merged quickly and also backported, to fix existing versions of rails affected by this regression. |
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.
there's a performance regression when passing an Active Record
relation to cache
normalize_versionand if not, would recrusively normalize it with
to_aenumerated, causing the performance regression
cache_versionreturningnilto Active Recordrelations
implemented. See collection cache versioning #34378