Do not copy all emojis in recentEmoji getter #340

Merged
floatingghost merged 1 commits from sn0w/akkoma-fe:feature/optimize-recent-emojis into develop 2023-09-25 13:24:13 +00:00
Contributor

Currently the recentEmojis getter performs a concat of rootState.instance.emoji and rootState.instance.customEmoji.
On instances with tons of emojis, this full copy can take forever.

In the case of cofe.rocks, emoji-reacting to a post will cause the browser to spend 7 seconds in Array.prototype.concat followed by a then relatively quick find call (~ 1-2 secs).

This PR changes the code to avoid the copy and instead performs two separate searches.
Profiles of reacting to a post before and after the patch are attached (both with JIT disabled, but enabling JIT only makes the concat about 1-2 secs faster so it doesn't change much).

If the resulting object must be copied in a final step to avoid state issues let me know, I'm not deep enough into Vue to judge that.

Currently the recentEmojis getter performs a concat of `rootState.instance.emoji` and `rootState.instance.customEmoji`. On instances with tons of emojis, this full copy can take forever. In the case of cofe.rocks, emoji-reacting to a post will cause the browser to spend 7 seconds in `Array.prototype.concat` followed by a then relatively quick `find` call (~ 1-2 secs). This PR changes the code to avoid the copy and instead performs two separate searches. Profiles of reacting to a post before and after the patch are attached (both with JIT disabled, but enabling JIT only makes the concat about 1-2 secs faster so it doesn't change much). If the resulting object must be copied in a final step to avoid state issues let me know, I'm not deep enough into Vue to judge that.
sn0w added 1 commit 2023-09-03 14:37:06 +00:00
ci/woodpecker/pr/woodpecker Pipeline was successful Details
6a1409e09b
Do not copy all emojis in recentEmoji getter

yep this seems find, i can't find any obvious state issues so good by me - thanks!

yep this seems find, i can't find any obvious state issues so good by me - thanks!
floatingghost merged commit 58be48d164 into develop 2023-09-25 13:24:13 +00:00
floatingghost deleted branch feature/optimize-recent-emojis 2023-09-25 13:24:13 +00:00
Sign in to join this conversation.
No description provided.