GWorkspace stuck using CPU - thread event polling

Riccardo Mottola <[email protected]>
Newsgroups gmane.comp.lib.gnustep.general
Message-ID <[email protected]>
22692 pts/7    Sl+  289:49                  |       \_ GWorkspace
22697 ?        Ss    10:38                  |           \_ 
/System/Tools/fswatcher --daemon --auto
22699 ?        Ss     0:00                  |           \_ 
/System/Tools/ddbd --daemon --auto

so it is GWorkspace itself

top
22692 multix    20   0  296768  59872  12908 S  10.9   0.2 290:03.40 
GWorkspace

but it is in state sleep, how can it consume so much CPU? (10% in a full 
load system with 12CPU is... almost a CPU)

So let me try GDB

gdb -pid 22692


(gdb) bt
#0  0x00007fc175c0fb42 in ?? () from /lib64/libc.so.6
#1  0x00007fc175c0451c in ?? () from /lib64/libc.so.6
#2  0x00007fc175c04561 in ?? () from /lib64/libc.so.6
#3  0x00007fc175c79b0a in poll () from /lib64/libc.so.6
#4  0x00007fc1762bf268 in poll (__fds=<optimized out>, __nfds=<optimized 
out>, __timeout=2)
     at /usr/include/bits/poll2.h:44
#5  -[GSRunLoopCtxt pollUntil:within:] (self=<optimized out>, 
_cmd=0x7fc1764d0180 <_OBJC_SELECTOR_TABLE+1184>,
     milliseconds=2, contexts=0x55d6ef96a480) at GSRunLoopCtxt.m:395
#6  0x00007fc1761e12d4 in -[NSRunLoop acceptInputForMode:beforeDate:] 
(self=0x55d6ef967d90,
     _cmd=0x7fc1764d01b0 <_OBJC_SELECTOR_TABLE+1232>, 
mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>,
     limit_date=0x55d6f177c590) at NSRunLoop.m:1259
#7  0x00007fc1761e0f94 in -[NSRunLoop runMode:beforeDate:] 
(self=<optimized out>, _cmd=<optimized out>,
     mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>, date=<optimized out>) at 
NSRunLoop.m:1339
#8  0x00007fc1769a4822 in -[GSDisplayServer(EventOps) 
getEventMatchingMask:beforeDate:inMode:dequeue:] (
     self=<optimized out>, _cmd=<optimized out>, mask=<optimized out>, 
limit=<optimized out>,
     mode=<optimized out>, flag=<optimized out>) at GSDisplayServer.m:1037
#9  0x00007fc171e9a20a in -[XGServer(X11Ops) 
getEventMatchingMask:beforeDate:inMode:dequeue:] (
     self=0x55d6ef63fec0, _cmd=<optimized out>, mask=4294967295, 
limit=0x55d6ef97f420,
     mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>, flag=1 '\001') at 
XGServerEvent.m:2743
#10 0x00007fc1767dd9c5 in DPSPeekEvent (ctxt=<optimized out>, 
mask=<optimized out>, limit=<optimized out>,
     mode=<optimized out>) at 
../Headers/Additions/GNUstepGUI/GSDisplayServer.h:210
#11 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] 
(self=0x55d6ef863ba0,
     _cmd=0x7fc176b125b0 <_OBJC_SELECTOR_TABLE+2928>, mask=4294967295, 
expiration=0x55d6ef97f420,
     mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>, flag=1 '\001') at 
NSApplication.m:2208
#12 0x00007fc1767df8de in -[NSApplication run] (self=0x55d6ef863ba0, 
_cmd=<optimized out>) at NSApplication.m:1579
#13 0x000055d6c71cd987 in main (argc=<optimized out>, argv=<optimized 
out>, env=<optimized out>) at main.m:38

There is no direct GWorkspace class in this trace actually

which would say it is in poll runloop. A wild guess it is waiting for an 
event from X11. Keyboard or Mouse?
Or instead it is using X for polling a different event.

(gdb) info threads
   Id   Target Id                                      Frame
* 1    Thread 0x7fc171fa4500 (LWP 22692) "GWorkspace" 0x00007fc175c0fb42 
in ?? () from /lib64/libc.so.6
   2    Thread 0x7fc1700166c0 (LWP 22723) "GWorkspace" 
0x00007fc175c0fb42 in ?? () from /lib64/libc.so.6


shows me there are two threads.

If I switch to the second thread, I see:
[Switching to thread 2 (Thread 0x7fc1700166c0 (LWP 22723))]
#0  0x00007fc175c0fb42 in ?? () from /lib64/libc.so.6
(gdb) bt
#0  0x00007fc175c0fb42 in ?? () from /lib64/libc.so.6
#1  0x00007fc175c0451c in ?? () from /lib64/libc.so.6
#2  0x00007fc175c04561 in ?? () from /lib64/libc.so.6
#3  0x00007fc175c79b0a in poll () from /lib64/libc.so.6
#4  0x00007fc1762bf268 in poll (__fds=<optimized out>, __nfds=<optimized 
out>, __timeout=2147483647)
     at /usr/include/bits/poll2.h:44
#5  -[GSRunLoopCtxt pollUntil:within:] (self=<optimized out>, 
_cmd=0x7fc1764d0180 <_OBJC_SELECTOR_TABLE+1184>,
     milliseconds=2147483647, contexts=0x7fc168001800) at 
GSRunLoopCtxt.m:395
#6  0x00007fc1761e12d4 in -[NSRunLoop acceptInputForMode:beforeDate:] 
(self=0x7fc1680017b0,
     _cmd=0x7fc1764d01b0 <_OBJC_SELECTOR_TABLE+1232>, 
mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>,
     limit_date=0x55d6ef97f420) at NSRunLoop.m:1259
#7  0x00007fc1761e0f94 in -[NSRunLoop runMode:beforeDate:] 
(self=<optimized out>, _cmd=<optimized out>,
     mode=0x7fc1764d0fb0 <_OBJC_INSTANCE_2>, date=<optimized out>) at 
NSRunLoop.m:1339
#8  0x00007fc1761df2c9 in -[NSRunLoop runUntilDate:] 
(self=0x7fc1680017b0, _cmd=<optimized out>,
     date=0x55d6ef97f420) at NSRunLoop.m:1369
#9  0x00007fc1703d9948 in +[ImageResizer connectWithPorts:] 
(self=0x7fc1703e0d80 <_OBJC_Class_ImageResizer>,
     _cmd=<optimized out>, portArray=<optimized out>) at Resizer.m:54
#10 0x00007fc176216d3e in nsthreadLauncher (thread=0x55d6f0613b30) at 
NSThread.m:1490
#11 0x00007fc175c07c13 in ?? () from /lib64/libc.so.6
#12 0x00007fc175c86f6c in ?? () from /lib64/libc.so.6


which shows too polling, again an event, in this case it is the 
ImageResizer thread.

49      serverObject = [[self alloc] init];
50      if (serverObject)
51        {
52          [(id)[serverConnection rootProxy] setResizer:serverObject];
53          [serverObject release];
54          [[NSRunLoop currentRunLoop] run];
55        }
56      [pool release];
57      [NSThread exit];


Is inter-thread DistributedObject stuck? something starved? I don't know...

Interesting is that is usually works and gets just sometimess suck, 
pointing out to some peculiar condition.

Riccardo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.