-
-
Notifications
You must be signed in to change notification settings - Fork 780
[13.0][OU-FIX] fix product images memory error #5457
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
base: 13.0
Are you sure you want to change the base?
[13.0][OU-FIX] fix product images memory error #5457
Conversation
avoid memory error when converting website_sale images.
avoid memory error when converting product images.
|
I think this impacts in performance, isn't it? |
|
maybe, i didn’t profile this. per image, it will make one database query to get the image, then several ones when creating the new attachments, but since reading, resizing and writing image attachments is way slower than doing some queries, i think the impact should be minimal. |
|
Not sure... Maybe this can be optional through a system param or similar? |
|
Or do it by batches of a size like 500? |
| # a MemoryError can happen if too many attachments are loaded in | ||
| # memory. therefore, we only load one record at the time and flush the | ||
| # cache at each iteration. | ||
| for attachment_id in attachment_ids: |
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.
| for attachment_id in attachment_ids: | |
| for i, attachment_id in enumerate(attachment_ids, 1): |
| ) | ||
| # flush and clear cache to avoid to fill up memory and force the |
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.
| ) | |
| # flush and clear cache to avoid to fill up memory and force the | |
| ) | |
| if i % 500 != 0: | |
| continue | |
| # flush and clear cache to avoid to fill up memory and force the |
|
iirc, i think the main issue comes from the fact that the smaller-size images are computed when flushing the model. i see in if we’re doing it in batches of 500 for performance, then it would make sense to also prefetch the records by the same batch size. unfortunately, i don’t have time currently to test this, but feel free to suggest something if you have. |
|
I think the batches can be of size 1000. |
avoid
MemoryErrorwhen converting product images (inproductandwebsite_sale).fixes #4712.