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
perf: LSDV-4695: Add Project relation to Prediction model to improve overall performance #4629
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ove performance Also update anywhere in the code where Predictions are created so project is also connected and adds a failsafe in the Predition save method to add a project if it was not added before
✅ Deploy Preview for heartex-docs canceled.
|
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #4629 +/- ##
===========================================
- Coverage 75.85% 75.85% -0.01%
===========================================
Files 157 157
Lines 12487 12499 +12
===========================================
+ Hits 9472 9481 +9
- Misses 3015 3018 +3 ☔ View full report in Codecov by Sentry. |
16 tasks
yyassi-heartex
approved these changes
Aug 17, 2023
bmartel
reviewed
Aug 18, 2023
bmartel
reviewed
Aug 18, 2023
bmartel
reviewed
Aug 18, 2023
bmartel
reviewed
Aug 18, 2023
bmartel
approved these changes
Aug 19, 2023
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
shayantabatabaee
pushed a commit
to shayantabatabaee/label-studio
that referenced
this pull request
Sep 19, 2023
…overall performance (HumanSignal#4629) * perf: LSDV-4695: add new project relation to Prediction model to improve performance Also update anywhere in the code where Predictions are created so project is also connected and adds a failsafe in the Predition save method to add a project if it was not added before * Add data migration to update predictions with direct fk to their project * Update to avoid magic number and add reasoning behind size choice * Convert data migration to async operation * Revert changes and use existing project to link to prediction
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR fulfills these requirements
[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made
ex.fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
Change has impacts in these area(s)
(check all that apply)
Describe the reason for change
Prediction performance in general has not been optimal due to the necessity of querying through the task model whenever needing to filter on project (Prediction -> Task -> Project).
What does this fix?
This PR is the first of a set of 2 PRs. This PR adds migrations to add the a project foreign key field to Prediction as well as a data migration to populate the new field with the correct project for existing Predictions. I've also added changes across the code on Prediction saves / bulk saves etc to ensure any new Predictions added after the migration will store the project properly.
Once the first PR is live, the second PR will introduce changes to queries which use the new project relation rather than querying through task -> project.
The PRs were separated in this way because until all Predictions have been updated with the new project fk, the queries could not be optimized to use the fk.
What feature flags were used to cover this change?
None - and this is by design. I've introduced code changes here on all Prediction save's/bulk saves to save project_id on create. This is necessary because the next PR will introduce query updates that depend on this Prediction.project_id linkage and if its missing on any Predictions, the query will break. I'll use a feature flag on the following PR to test the query changes however.
Does this PR introduce a breaking change?
(check only one)
What level of testing was included in the change?
(check all that apply)
Which logical domain(s) does this change affect?
Predictions