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

More fine grained dirty marking #425

Open
emilsjolander opened this issue Feb 22, 2017 · 1 comment
Open

More fine grained dirty marking #425

emilsjolander opened this issue Feb 22, 2017 · 1 comment

Comments

@emilsjolander
Copy link
Contributor

Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent.

This change has the potential of greatly improving performance of re-calculating a tree.

This might require adding a second dirty flag named hasDirtyChildren ensuring that traversal still works even though a parent is not marked as dirty.

@arcanis
Copy link
Contributor

arcanis commented Feb 22, 2017

I've worked on something similar for mylittledom; at first I tried to only traverse children that were marked as dirty, but the issue was that a dirty node would possibly not only affect its children, but also its siblings (except when absolutely positioned, but it's often not the case, so the optimization would not affect the hot path and would probably make it slower). The algorithm I went with is to always cascade the layout on both dirty nodes and on any children of a node that has at least one dirty children, but to stop the cascading if such a node (which isn't explicitely marked as dirty) does not change its layout.

My implementation is here if you want to give it a look: https://github.com/manaflair/mylittledom/blob/master/sources/core/dom/Element.js#L776-L842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants