shrinerb / shrine

File Attachment toolkit for Ruby applications

Home Page:https://shrinerb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Huge memory consumption when using ImageProcessing::Vips for derivatives

qdegraeve opened this issue · comments

Hi,

recently we tried tu move out from Imagemagick to Vips to improve performances of derivatives processing as we use it a lot.
We had great expectations but unfortunately, the result is not at all what we expected in terms of memory consumption.

While the processing speed is increased by between 5 and 10 times, the memory is increased as well by 2.

I do not have a precise measure but I have graphs that represent the same exact flow, with the same pictures (all around 5 mb) to be processed.

In the example we try to process each image, with sidekiq and a throttle configured with a concurrency of 1. There is 19 images to be processed and here are the graphs :
With VIPS
image

With ImageMagick
image

Maybe there something I miss or do not understande.

My configuration is a container build with ruby-3.2-bookworm-slim, libvips 8.15, rails 6.1 , shrine 3.4 and sidekiq 7.2

For now I will stay with ImageMagick but if you have any clue on what is happening that would be great.

Ask me if you need further details
Regards
Quentin

Not sure what's causing the increased memory usage, libvips should even be using less memory than ImageMagick. This is not an issue in Shrine gem, because the image processing is handled by the ImageProcessing gem. The issue is unlikely in ImageProcessing or ruby-vips gems either, it's most likely in libvips. I will move this to a discussion.