KEMBAR78
Disable auto reload if page is not visible by bmd3k · Pull Request #3483 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@bmd3k
Copy link
Contributor

@bmd3k bmd3k commented Apr 6, 2020

  • Motivation for features / changes
    Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

  • Technical description of changes
    Do not auto reload if document is not visible according to the Page
    Visibility API. When page again becomes visible perform an auto reload
    if one has been missed.

  • Detailed steps to verify changes work correctly (as executed by you)
    Run a local TensorBoard.
    Open localhost:6006.
    Ensure option "Reload data every 30s." is selected.
    Open detached network tab in chrome developer tools.
    Watch for several minutes and observe that many network calls are made every 30s.
    Open different tab in same window but with chrome developer tools still visible.
    Watch for several minutes and observe that no network calls are made.
    Switch back to TensorBoard tab and watch as network calls are immediately made and UI reloads graphs.
    Continue to watch network tab as it again follows a 30s period for reload network calls.

Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
@bmd3k bmd3k changed the title Disable auto reload if page is not visible. Disable auto reload if page is not visible Apr 6, 2020
@bmd3k bmd3k marked this pull request as ready for review April 6, 2020 16:06
@bmd3k bmd3k requested a review from stephanwlee April 6, 2020 16:24
Copy link
Contributor

@stephanwlee stephanwlee left a comment

Choose a reason for hiding this comment

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

FYI: there is a different implementation of autoReloadBehavior on the Angular side. https://github.com/tensorflow/tensorboard/blob/master/tensorboard/webapp/plugins/plugins_component.ts#L162-L172

);
},
_doReload: function() {
if (this.reload == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer triple equals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't write this originally so can't say for sure: But I wouldn't be surprised if the check is purposefully "==" to also catch when this.reload is undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

ACK

window.clearTimeout(this._autoReloadId);
document.removeEventListener(
'visibilitychange',
this._handleVisibilityChange.bind(this)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe bind call creates a new reference and this is not removing the event listener attached at L55.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, yuck. I looked at how some other components handle this and picked what looks like the least-bad option.

Copy link
Contributor

@nfelt nfelt left a comment

Choose a reason for hiding this comment

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

FWIW, would perhaps be good to update the Reload data every 30s. settings panel text to reflect the fact that this is now more complex behavior, e.g. "Reload data every 30s while page is visible" or something?

cc @GalOshri

Copy link
Contributor Author

@bmd3k bmd3k left a comment

Choose a reason for hiding this comment

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

FWIW, would perhaps be good to update the Reload data every 30s. settings panel text to reflect the fact that this is now more complex behavior, e.g. "Reload data every 30s while page is visible" or something?

cc @GalOshri

I am following up with Gal on it. Will send a followup PR if he thinks the message should be updated. My personal opinion is that most people would understand the new behavior without the explanation .

);
},
_doReload: function() {
if (this.reload == null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't write this originally so can't say for sure: But I wouldn't be surprised if the check is purposefully "==" to also catch when this.reload is undefined.

window.clearTimeout(this._autoReloadId);
document.removeEventListener(
'visibilitychange',
this._handleVisibilityChange.bind(this)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, yuck. I looked at how some other components handle this and picked what looks like the least-bad option.

@bmd3k
Copy link
Contributor Author

bmd3k commented Apr 6, 2020

FWIW, would perhaps be good to update the Reload data every 30s. settings panel text to reflect the fact that this is now more complex behavior, e.g. "Reload data every 30s while page is visible" or something?
cc @GalOshri

I am following up with Gal on it. Will send a followup PR if he thinks the message should be updated. My personal opinion is that most people would understand the new behavior without the explanation .

I followed up with Gal. He doesn't think it's necessary to change the existing text.

@bmd3k bmd3k requested a review from stephanwlee April 6, 2020 21:58
@bmd3k bmd3k merged commit c5c5812 into tensorflow:master Apr 7, 2020
@bmd3k bmd3k deleted the autoreload-reduce branch April 8, 2020 16:56
bmd3k added a commit that referenced this pull request Apr 10, 2020
In #3483 I attempted to pause and restart auto reload behavior based on page visibility.

Unfortunately a change I made to event handling just before merging into master inadvertently disabled the logic. The change happened in a seam in the code that was not covered by tests.

This change fixes the event handling and improves the test coverage.
bileschi pushed a commit to bileschi/tensorboard that referenced this pull request Apr 15, 2020
Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
bileschi pushed a commit to bileschi/tensorboard that referenced this pull request Apr 15, 2020
In tensorflow#3483 I attempted to pause and restart auto reload behavior based on page visibility.

Unfortunately a change I made to event handling just before merging into master inadvertently disabled the logic. The change happened in a seam in the code that was not covered by tests.

This change fixes the event handling and improves the test coverage.
bmd3k added a commit that referenced this pull request Apr 15, 2020
Note that this is the ng_tensorboard version of #3483.

* Motivation for features / changes
Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

* Technical description of changes
Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
bileschi pushed a commit that referenced this pull request Apr 15, 2020
Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
bileschi pushed a commit that referenced this pull request Apr 15, 2020
In #3483 I attempted to pause and restart auto reload behavior based on page visibility.

Unfortunately a change I made to event handling just before merging into master inadvertently disabled the logic. The change happened in a seam in the code that was not covered by tests.

This change fixes the event handling and improves the test coverage.
caisq pushed a commit to caisq/tensorboard that referenced this pull request May 19, 2020
…low#3498)

Note that this is the ng_tensorboard version of tensorflow#3483.

* Motivation for features / changes
Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

* Technical description of changes
Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
caisq pushed a commit that referenced this pull request May 27, 2020
Note that this is the ng_tensorboard version of #3483.

* Motivation for features / changes
Reduce the load on TensorBoard servers by disabling auto reload if the page is not considered visible.

* Technical description of changes
Do not auto reload if document is not visible according to the Page
Visibility API. When page again becomes visible perform an auto reload
if one has been missed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants