-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Meetings index in a component optimization #9137
Conversation
42487b0
to
793dfc0
Compare
793dfc0
to
448ffd4
Compare
* develop: Compile SCSS through sass-embedded (#9081) Prevent race condition between prevenTimeout and show modal (#9092) Bump elections dependencies to 0.23.0 (#9140) Reduce d3 bundle size (#9034) Improve wording when casting your vote (#9098) Do not send upcoming meeting notification for hidden or withdrawn meetings (#9134) Fix processes count in processes group title cell (#9087) Fix attachments when called from Cells (#9136) Clarify message to user when checking census (#9112)
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.
@decidim/product Andrés, we have created this PR to improve the server response time in some key pages and improve the First Contentful Paint. It's ready to be reviewed.
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.
I noticed few issues with the cache hash, could you please take a look?
Generally I wouldn't support this kind of changes. I can understand the desire to make the pages to load quicker but these kinds of changes just feel like adding a band aid on top of another band aid.
Another thing is that these kinds of things are very context specific such as:
- Specific to the particular logged in user
- Specific to the selected filters
- Specific to the selected language
- Specific to the selected order
- etc. etc.
This causes millions of potential different combinations in to be added to the cache for each content paint. If each paint accounts for 1kB (for instance, just a number from my head), this cache alone would potentially cause 1GB of accumulated cache size with a million different combinations.
Pushing stuff to the cache is not free, it has a cost. Many configurations use memory-based cache, so we just increased the Decidim RAM need (which is already very high) by 1GB adding this cache.
OK, so you can choose to store the cache on disk. Disk space is basically free right?
That's not completely free either. E.g. in multi-node setups this would cause the cache to accumulate separately on separate machines which itself can cause problems if the same user is served from multiple nodes during different loads. Another issue is that this makes the cache implementation itself run slower as it needs to go through more records and loading millions of records from the disk becomes slow at some point.
This seemingly improves performance as per the metrics if you isolate the tests only for a single user, single node, specific setup, etc. But it may cause issues or worsen the performance under other configurations.
@andreslucena @decidim/product Have you agreed on this approach beforehand?
If you feel this is necessary, we can keep on building the band aid pile until we allocate actual resources to re-think the caching strategy & necessity to show some user-specific stuff in the UI which would greatly reduce the amount of cache hash parameters. Or re-think how that user-specific stuff would be loaded separately in the front-end after the cards are loaded with these sections initially empty.
@@ -111,6 +111,17 @@ def meetings | |||
@meetings ||= paginate(search.result.order(start_time: :desc)) | |||
end | |||
|
|||
def cache_hash | |||
@cache_hash ||= [ |
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.
Please add:
- Current locale
- Current order of items
@ahukkanen you are totally right, and I think some of this user customizations are removed in the new design, where meetings are more compact. That said I'm happy to discard this PR if you feel to until the new design is in place to avoid adding more logic layers that can be simplified later. |
@ferblape If you asked me, I would discard this PR. And exactly for that reason, we hopefully wouldn't need this kind of stuff in the future, i.e. there needs to be a better way to optimize the performance. But I'm not the one pulling the cords here, so let's wait for response from @decidim/product . |
I agree with what you've said, let's discard this. Caching with filtering doesn't work well.
The task that we have pending is just to improve general performance (see #8495). It's tricky because there are some things that probably doesn't make sense to solve as they could be directly related to the UI and the current design, and they will change with the redesign. |
🎩 What? Why?
This PR adds fragment caching to meetings index of a component performance by fragment caching the _meetings partial render
Metrics
Data obtained from appsignal data of staging applicaction, with a component with 48 meetings and pagination with 20 items per page. Time in ms.
The main improvement is observed in the times of action_view
Before optimization
After optimization
📌 Related Issues
Testing
Verify the page loads as before, and maybe in the logs check the cache hit message.
📋 Checklist
🚨 Please review the guidelines for contributing to this repository.
docs/
.📷 Screenshots
Please add screenshots of the changes you're proposing
![Description](URL)