Iridium icon indicating copy to clipboard operation
Iridium copied to clipboard

Improve json recursive performance

Open ParticleCore opened this issue 1 year ago • 2 comments

Currently there are a few operations that take a performance hit that is noticeable due to brief UI lockups, these mostly occur when the comment section is loading, which can contain a significant amount of data, and deep hierarchy.

In multiple sections of the extension the root path is being passed arbitrarily, meaning the recursive function has to traverse the entire json tree even when it might not be of interest for the function using it.

Ideally this should be substituted by a specific prior root path check to ensure the data is of interest of the function, for example: https://github.com/ParticleCore/Iridium/blob/a5b58a38c84299776a0388e057e0494a88543775/src/firefox/js/background-inject.js#L254-L259

Problem is this might introduce bugs because there might be multiple paths for the same root and all must be covered, for example a multi-path deep node: https://github.com/ParticleCore/Iridium/blob/a5b58a38c84299776a0388e057e0494a88543775/src/firefox/js/background-inject.js#L2707-L2708

However, the performance impact is noticeable so this must be improved in one way or another.

ParticleCore avatar Apr 17 '24 21:04 ParticleCore

Issue seems more evident when the user is logged in, especially when loading the comment section. If the user is not logged in, there are no performance issues. This indicates that the comment payloads when logged in are significantly bigger.

The difference in seconds for processing the comment section payload when not logged in vs logged in is respectively 0.102s and 3.2s (according to a few random tests).

ParticleCore avatar May 02 '24 01:05 ParticleCore

Things have been busy lately, and I have yet to find a good way to go about this so I will likely compromise on just excluding any results that are related to the comment section for now and think of a different way to go about it in the future.

ParticleCore avatar May 12 '24 23:05 ParticleCore

Seems like the major issue of the performance problems are restricted to the comments section, so I will just exclude them from processing. It seems like it does not affect any other functionality so there aren't any known compromises.

ParticleCore avatar Sep 11 '24 22:09 ParticleCore

Chrome (129.0.6668.42) running Iridium 2.1.1 still seems to get un-responsive while loading comments. Though only on the 2nd set of comments loading per-video onwards.

As in: Initial video load, and scrolling down to comments will load fast and smoothly. But scrolling down more until it loads more comments gets un-responsive and slow, like the old version did.

LazyBoot avatar Sep 19 '24 00:09 LazyBoot

@LazyBoot Can you open a new issue for that one? In might have missed something else in the logic I implemented for this one that must be different for subsequent loads.

ParticleCore avatar Sep 19 '24 03:09 ParticleCore

Done, opened as #1005

LazyBoot avatar Sep 19 '24 19:09 LazyBoot