For recurring events, skip calculating occurrences if they're known to be outside the date range requested
Categories
(Calendar :: Provider: Local Storage, enhancement)
Tracking
(Not tracked)
People
(Reporter: darktrojan, Assigned: darktrojan)
References
Details
(Keywords: perf)
Attachments
(1 file, 1 obsolete file)
|
27.59 KB,
patch
|
Fallen
:
review+
|
Details | Diff | Splinter Review |
When calling getItems on a calendar, occurrences are calculated for every recurring event, to see if there are any between aRangeStart and aRangeEnd. This is a waste of time in a lot of cases, because we can know that there are no occurrences. For example, past events that have stopped recurring.
| Assignee | ||
Comment 1•6 years ago
|
||
Philipp what do you think of this? It's more a proof of concept than a finished patch, but it demonstrates what I have in mind.
The idea is that the last possible date is remembered (from the first call to getItems at this stage) and used to ignore the items in subsequent calls to getItems. This could be extended further: the current calculation is not as good as it could be, and I think we could go as far as storing the information in the database and not even retrieving irrelevant items from it.
In the limited testing I've done with this patch it is a good performance win.
| Assignee | ||
Comment 2•6 years ago
|
||
In the limited testing I've done with this patch it is a good performance win.
It really depends on what's in your calendars but I've seen this take a third off the time taken to go back or forward in the month view.
Comment 3•6 years ago
|
||
I seem to recall the "previous" iterator wasn't very efficient, maybe double check the implementation? You should also check the edge cases of different rules, e.g. using COUNT or UNTIL.
The other thing we could do to speed this up, I have some code that is super fast and is capable of returning all occurrences within a specified interval, though no getting next/previous occurrences. It isn't my code but the author has indicated he'd be willing to re-license if necessary.
| Assignee | ||
Comment 4•6 years ago
|
||
I'm not really interested yet in how we calculate the last occurrence, as long as it's right.
| Assignee | ||
Comment 5•6 years ago
|
||
Even with a poorly performing implementation, this provides such an improvement I think it's worth having. I've changed it so that only immutable objects are optimised (assuming bug 1601848 is fixed) so that we don't have to deal with the implications of a possibly-changing value. Mutable objects would see little benefit anyway, IMO.
Comment 6•6 years ago
|
||
| Assignee | ||
Comment 7•6 years ago
|
||
0x7fffffffffffffff is a negative number when converted to PRTime (a.k.a. 64-bit integer), because in javascript it's stored as a floating-point number, loses precision, and is greater than 2⁶³.
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/83cf86aba5a2
For recurring events, skip calculating occurrences if they're known to be earlier than the date range requested; r=Fallen
| Assignee | ||
Updated•6 years ago
|
Comment 10•6 years ago
|
||
Interesting, we use 0x7fffffffffffffff in a few other places. Maybe worth checking out :)
Description
•