Cache block item constructors for block based editors#15264
Merged
Migaroez merged 4 commits intorelease/13.0from Nov 29, 2023
Merged
Cache block item constructors for block based editors#15264Migaroez merged 4 commits intorelease/13.0from
Migaroez merged 4 commits intorelease/13.0from
Conversation
Migaroez
approved these changes
Nov 29, 2023
Contributor
Migaroez
left a comment
There was a problem hiding this comment.
✅ Looks good
✅ Pair testing seems to cover everything.
Contributor
|
This isn't thread safe, see #15421 |
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.
Prerequisites
Description
When block based editors construct their published values, they use a whole lot of reflection and on-the-fly IL generated types to construct their contained block items. In short, they activate a lot of what's going on in
ReflectionUtilities.Unfortunately the reflected results are not cached between requests, even though they can never differ as they are type bound. In fact, the results are not even cached between block based editors, so if two block based editors exist on the same page one or more of the same block types, the reflection is repeated for each editor. This also even applies to nested block editors.
The block editors do cache their published values, but all this reflection will still happen for each "first page render" (and after a page publish). The result is a fair amount of CPU time spent churning reflection:
This PR aims to cache as much of this reflection as possible, so we don't have to do all of this reflection over and over.
Since block items are typed to the individual block based editors, caches must be introduced and isolated for each of them (
BlockListItem<TContent, TSettings>,BlockGridItem<TContent, TSettings>andRichTextBlockItem<TContent, TSettings>respectively).Testing this PR
To test this PR, we must ensure that the Block List, the Block Grid and the Rich Text Editor all continue to work the same for their contained blocks. This means they must work:
...and probably a few other permutations.
It might be best to reach out to @kjac for testing 😆