Bug 144993 - kded collects lots of passive grabs, which gradually slow down the X server.
Summary: kded collects lots of passive grabs, which gradually slow down the X server.
Status: RESOLVED WORKSFORME
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kded (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Lubos Lunak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-03 19:39 UTC by Lasse Collin
Modified: 2007-07-31 17:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lasse Collin 2007-05-03 19:39:36 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Compiled From Sources
Compiler:          GCC 4.1.2 
OS:                Linux

Something in KDE makes passive grabs, which never get released. When the number of grabs gets higher, it starts to slow down the X server.

I need a few days of uptime until the slowdown is obvious; after two weeks everything is very sluggish. For example, changing between applications takes 1-2 seconds, and keyboard repeat rate drops to 15-20 chars/sec instead of my normal 30 chars/sec.

When investigating the problem, I decided to kill processes one by one. At that time I had 18 days of KDE uptime. When I killed kded, the X server hung *totally* for 45 minutes; according to gdb it was releasing grabs. After releasing all the grabs, everything was snappy again. That is, I didn't need to restart the X server.

With lower uptimes (about one week), I have noticed that logging out from KDE has taken up to five minutes. The reason was very probably the same as above, but the number of grabs hadn't grown so large yet.

So far I don't know what exactly is making those grabs. I assigned this bug to kded, because it was kded that was holding the grabs.

There is some additional information in Freedesktop.org's Bugzilla <https://bugs.freedesktop.org/show_bug.cgi?id=2738>. While I think that KDE shouldn't do massive amount of duplicate grabs, I think that X server shouldn't accept so many duplicate grabs either. 

This bug is may be related to KDE bug #117169, which now has a working work-around. However, the exact problem behind that tough bug wasn't found, but it had something to do with grabs.
Comment 1 Lubos Lunak 2007-05-21 15:40:05 UTC
I think this should be fixed in X. The X docs don't seem to say anything about repeated grabs, but e.g. the description of XUngrabKey() IMHO implies that they should not be stacked, i.e. that if such a grab already exists the next one should be a no-op and the very first ungrab should release it. Therefore I think the second patch in the x.org bugreport is correct. If nobody does anything about the x.org bugreport I suggest mailing the xorg@lists.freedesktop.org mailing list.
Comment 2 Leo Savernik 2007-05-21 18:28:24 UTC
*** This bug has been confirmed by popular vote. ***
Comment 3 Lasse Collin 2007-06-06 19:20:46 UTC
I got no reply to my post <http://lists.freedesktop.org/archives/xorg/2007-May/025054.html> but on #xorg-devel@Freenode I was told that the X11 client should be fixed. Currently it seems that the actual behavior (stacking vs. erasing the old grab) won't change. Maybe they will change from growing the linked list to reference counting, which will make the server suffer a lot less from large amount of grabs. Everyone agreed that the documentation is ambiguous, so relying on repeated grabs is a bad idea in any case.
Comment 4 Lubos Lunak 2007-06-08 14:14:13 UTC
It seems I've talked somebody from X.org into the fact that this should be fixed in X.org after all. Please test the patch from the linked bugreport if possible.
Comment 5 Lasse Collin 2007-06-10 22:21:56 UTC
I will test the patch. Unfortunately I usually don't have long uptimes in the summer, and this bug isn't obvious without at least one week uptime. It may take some time before I'm able to confirm that the patch works. It looks good to me though (definitely better than my patches).
Comment 6 Lasse Collin 2007-07-31 17:51:16 UTC
I just had 22 days of uptime, and things were still running smoothly. Also, logging out didn't take more time than usually. Thus, this bug seems to be fixed now. Thank you.