-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Conversation
cvat/apps/engine/views.py
Outdated
@@ -256,6 +256,12 @@ def perform_create(self, serializer, **kwargs): | |||
organization=self.request.iam_context['organization'] | |||
) | |||
|
|||
def perform_destroy(self, instance): |
There was a problem hiding this comment.
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 , could you please look at helm tests? |
cvat/apps/events/utils.py
Outdated
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
_caches = {} |
There was a problem hiding this comment.
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.
cvat/apps/engine/models.py
Outdated
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: |
There was a problem hiding this comment.
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.
- pre_delete -> store all required information inside the cache (you can prepare ready to use event here)
- post_delete -> check that you have the required information inside the cache and flush it, otherwise handle the signal as usual.
Before:
After:
Motivation and context
How has this been tested?
Checklist
develop
branch- [ ] I have increased versions of npm packages if it is necessary(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.