hyprwm / hyprpaper

Hyprpaper is a blazing fast wayland wallpaper utility with IPC controls.
https://wiki.hyprland.org/Hypr-Ecosystem/hyprpaper/
BSD 3-Clause "New" or "Revised" License
724 stars 53 forks source link

Hyprpaper uses too much memory #143

Open DrShadow34 opened 5 months ago

DrShadow34 commented 5 months ago

According to the guide, preloading should take "This can result in around 8 - 20MB of mem usage", but for me hyprpaper uses around 1.8gb, what is kinda weird, especially after I looked into logs:

[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/octo.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/angel.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/dark.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/purple.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/pony.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/mercy.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/fox.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/colorfox.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/dash.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/catgirl.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/pink.png, Shared Memory usage: 132.7MB
[LOG] Total SM usage for all buffers: 1459.8MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/octo.png, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/angel.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/dark.png, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/purple.png, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/pony.png, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/mercy.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/fox.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/colorfox.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/dash.png, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/catgirl.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/pink.png, Shared Memory usage: 33.2MB
[LOG] Total SM usage for all buffers: 1824.8MB

As you can see, every picture reserving a lot of memory. Weird amount aside, why it's same number? Also, all pictures combined weight ~145mb. So I tried removing some pictures from preload, and that did nothing:

[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/dark.png, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/sacra/Pictures/Wallpapers/colorfox.jpg, Shared Memory usage: 132.7MB
[LOG] Total SM usage for all buffers: 265.4MB

Same size for each preload, lower amount simply because there not a lot to preload. Changing scaling will remove "Shared Memory usage: 132.7MB" row and there will be only "Shared Memory usage: 33.2MB" one, but memory allocation still same according to used memory.

Same result from hyprpaper-0.6.0-3 from arch repos and fresh version from git, currently: hyprpaper-git-0.6.0.r8.g09c40626-1

vaxerski commented 5 months ago

your pictures are compressed. Hyprpaper has to keep them in memory uncompressed. 33.2MB sounds like a 4K+ image.

It's not recommended to preload that many images.

DrShadow34 commented 5 months ago

Yes, I'm using 4k resolution. Well, that make sense now, thank you. I guess that would be a good idea to put that into Readme.md, to clarify a bit about memory allocation, cause current version is a bit misleading for dumb people like me.

vaxerski commented 5 months ago

feel free to make a MR to clarify parts that are unclear to you

DrShadow34 commented 5 months ago

Okay, now I'm really curious. You said in MR that 4k image is 33.1MB uncompressed, then where 2gb coming from? 33.1 x 11 should be just ~364mb, right?

vaxerski commented 5 months ago

correct. What are the resolutions of the images?

DrShadow34 commented 5 months ago

Each preloaded image has own resolution, from 12288 × 8192 of the biggest one to 223 × 226 of the lowest one. Upd. Okay, I was thinking for a second, that I'm going insane, so I converted all 11 images to 1080p png's and nothing changed, still 1824.8MB allocated. So I tried to change resolution of display to 1080p in hyprland.conf and now: [LOG] Total SM usage for all buffers: 91.2MB, but according to htop "res" is still 1729M, what is just 47mb difference from 2160p. I don't understand :c

vaxerski commented 5 months ago

that's... odd. I don't understand either.

DrShadow34 commented 5 months ago

It looks like no matter what, hyprpaper will just allocate same amount of memory per image (like there another 16k? screen), even if I preload 11 1x1 black png's it still will be 1.8GB (as staited before, 132.7mb per each loaded image). hyprctl monitor reporting normal 3840x2160 output and I have only one screen, so I have no idea why it doing that.

krims0n32 commented 1 week ago

Seeing similar behaviour:

[LOG] Buffer created for target /home/js/.wallpapers/python-logo-4k-i6-3840x2160.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/js/.wallpapers/wp6248987.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/js/.wallpapers/wp5134478.jpg, Shared Memory usage: 33.2MB
[LOG] Buffer created for target /home/js/.wallpapers/lakeside-sunset-deer-minimal-art-landscape-scenic-panorama-3840x2160-4592.png, Shared Memory usage: 33.2MB
[LOG] Total SM usage for all buffers: 663.6MB

These wallpapers are no more than 250kb on disk.

krims0n32 commented 1 week ago

Disabled fractional scaling because my wallpaper was really blurry (wallpapers are 4k as my native monitor resolution).

[LOG] Buffer created for target /home/js/.wallpapers/python-logo-4k-i6-3840x2160.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/js/.wallpapers/wp6248987.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/js/.wallpapers/wp5134478.jpg, Shared Memory usage: 132.7MB
[LOG] Buffer created for target /home/js/.wallpapers/lakeside-sunset-deer-minimal-art-landscape-scenic-panorama-3840x2160-4592.png, Shared Memory usage: 132.7MB
[LOG] Total SM usage for all buffers: 530.8MB

Still high but a little better.

vaxerski commented 1 week ago

buffers have to be uncompressed. The fact your 4K wallpaper is a compressed-to-fuck jpeg doesn't matter.

krims0n32 commented 1 week ago

I understand, but 530MB for 4 preloaded 3840x2160 wallpapers still seems excessive, no?

vaxerski commented 1 week ago

yes, should be 130MB