-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Dynamic caching in Mapper
for better performance
#17586
base: master
Are you sure you want to change the base?
Conversation
…prove view-to-model mapping performance, and as a result improve editor load and data save performance.
This PR introduces caching in I included a lot of explanations in the API docs and inline comments, so go through the PR to learn more. My main assumptions were:
I decided to implement it fully inside Other options I considered were:
I decided that making it directly in Possible improvement that occured to me at later point, and I didn't try it. Maybe it would be easier to understand and simpler to implement if each traversed node kept total |
…rCache` are always "top-most" possible positions for given model offset. Delete entires from `MapperCache#_nodeToCacheListIndex`.
Ready for re-review. |
Okay I didn't notice TS failed in other places -_-. |
I reverted some of the changes as they were breaking changes. This is the best I could do without running into more issues. |
…hoistViewPosition()`. In some cases, we need to go "go up" in `Mapper#_findPositionStartingFrom()`.
Looks like there's a memory leak in the mapper cache. Consecutive |
I fixed the error in API docs and also fixed the memory leak problem. We cannot be sure if Another way to go would be to use Unfortunately, The problem is that I needed to assign the class methods to properties, so that we can call On the side note, I am not sure if we need But I am afraid that it may be necessary to prevent some errors? OTOH, it's very unlikely. We stop tracking after view element is unbound in mapper, so the view element at this point is no longer used, most probably. In theory something might "happen" inside it, but probably not, and even if, then |
On the other note, I can see that memory grows anyway, around 0.2 MB after every |
Fixes in code style and API docs.
Suggested merge commit message (convention)
Other (engine): Introduced dynamic caching in
Mapper
in order to improve view-to-model mapping performance, and as a result improve editor load and data save performance. Closes #17623.Other (engine): New parameter
data
was added forchange:children
event fired byViewElement
andViewDocumentFragment
when their children change.data
is an object withindex
property, which says at which index the change happened. Related to #17623.Other (engine):
Mapper#registerViewToModelLength()
is now deprecated and will be removed in one of upcoming releases. Note: if this method is used, the caching mechanism forMapper
will be turned off which may degrade performance when handing big documents. Note: this method is used by the deprecated legacy lists feature. See #17623.MINOR BREAKING CHANGE (engine):
Mapper#registerViewToModelLength()
is now deprecated and will be removed in one of the upcoming releases. This method is useful only in obscure and complex converters, where model element, or a group of model elements, are represented very differently in the view. We believe that every feature that uses custom view-to-model length callback can be rewritten in a way that this mechanism is no longer necessary. Note: if this method is used, the caching mechanism forMapper
will be turned off which may degrade performance when handing big documents. Note: this method is used by the deprecated legacy lists feature.