-
Notifications
You must be signed in to change notification settings - Fork 30
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
[RFC] Downsample when decoding #146
Conversation
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.
I don't think it is a good idea.
Only jpeg has this feature, it useless for other formats.
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.
…On Sat, Jun 22, 2024, 21:32 Nico Brailovsky ***@***.***> wrote:
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.
------------------------------
You can view, comment on, or merge this pull request online at:
#146
Commit Summary
- fecb629
<fecb629>
[RFC] Downsample when decoding
File Changes
(6 files <https://github.com/artemsen/swayimg/pull/146/files>)
- *M* src/formats/jpeg.c
<https://github.com/artemsen/swayimg/pull/146/files#diff-5dee4592ceed15794794ddb2b681fa0ea3726a0f144df3202ca3bcf319f4d076>
(18)
- *M* src/formats/loader.c
<https://github.com/artemsen/swayimg/pull/146/files#diff-7788e18b0e0187bb770dc359e174f6da4c83bdace9b35f1a889ad8d05698ec73>
(11)
- *M* src/formats/loader.h
<https://github.com/artemsen/swayimg/pull/146/files#diff-6e00fda22e14a3c504e6673766c29b4e965b64b1e04796715dc3d3e9b84e6d9f>
(13)
- *M* src/image.c
<https://github.com/artemsen/swayimg/pull/146/files#diff-a0ad98f6680fbee4dfcb6df2d7fae9cb7e02c521b28633aef28ad0b494bd3378>
(16)
- *M* src/image.h
<https://github.com/artemsen/swayimg/pull/146/files#diff-489be67be42aeaf673552ac2183b3cdfad9d78430fe35d83d09b93a8fb065131>
(9)
- *M* src/imagelist.c
<https://github.com/artemsen/swayimg/pull/146/files#diff-f44fc950d2e6f1c96a8e4ebf40b13084dbab64a47c3020585d176ea9bf71401b>
(12)
Patch Links:
- https://github.com/artemsen/swayimg/pull/146.patch
- https://github.com/artemsen/swayimg/pull/146.diff
—
Reply to this email directly, view it on GitHub
<#146>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI5UOBH2LDVOBA4LGPTAM3ZIW7MLAVCNFSM6AAAAABJXULYYGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DOOJWGIYDKOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
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.
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 :)) |
Allows to load image by reading stdout from external command. Relates to #145, #146. Signed-off-by: Artem Senichev <[email protected]>
Sorry, I can't merge this code as it solves a very specific and narrowly focused problem. |
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.