-
Notifications
You must be signed in to change notification settings - Fork 125
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
Enhance fastforward speed if no count
value has been given
#438
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #438 +/- ##
============================================
- Coverage 98.87% 98.85% -0.02%
- Complexity 1809 1849 +40
============================================
Files 65 65
Lines 5160 5259 +99
============================================
+ Hits 5102 5199 +97
- Misses 58 60 +2
Continue to review full report at Codecov.
|
3718f24
to
3f2279e
Compare
Thanks for the PR. This adds a lot of code. For which use-case do these changes improve performance? Did you measure how much it improves performance? |
3f2279e
to
5f6e97c
Compare
@staabm It's dependent on the other PRs (which I included in this branch too) because otherwise I would have to write tests that are on purpose incorrect. It improves performance for basically every rrule that does not have the |
5f6e97c
to
568e727
Compare
I'm also a little worried about the complexity this adds. It's not a super easy to maintain part of the code. At the very least the newly introduced code is not really documented, and it could stand to benefit from more in-line documentation and better variable naming. It's pretty impressive though. I have no doubt that this greatly improves performance. |
568e727
to
dec08b0
Compare
dec08b0
to
8eaabc0
Compare
Yeah its a lot of complexity. I cant overlook the impact of the change though, therefore will delegate the final call to @evert |
For what it's worth, the intent of the The way I envisioned that these optimizations would happen, is that the fastForward function looks if the rules from RRULE are considered "simple enough", such as By giving every So usually what I will ask people who need a feature like this is: Are there 2 or 3 specific cases that would solve 90% of your problem, because that tends to be a bit more effective in the long. For example, having support for faster fastForwarding in hourly events might not be interesting to anyone because hourly recurring events are so rare. I think another feeling with this patch is that it feels very much like a patch on existing logic, when maybe the existing logic/structure wasn't really good enough. This makes me wonder if a better design exists to satisfy this requirement. Anyway, I realize that these are fairly vague and not-that-constructive comments :/ |
@evert So in general, we want to use this library in a more enterprise setting. Fastforward will be included and needs to be performant enough to be used without causing a DDOS vulnerability. Essentially this means that we will have to block any It's very important to have this or a similar performance improvement as we are relying on this. So hopefully, we can find a solution as it's best to have this in the main branch of course :-).
I understand, I will fix this, of course. Would be better to sort out a way that this speed up can be merged first, though. As I promised the performance measure. I wrote an easy example of the speed up like this (note that there are a lot of tests included in the FastForwardTest case which stress test the performance and test if the fast forward does run in a certain timeframe)
require_once 'vendor/autoload.php';
foreach (['YEARLY', 'MONTHLY', 'DAILY'] as $freq) {
$timezone = 'America/New_York';
$startDate = new \DateTime('1992-10-23 00:00:00', new \DateTimeZone($timezone));
$rrule = new \Sabre\VObject\Recur\RRuleIterator("FREQ=$freq", $startDate);
$start_time = microtime(true);
for ($i = 0; $i < 1000; $i++) {
$rrule->rewind();
$rrule->fastForward(new \DateTime('now'));
}
$end_time = microtime(true);
echo 'Frequency: ', $freq, PHP_EOL;
echo 'Time spent for 1: ', ($end_time - $start_time), ' ms', PHP_EOL, PHP_EOL;
} The output for the master branch is: $ php ./benchmark.php
Frequency: YEARLY
Time spent for 1: 0.067322969436646 ms
Frequency: MONTHLY
Time spent for 1: 0.58958315849304 ms
Frequency: DAILY
Time spent for 1: 13.813991069794 ms For the proposed branch: php ./benchmark.php
Frequency: YEARLY
Time spent for 1: 0.034175872802734 ms
Frequency: MONTHLY
Time spent for 1: 0.056872129440308 ms
Frequency: DAILY
Time spent for 1: 0.015760898590088 ms
So that is general not easily done. Consider this case:
Of course, we could patch this, but then why won’t we already rely on logic that is already there to handle these cases? The benefit of this is that this code is used way more, so there is less chance that a bug will go unnoticed. Hopefully, we can figure something out here :-) |
No description provided.