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

Improve performance of task claims by managers #852

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

Conversation

bennybp
Copy link
Contributor

@bennybp bennybp commented Oct 21, 2024

Description

We've noticed that with large databases, the time to claim tasks is a bit slow (multiple seconds). This is particularly noticeable in Issue #850 .

This PR aims to improve this significantly via two main ways:

  • Improving the SQL query. Not the task queue has an available column which can be used to filter, rather than the status column of the joined base_record table. This seems to be the fastest way, although it denormalizes stuff a bit
    • I tried a conditional WHERE status = 'waiting' index on base_record but that didn't even help as much
  • Improving the task specification generation (which happens sometimes when claiming) so that data is retrieved in fewer SQL queries. Also, I eliminated creation of pydantic objects here, which also trims a bit of time.

Tests on a copy of a production database show a reduction from ~2-3 seconds to 0.5-0.7 seconds for 200 tasks. Getting it much lower is going to be tough, since some of that is data transfer overhead over the internet.

Note that this does require a database migration with the upgrade-db subcommand.

Status

  • Code base linted
  • Ready to go

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.

1 participant