Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Scheduler] Improve triggers performance when possible #49817

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

Merged

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Mar 26, 2023

Q A
Branch? 6.3
Bug fix? yes-ish
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

Using \DatePeriod for the default trigger is great as it takes care of all date/time idiosyncrasies.
But for high frequencies, that does not work well and performance becomes an issue. So, this PR solves this issue by always using the fast algorithm when the frequency is expressed in seconds (int) or an ISO period (like PT2S) or when created from a string that uses a "simple" expression (like 2 seconds).

/cc @upyx

@upyx
Copy link
Contributor

upyx commented Mar 26, 2023

Why do you think the original version was bad? The DatePeriod class doesn't fit the requirements of the triggers: it provides a forward only iterator. The getNextRunDate method must return a valid value for any argument in any order. It's just a different task.

Now, there are two algos and "magic" with reflections...

The goal of constructors is initialization of objects to a valid state. It's not a big deal, but having logic in a constructor except assertions of arguments is bad practice. Now it has too much "magic".

The TriggerInterface allows you to make any composition. Triggers (originally) are not intended to be extended.

IMO it was better.

@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch from 47b35b8 to fe266a5 Compare May 21, 2023 14:25
@fabpot fabpot requested a review from kbond as a code owner May 21, 2023 14:25
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch 2 times, most recently from 537e357 to 55933a2 Compare May 21, 2023 14:36
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch 5 times, most recently from 6e48389 to c494148 Compare May 21, 2023 19:34
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch from c494148 to f70a577 Compare May 21, 2023 19:39
Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cosmetic

@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch from f70a577 to c80e9ad Compare May 21, 2023 19:45
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch from c80e9ad to a53187f Compare May 21, 2023 19:47
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch 2 times, most recently from 1fe7222 to ca3c30c Compare May 22, 2023 08:26
@fabpot fabpot force-pushed the scheduler-trigger-perf-improvments branch from ca3c30c to ebcced6 Compare May 22, 2023 08:28
@nicolas-grekas
Copy link
Member

Thank you @fabpot.

@nicolas-grekas nicolas-grekas merged commit 9b0d811 into symfony:6.3 May 22, 2023
@fabpot fabpot mentioned this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants