elementary / elementary/calendar
Slow month switching with many events
- Dominant language
- Vala
- Stars
- 136
- Forks
- 42
- Avg merge
- 8h 33m
- Merged PRs (30d)
- 3
Description
## Prerequisites
- [x] I have searched open and closed issues for duplicates.
## Describe the bug
Also reported in #623, but reporting here to track separately.
When switching months with many events, it stutters and takes a long time to populate. It's over a second for me, on an i7 XPS 13, which should be fairly fast. I would say I have an average of 5 events per weekday, so that would be probably around 25-30 events total. When I page to these months, the animation doesn't play at all.
### To Reproduce
Steps to reproduce the behavior:
1. Create a lot of events in a single month, at least 3 or 4 per day (the number will vary by machine of course, but it doesn't need to be that many to see)
2. Switch to a different month and back.
3. Returning to the original month will be slow like I described. The animation won't play for a while, and in my case events keep populating after the switch.
### Expected behavior
Switching should be smooth. Ideally events would appear instantaneously, but that's less important.
### Logs
I tried a few times to page back and forth and run it through a profiler. Here are some results (note from different runs):
- [`gprof` results](https://gist.github.com/mcclurgm/b9275afdc8405d7275bda03d0a401fce)
- A `perf` run that I generated a flame graph for using Hotspot:

## Platform Information

- [x] I'm using the latest version from git that I've manually compiled (latest that supports Hera)
- [ ] I'm using the latest released stable version
## Additional context
Of course, this isn't something that can be "fixed" clearly, but I'm opening this to make it sorta trackable and hope my findings are useful to others. I'm currently working on reducing the work done by `calendar_util_component_is_on_day`, but this is not nearly enough to get it to run smoothly. There's going to be a fair bit more to be done until this runs quickly, especially on slower hardware.
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/95452401-slow-month-switching-with-many-events?utm_campaign=plugin&utm_content=tracker%2F60388692&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F60388692&utm_medium=issues&utm_source=github).
Contributor guide
Assessment
This issue has not been assessed yet.