-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Initial tag load performance improvement #87
Conversation
I'm assuming that on clicking a parent tag the child tags will get loaded in? (I haven't had time to test locally) |
This is definitely not ready for merge. When clicking on a tag, only those with existing discussions that load appear (because they are included in the /api/discussions response - we could improve performance times by not including already-loaded tags in API response, not sure if possible). Sometimes a second child tag appears under another tag - not sure why that one is loaded 🤔. |
Iirc, there isn't currently a call to the tags endpoint in the tags frontend (at least not on the tags page I think)? How are additional tags being loaded? Also, I'm still confused why the tag states can't be loaded alongside the tags themselves in a single query. I'm in favor of not loading everything at once for reasons of scalability and reducing payload size, but I think the multiple queries thing is the bigger issue when it comes to performance. Does it still occur when no extensions other than core and tags are enabled? |
@askvortsov1 Additional tags are only loaded when a discussion has the tag. |
Hm, right I didn't look far enough beyond the first page. Will look into that. |
Also, if the page we're on IS the page for a parent tag (which is possible via custom homepages), perhaps we should load those too? |
@askvortsov1 Well it'd also be a parent tag if you directly visit /t/. I think this should also be extensible. |
@datitisev what exactly do you mean with extensible? What should be extensible? |
@luceos 🤔 i don't know. I assume deciding which tags get loaded, because of this comment I was replying to:
|
My pr adds a ShowTagController to load one tag through the api. The parent include (relation) already existed, I've added |
This code drops the sub tags so that forums with many tags wont load the state unecessarily for each sub tag. I've attempted to load only the 3 tags with most discusssions withCount(), but the issue is that the subquery doesn't allow using a limit in MySQL. We can further improve this logic, but that requires discussion. Please note that specific tag pages aren't affected because they have their own logic!
d4c4c84
to
9157cef
Compare
TODO: Add tag loading logic for the composer and selection modal. I feel like this could also use pagination, but I think that might be better in a separate PR after we get @datitisev's PaginatedList utils class merged. |
Current setup: ~50 top level primary tags Load differences:
This still feels way too slow, especially the regular discussion / discussion list pages (with no tags, they load in ~200ms). Also, some logic issues are still present with load. Taking this back into draft mode. |
And back out of draft |
Co-authored-by: Sami Mazouz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, nice work!
- Only load lastPostedDiscussion on TagsPage - For forum payload, only load top-level primary tags and top 3 secondary tags. - In other cases, load tags in dynamically when needed. Co-authored-by: Alexander Skvortsov <[email protected]> Co-authored-by: Sami Mazouz <[email protected]>
- Only load lastPostedDiscussion on TagsPage - For forum payload, only load top-level primary tags and top 3 secondary tags. - In other cases, load tags in dynamically when needed. Co-authored-by: Alexander Skvortsov <[email protected]> Co-authored-by: Sami Mazouz <[email protected]>
Links flarum/framework#2177
Current situation
On hitting the Forum index, the ShowForumController gets its payload enriched from
flarum/tags
:tags/src/Listener/AddForumTagsRelationship.php
Lines 53 to 56 in 164d67b
This code loads all tags and some of its relations. For small forums this isn't really an issue. But forums that have a ton of subtags this affects performance.
New situation
I've decided to exclude subtags, but include helper tags. The helper tags are limited to three, unless you click "more tags" which redirects you to the tags page. We could potentially improve this logic further by only including the 3 tags with the most discussions (
withCount('discussions')
), but that would need some optimalization as subqueries can't uselimit
in MySQL.I am currently deploying this branch to the Bokt staging environment.Query count reduction in Bokt staging: 411 to 52. 163 tags.