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

Make inactive nodes mark their children as dirty on setInactive #4397

Merged
merged 2 commits into from
Jul 16, 2018

Conversation

gilberto-torrezan
Copy link
Contributor

This moves the setting of dirty nodes out of the collectChanges method.

When using long-polling push, the client keeps asking for changes from
the server. The server then collects all the changes and sends to the
client. The problem is: a child node is always considered dirty, if
its parent is invisible, and the node is always included in the changes
sent to the client.

Since there's not a single moment where there's nothing to send, the
server keeps sending the changes, and the client keeps asking for the
changes. This creates a busy loop between client and server, which only
ends when the parent node is made visible again.

To prevent this, this patch changes this logic to make the children
nodes only dirty when the parent visibility changes.

Copy link
Contributor

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK but several comments:

-Previously the code has been invoked when needed: if the node has been marked as dirty then it has been remarked again: As a result ONLY dirty nodes participated in the related functionality.

  • Now every change in active state of the parent node causes the traversal of the whole subtree and every descendant node becomes dirty even if it had no any change at all. This obviously affect performance in a bad way. I'm not sure how serious it is: changes are not sent to the client if there is nothing to send anyway ( so excessive dirtyness doesn't create extra server->client communication). But this affects server side (may be acceptable)
  • I don't see how exactly the previous state of the code causes issues. As a result nothing prevents to reintroduce similar code back which returns back the issue you are trying to fix.

So at least I would suggest to make some test which checks that the issue doesn't reappear back: it will also help me to understand what was the original problem with changing dirty flag in the collectChanges method.

This moves the setting of dirty nodes out of the collectChanges method.

When using long-polling push, the client keeps asking for changes from
the server. The server then collects all the changes and sends to the
client. The problem is: a child node is always considered `dirty`, if
its parent is invisible, and the node is always included in the changes
sent to the client.

Since there's not a single moment where there's nothing to send, the
server keeps sending the changes, and the client keeps asking for the
changes. This creates a busy loop between client and server, which only
ends when the parent node is made visible again.

To prevent this, this patch changes this logic to make the children
nodes only dirty when the parent visibility changes.
@gilberto-torrezan gilberto-torrezan force-pushed the gilberto/4353_polling_bug branch from 63ebf08 to ef557a6 Compare July 16, 2018 10:21
@gilberto-torrezan
Copy link
Contributor Author

Have added a test based on the code submitted in the ticket, that reproduces the bug.

@gilberto-torrezan gilberto-torrezan changed the title WIP Make inactive nodes mark their children as dirty on setInactive Make inactive nodes mark their children as dirty on setInactive Jul 16, 2018
Copy link
Contributor

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether this is feasible but generic test for no dirty flag is set inside collectChanges would be good.

Though it's not possible to make such test for every possible case: node should not modify dirty flag not only for itself but may be for any other node......

So may be IT test for this specific case is enough..

@gilberto-torrezan gilberto-torrezan merged commit 0a2147a into master Jul 16, 2018
@gilberto-torrezan gilberto-torrezan deleted the gilberto/4353_polling_bug branch July 16, 2018 11:01
gilberto-torrezan added a commit that referenced this pull request Jul 17, 2018
* Make inactive nodes mark their children as dirty on setInactive

This moves the setting of dirty nodes out of the collectChanges method.

When using long-polling push, the client keeps asking for changes from
the server. The server then collects all the changes and sends to the
client. The problem is: a child node is always considered `dirty`, if
its parent is invisible, and the node is always included in the changes
sent to the client.

Since there's not a single moment where there's nothing to send, the
server keeps sending the changes, and the client keeps asking for the
changes. This creates a busy loop between client and server, which only
ends when the parent node is made visible again.

To prevent this, this patch changes this logic to make the children
nodes only dirty when the parent visibility changes.

Fix #4353
gilberto-torrezan added a commit that referenced this pull request Jul 17, 2018
* Make inactive nodes mark their children as dirty on setInactive

This moves the setting of dirty nodes out of the collectChanges method.

When using long-polling push, the client keeps asking for changes from
the server. The server then collects all the changes and sends to the
client. The problem is: a child node is always considered `dirty`, if
its parent is invisible, and the node is always included in the changes
sent to the client.

Since there's not a single moment where there's nothing to send, the
server keeps sending the changes, and the client keeps asking for the
changes. This creates a busy loop between client and server, which only
ends when the parent node is made visible again.

To prevent this, this patch changes this logic to make the children
nodes only dirty when the parent visibility changes.

Fix #4353
@gilberto-torrezan gilberto-torrezan added this to the 1.1.0.alpha1 milestone Jul 18, 2018
gilberto-torrezan added a commit that referenced this pull request Aug 1, 2018
@gilberto-torrezan gilberto-torrezan mentioned this pull request Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants