-
-
Notifications
You must be signed in to change notification settings - Fork 653
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
revise jxlsave to reduce memory use #3132
Comments
Hi @tulzke, libvips is still using the original one-shot encode mode for libjxl, so yes, memory consumption is high for large images. I tried with a largish image here:
So 30gb and 30s for a 30k x 30k pixel image. I think there's now a streaming encode mode, so yes, libvips should switch to that. As far as I know there's no streaming decode though :-( There's talk of adding a tiled mode to JXL, which would be even better, of course. Let's tag this as an enhancement and try to revise this for 8.14. |
I tried your image and saw:
So 48gb of memory and 66s of real time. I wonder why it's more difficult to encode? Perhaps it's related to the colour profile. |
Hello, @jcupitt. |
This is causing errors in production for me. The errors are pretty bad because they make the entire process hang instead of allowing error handling to run and finish the process. I know the integration is still very early, and I wasn't expecting it to be flawless, but just wanted to let you know :) I ran some tests with wasm-vips, and it seems like any image that is roughly larger than 3500x3500 will crash the process. This is a problem because my pipeline deals with images for 4K screens, which are just in that ballpark of resolution. Here is a test case you can run in the browser: test case Thank you for already having such good JPEG XL support! |
It looks like libjxl is considering supporting a streaming/chunk-wise encode API, see: |
There were some updates in 0.9, with better support for streaming in libjxl: https://github.com/libjxl/libjxl/releases/tag/v0.9.0 Also related is this issue in libjxl's repo, where there seem to be some interest from the libvips team to contribute to libvips directly. I think that would be ideal! |
Per Cloudinary's recent test, an 80 (?) MP image now requires only ~1GB of memory as opposed to 8GB. Compressing OP's file also took only 1GB (per VIPS's 'highwater mark') with |
Yes, it's a nice improvement! We've started building libvips binaries with 0.10.1, eg.: |
The libvips highwater mark just counts libvips pixel buffers, it won't include memory allocated by external libraries. I usually test memuse with eg.:
So 2.3gb of ram and 4.5s elapsed time. With lbjxl 0.10.1:
About a 5x improvement in encoding speed and memory use for this photo. |
Bug report
When using libvips to convert to jxl, there is a huge memory consumption.
Yes, the image is large. It has a size of 23205x15802. But this is no more than 1GB in raw format.
It eats up all the memory, after which it is killed by the OS via SIGKILL. (My system uses 32Gb RAM)
At the same time, cjxl (the libjxl utility) does this without problems.
To Reproduce
Download that image: https://disk.yandex.ru/d/7YnSsGURImI7Vg
Use cli command: vips copy to_jpg_example.jpg converted.jxl
Expected behavior
Successful conversion to jxl
Actual behavior
Killing a process after uncontrolled memory consumption
Screenshots
![image](https://user-images.githubusercontent.com/62292054/199232636-46808e8b-09ec-4ae4-a721-135449c2cb69.png)
Environment
The text was updated successfully, but these errors were encountered: