Skip to content
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

[RFC] Downsample when decoding #146

Closed

Conversation

nicolasbrailo
Copy link
Contributor

When used in very constrained systems (eg raspberry pi's) the memory pressure from Swayimg can be quite significant. It's very easy to bring down a platform with 512mb of RAM just by loading a few large pictures and keeping them in memory. Implementing this change would enable loaders to reduce image size, so that the actual pixels stored in memory are not more than those that will be rendered to screen.

In my system, using not-very-large images (12mp) I see a reduction in memory usage of about 1/3, and faster render speeds.

When used in very constrained systems (eg raspberry pi's) the memory pressure
from Swayimg can be quite significant. It's very easy to bring down a
platform with 512mb of RAM just by loading a few large pictures and
keeping them in memory. Implementing this change would enable loaders to
reduce image size, so that the actual pixels stored in memory are not
more than those that will be rendered to screen.

In my system, using not-very-large images (12mp) I see a reduction in
memory usage of about 1/3, and faster render speeds.
@artemsen
Copy link
Owner

artemsen commented Jun 23, 2024 via email

@nicolasbrailo
Copy link
Contributor Author

Only jpeg has this feature, it useless for other formats.

Yeah that's the part I'm not too happy about. That's why it's an RFC in stead of a PR, if there's a good way of implementing this without doing it for all decoders, I'd love to know. If there is no way to fit it at all, that's also good to know.

12 megapixels is 48 MiB of memory, not so much even for raspberry. We could
disable cache and turn off preload functionality, this will save 2/3 of RAM.

A Rpi-W will certainly die with just a handful of images being cached. An Rpi4 with a lot more ram (4gb?) will also die with just 15 or 20 images decoded to memory (for my use case, I need at least a couple dozen images in memory, so I can't even start swayimg without this patch!)

Besides memory savings, this patch also makes it a lot more snappy to load and cycle through images. Noticeably so, according to my monkey-testers (ie kids swiping through images back and forward fast enough to complain that the picture frame is not working :))

artemsen added a commit that referenced this pull request Jul 4, 2024
Allows to load image by reading stdout from external command.

Relates to #145, #146.

Signed-off-by: Artem Senichev <[email protected]>
@artemsen
Copy link
Owner

artemsen commented Jul 4, 2024

Sorry, I can't merge this code as it solves a very specific and narrowly focused problem.

@artemsen artemsen closed this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants