SwayNotificationCenter icon indicating copy to clipboard operation
SwayNotificationCenter copied to clipboard

slow performance with lots of notifications

Open nekopsykose opened this issue 2 years ago • 9 comments

this isn't really so much an "issue" as much as an avenue for optimisation.

generate a lot of notifications:

for x in $(seq 1 1000); do
  notify-send "$x" "$x"
done

as these fill the notification buffer, they get slower and slower to send (especially past the ~120 mark).

this itself doesn't really matter: nothing really spams notifications this much (at once). however, once they are all completed, opening the swaync center takes a long time of 2-3 seconds (swaync-client -t). once it's opened once, it then doesn't take very long to open/close (i assume the buffer is "cached" in some way), but any new notification coming in resets that long timer to open it once again.

clearing the notifications (open center, Shift+c or whatnot), then resets back to the fresh behaviour of everything being fast.

this doesn't really matter, but it makes it a little slow to open the notification center to check recent notifications once the buffer is somewhere above ~120 notifications. and this is very common if one doesn't ever clear them, like me, being too lazy to click them away and letting them pile up for a while.

of course the easiest fix is actually dismissing notifications all the time, but i think there might also be some way to make it not slow to open with 100+ notifications, maybe there is some very obvious place to optimise the notification buffer being toggled.

nekopsykose avatar Jun 24 '22 03:06 nekopsykose

Hmmm... I wonder if all notifications need to be drawn before opening even if they're not visible?

ErikReider avatar Jun 24 '22 08:06 ErikReider

Seems like a GTK issue...

ErikReider avatar Jun 25 '22 10:06 ErikReider

Inefficient lists is one of the things fixed by Gtk4, with its recycling GtkListView.

kennylevinsen avatar May 21 '23 11:05 kennylevinsen

Inefficient lists is one of the things fixed by Gtk4, with its recycling GtkListView.

Cool! Didn't know that! I'll be porting this to GTK4 once gtk4-layer-shell becomes available in distro repos :)

ErikReider avatar May 21 '23 14:05 ErikReider

I'll be porting this to GTK4 once gtk4-layer-shell becomes available in distro repos

distros usually add deps for things that use them, i.e. they would add gtk4-layer-shell to satisfy this if you ported to it. that's why almost no distro has it already- no application uses it (that i know of), and it's not hard to build. someone has to be the first (usually). don't let that stop you in itself :) (speaking as a distro maintainer)

of course, it's a bunch of more work to actually do the porting, so no rush there :)

nekopsykose avatar May 21 '23 14:05 nekopsykose

Things have slowed down a bit in SwayFX now when blur has been merged so I'll probably look into this after #221 is merged

ErikReider avatar May 21 '23 14:05 ErikReider

I think a decent workaround would be to have a configurable "buffer" size for notifications, e.g. a max-notification-count option set to 100 will cause old notifications to be automatically dismissed once that number of notifications is reached.

0xC0ncord avatar Jun 17 '23 04:06 0xC0ncord

Agreed @0xC0ncord, an optional buffer would be good, because I always forgot to clear and when I clear it the swaync just freezes because it is too many notifications.

emanuelserpa avatar Nov 23 '23 15:11 emanuelserpa

I use this with my security system, I avg 200-500 notifications every 24hr. When I first start swaync its using ~60mb, 2 days running its using ~400mb, after 4 days its over 1gb. I clear notifications several times a day, is this normal?

s0ulslack avatar Jan 16 '24 04:01 s0ulslack