Conversation
…nuous rerendering
siggy
approved these changes
Sep 10, 2018
| super(props); | ||
| this.tapResultsById = {}; | ||
| this.topEventIndex = {}; | ||
| this.debouncedWebsocketRecvHandler = _.throttle(this.updateTapEventIndexState, 500); |
Member
There was a problem hiding this comment.
TIL _.debounce (and _.throttle)!
what do you think about setting leading: true, to make the initial event pop up immediately after the user hits Start?
_.throttle(this.updateTapEventIndexState, 500, {
'leading': true,
'trailing': false
});
Author
There was a problem hiding this comment.
On throttle, I believe the default value for leading is true. I think the inital delay is the delay in establishing the websocket connection and sending the query.
dadjeibaah
approved these changes
Sep 10, 2018
Contributor
dadjeibaah
left a comment
There was a problem hiding this comment.
Pretty cool fix! The changes are pretty significant. 📦
Contributor
klingerf
approved these changes
Sep 10, 2018
Contributor
klingerf
left a comment
There was a problem hiding this comment.
⭐️ This is awesome! Am going to take the same approach with the tap table.
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.

Problem
We receive a lot of websocket events from the tap server. Previously, we were processing each event as we received it, then calling setState after processing to update the tables. Each call to setState triggered a re-render of the whole table. We were rerendering multiplie times a second, causing the whole page to become unresponsive.
Solution
throttlesetState for receiving websocket tap events to prevent continuous rerendering.Store the tap events in an index outside of state, and only update the state once every specified interval (currently 500ms).
We can now view entire namespaces with Top and the page won't crash!
To verify: Go to
/topand try topping a namespaceFor more reading:
https://css-tricks.com/debouncing-throttling-explained-examples/
https://nolanlawson.com/2018/09/01/a-tour-of-javascript-timers-on-the-web/
Part of #1601