lilyinstarlight / nixos-cosmic

Flake for testing COSMIC on NixOS
MIT License
162 stars 18 forks source link

High Ram usage in cosmic applications #138

Open Thorndur opened 1 month ago

Thorndur commented 1 month ago

Hi @lilyinstarlight, i'm trying out Cosmic on nixos 24.11 and what i noticed is that many the Cosmic application use a lot of ram on my machine (Framework 13 amd so a x86_64 machine). I'm not sure if that is a problem with the nix flake or with Cosmic Epoch itself. But as other Cosmic users, don't seem to have the problem I ask here. Specifically cosmic-comp, a bunch of applets and a few other applications all have roughly the same memory usage of ~1.4GB per process (about half of that is shared, please see screenshot of htop). Which seems very big to me. The applications and applets also take a while to open for the first time, which is probably related. I have these sevices set and i'm using the cosmic cachix cache. services.desktopManager.cosmic.enable = true; services.displayManager.cosmic-greeter.enable = true;

Thanks for the great work on the flake, I really appreciate it! screenshot-2024-05-30-15-59-12

modisek commented 1 month ago

I am experiencing the same with high ram usage and also the applets being taking a long time to show output when i click o them.

CnTeng commented 1 month ago

@modisek I hava the same experience with you, especially the applets.

Itsusinn commented 1 month ago

I cloned cosmic-term repo and build it locally (cargo run --release). The memory usage is still high(~700MB). Same as cosmic-term under this flake. So maybe cosmic itself's problem.

Itsusinn commented 1 month ago

On archlinux, cosmic-term use 60MB. So maybe some logic of iced on nixos leads to this problem.

Thorndur commented 1 month ago

Hi thanks for the hint @Itsusinn you lead me on the right track, I think i found the cause. Looking through the open Iced issues, i found this one https://github.com/iced-rs/iced/issues/2455, where an Iced application would load all Systemfonts into memory on startup and cause performance problems through that. I have nerdfonts installed which are pretty huge. Removing the nerdfont package from my nix config seems to do the trick. The Memory usage went form about 1.5 GB to about 60-100mb per app and everything is really snappy now. So until this gets fixed on the Iced side the workaround would be to keep the fonts folder small. screenshot-2024-06-10-15-13-54

modisek commented 1 month ago

Thanks for that workaround @Thorndur after reducing my fonts, memory usage has gone down for everything excluding the cosmic-applets which seems to be using a lot of ram still..Other than that its now somewhat usable for me

Itsusinn commented 1 month ago

I made a pull request for cosmic-text sereval days ago, which makes parsing process quicker. At that time i didn't notice it used so much RAM. But now I think reducing fonts that need to be parsed is root of the problem.