Skip to content
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

refactor(db-scheduler): optimize all_as_schedule query #835

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alirafiei75
Copy link

Summary

This PR optimizes the all_as_schedule function to improve performance by filtering unnecessary tasks from the database query.

Changes

  • Exclude clocked tasks not due within 5 minutes.
  • Exclude crontab tasks outside the relevant hour range.

fixes #675
fixes #786

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.40%. Comparing base (17d87f4) to head (0205cdf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #835      +/-   ##
==========================================
+ Coverage   87.20%   87.40%   +0.20%     
==========================================
  Files          32       32              
  Lines         938      953      +15     
  Branches       76       76              
==========================================
+ Hits          818      833      +15     
  Misses        102      102              
  Partials       18       18              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alirafiei75
Copy link
Author

Screenshot from 2025-01-04 12-04-45

This is cpu usage of our celery-beat server. We depend highly on cronjobs and clockjobs and as you see, optimizing the scheduler query, led to reduction in cpu usage considerably (see 11:53 in the picture)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatabaseScheduler is bad for a large amount of tasks? Scheduler is slow when dealing with lots of tasks
1 participant