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

Reduce deletion time of task and projects #5926

Merged
merged 9 commits into from
Mar 31, 2023
Merged

Conversation

azhavoro
Copy link
Contributor

Before:
before
before_silk
After:
after
after_silk

Motivation and context

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have added a description of my changes into the CHANGELOG file
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
    - [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@azhavoro azhavoro requested a review from nmanovic as a code owner March 24, 2023 12:23
@@ -256,6 +256,12 @@ def perform_create(self, serializer, **kwargs):
organization=self.request.iam_context['organization']
)

def perform_destroy(self, instance):
Copy link
Contributor

Choose a reason for hiding this comment

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

I will not recommend implementing the logic this way. It is a workaround.

Need to optimize handers of signals. Manually call post_delete for tasks from post_delete for projects with all necessary prefetches. The same for post_delete jobs, etc. Need to use local memcache to check that the signal handler has been called already. The optimization should be trivial. It will work for all objects (not only for jobs)

@azhavoro azhavoro changed the title Reduce deletion time of task and projects [WIP] Reduce deletion time of task and projects Mar 24, 2023
@azhavoro azhavoro changed the title [WIP] Reduce deletion time of task and projects Reduce deletion time of task and projects Mar 27, 2023
@nmanovic
Copy link
Contributor

@azhavoro , could you please look at helm tests?

#
# SPDX-License-Identifier: MIT

_caches = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

when we discussed, it was suggested to use https://docs.djangoproject.com/en/4.1/topics/cache/#local-memory-caching. There are a number of strong reasons for that.

def delete(self, using=None, keep_parents=False):
from cvat.apps.events.signals import resource_delete
from cvat.apps.events.utils import clear_cache
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

I will recommend filling the cache in pre_delete and flushing it in post_delete. Thus we can be sure that we generate events only after an object is deleted.

  1. pre_delete -> store all required information inside the cache (you can prepare ready to use event here)
  2. post_delete -> check that you have the required information inside the cache and flush it, otherwise handle the signal as usual.

@nmanovic nmanovic merged commit 2f873fa into develop Mar 31, 2023
@nmanovic nmanovic deleted the az/fix_task_deletion branch March 31, 2023 10:40
mikhail-treskin pushed a commit to retailnext/cvat that referenced this pull request Jul 1, 2023
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.

2 participants