-
Notifications
You must be signed in to change notification settings - Fork 413
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
Reduce layout thrashing by optimizing dxSTable row creation #2231
Conversation
Thanks, but IMHO instead this patch we need to optimize function dxSTable.prototype.getMaxRows (for example, remove condition 'this.viewRows<this.maxViewRows'). |
Do you think it's a good idea to rewrite this function though? There are other methods which call I investigated your suggestion further and found that |
@Novik Could you review this pull request again? I optimized dxSTable row creation and removed an unnecessary table sort. The results are even more astonishing than before and the code quality is much higher. Benchmarks for theWebUI.addTorrents() The performance penalty is now reduced to approximately 70ms, regardless of the number of torrents. |
And this is not surprising, because really you simple remove DOM filling at the first call of function. I.e. if we will have only one call of addTorrents(), then user will see nothing. |
|
Yes, you are right, through the sequence loadTorrents -> show -> resize -> resizeTop -> dxSTable.resize -> dxSTable.refreshRows. But yet one moment. Pay attention to this fragment, please:
We may have here sIndex !=- 1 (if user press on the column header in the previous session, for example). |
Good catch. I just removed the table sort from the "fast" case. It's only taking about 300ms now to add the torrents, regardless of the number of torrents added to the web client. I think this PR is ready for merge now. |
This resource explains the issue in more detail. ruTorrent was taking 20s to load with 5000 torrents, when I refreshed the page. I ran a profile and found this function was thrashing the layout. After implementing this fix, my loading time was down to 5s.
Benchmarks for theWebUI.addTorrents()
Loading times with 500 torrents are reduced from 800ms to 250ms. Approximately 150ms is a performance penalty.
Loading times with 5000 torrents are reduced from 18s to 1s. Approximately 400ms is a performance penalty.
There is a performance penalty for this fix.
theWebUI.loadTorrents()
must be run afterwards to display the 20 to 30 rows of torrents that will be initially visible to the user. This can no longer be done duringtheWebUI.addTorrents()
. However, as demonstrated above, the page loading speed benefit is greater than the performance penalty, in virtually every situation. The user may see approximately 100ms longer loading times with only 50 torrents. This is relatively small and trivial though.