Do not copy all emojis in recentEmoji getter #340

Merged
floatingghost merged 1 commit 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
Do not copy all emojis in recentEmoji getter
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
6a1409e09b

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
mel referenced this pull request from a commit 2024-05-15 22:36:01 +00:00
Sign in to join this conversation.
No description provided.