'What does libvips VIPS_DISC_THRESHOLD default=100 mean?

Does it mean that it will take 100MB (Open via Disk)? Or it mean that it will take 100MB (Open via Memory)?



Solution 1:[1]

That's the threshold at which libvips will flip from open-via-memory to open-via-disc.

For small images (100mb when decompressed in this case), libvips will decompress to memory then process from there. This is obviously not a good idea for large images, so for these libvips will decompress to a temporary disc file, then map that area of disc into virtual memory and use that as the pixel source.

tldr: set VIPS_DISC_THRESHOLD to a small number to prefer the use of disc, set it to a large number to prefer RAM.

There's a chapter in the libvips docs which goes into a lot more detail:

https://www.libvips.org/API/current/How-it-opens-files.md.html

To very quickly summarize:

  1. libvips has at least four ways of opening images and tries hard to pick the best one for you automatically.
  2. Sometimes it'll need a bit of help to hit the best path for your use case and you have three main ways of influencing this.
  3. You can hint the access pattern you expect for this image with the access= parameter, you can set the threshold at which it'll flip between preferring memory and preferring disc, and you can say where you'd like disc temporaries to be held.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jcupitt