diff options
| author | Matt Goldspink <mattgoldspink1@gmail.com> | 2023-02-19 15:08:07 -0800 |
|---|---|---|
| committer | Matt Goldspink <mattgoldspink1@gmail.com> | 2023-02-19 15:08:07 -0800 |
| commit | afc65fb07a55ca4853be335e34f4846bf364a5ca (patch) | |
| tree | f07e74d49265b15b95060e4c12a08eb585c1d21e /src/slskd/Core/API/Controllers/OptionsController.cs | |
| parent | 53e7204c4bd2531ae4da883d5b6dc018817a0aa9 (diff) | |
| download | slskd-afc65fb07a55ca4853be335e34f4846bf364a5ca.tar.gz | |
Trying to speed up the performance of the Browse tab.
It looks like there's a couple of issues with the current implementation which shows in Performance tab in Chrome:
1) getChildDirectories and in particular the split function. When you look at the code we're doing 3 filters on a reduced array each time, but always starting with the full list of directories. So for every child directory we iterate once over the entire array of all directories to remove 1 item, then for n-1 items we split them, then we find the ones who start with the parent path name. This is very inefficient.
To fix this I added one first iteration that will split the names on them all once and use that depth as a key into a Map and store an Array of the items at that depth. We could possibly go one step further and iterate the array store the d.name split on the last index of the seperator as a key to speed this up? But the new version is already orders of magnitude faster
2) The compression on saveState into localStorage is slow and blocking the UI thread. Given that the saveState doesn't affect the actual state in the component or whats rendered I've moved it out of the current tick of rendering and shifted it in most browsers to be done when the screen is idle (i.e. user is not doing anything). Or in the case of Safari falling back to the next tick.
This dropped render time for on one user with 6000+ directories from 1 minute to around 15s, of which a large chunk is the server calls.
Fixes #317
Diffstat (limited to 'src/slskd/Core/API/Controllers/OptionsController.cs')
0 files changed, 0 insertions, 0 deletions
