-
Notifications
You must be signed in to change notification settings - Fork 263
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
perf: reduce number of avatar requests #10486
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Hamza Mahjoubi <[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.
Quick review
I broke RecipientBubble 😨, converting to draft |
Signed-off-by: Hamza Mahjoubi <[email protected]>
The avatar controller and frontend service are still needed for Recipient bubble (Thread.vue) , because the message object contains only from's avatar ( to, cc, bcc ) still need to be fetched , and assuming that we need them and pre-fetching is counterproductive because we can't assume that all threads are gonna be opened |
Signed-off-by: Hamza Mahjoubi <[email protected]>
Signed-off-by: Hamza Mahjoubi <[email protected]>
Signed-off-by: Hamza Mahjoubi <[email protected]>
How will this handle worst case scenarios? Imagine you load 20 messages and each of them is sent by someone else, and there is no contacts picture so gravatar favicon sources are tapped. These make external HTTP requests that could take several seconds, e.g. when the favicon request times out because the domain does not correspond to a HTTP server. Will this slow down the loading of messages? If so, we have to fine-tune the approach. Let me know, I have some ideas. |
So I did a little benchmarking and here are the results Main
This branch
Doesn't look like a good approach |
Okay, that is what I was afraid of. Then we do it like follows: check the cache for an avatar URL. If it exists, attach it to the recipient. Also attach a false if there is one, it indicates that there is no avatar for the user. This means that the initial loading with empty cache is still done in many requests, but those help us offload the slow fetching into async operations that don't block the main app functionality. For page reloads, mailbox switches, messages of senders seen previously etc we will preload the avatar URLs and save some requests. |
Signed-off-by: Hamza Mahjoubi <[email protected]>
Signed-off-by: Hamza Mahjoubi <[email protected]>
I'm not sure how to return a 3rd state "elegantly" ( Avatar => avatar exists , null => avatar doesn't exist, ? => we want to fetch it from the frontend) |
No description provided.