[QScintilla] CPU usage of QScintilla editor

fulcrumusa at aim.com fulcrumusa at aim.com
Fri Apr 22 17:42:50 BST 2016


Hi,

I recently noticed that my application was consuming between 2-4% of CPU when it was completely idle.
When I attempted to track that down, I quickly arrived at the fact that the QsciScintilla() editor class was
the cause of this.

Just to clarify, I am using QScintilla through its Python bindings and PyQT4.

To further confirm/debug this I wrong the following minimal application:

 1 from PyQt4.QtCore import *
 2 from PyQt4.QtGui import *
 3 import PyQt4.Qsci as Qsci
 4 import sys
 5
 6 a = QApplication(sys.argv)
 7 w = QMainWindow()
 8 s = Qsci.QsciScintilla()
 9 w.setCentralWidget(s)
10 w.destroyed.connect(a.exit)
11 w.show()
12 a.exec_()

When I ran it, the CPU usage was around 3%. The CPU usage with dropped to 0% when commented out
lines 8 and 9.

An strace of the process with lines 8 and 9 active shows that something in QScintilla is constantly trying
to receive messages from the X server:

socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC, 0) = 6
connect(6, {sa_family=AF_LOCAL, sun_path=@"/tmp/.X11-unix/X0"}, 20) = 0
getpeername(6, {sa_family=AF_LOCAL, sun_path=@"/tmp/.X11-unix/X0"}, [20]) = 0
uname({sysname="Linux", nodename="...", ...}) = 0
access("/tmp/xauth-<uid>-_0", R_OK)  = 0
open("/tmp/xauth-<uid>-_0", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=176, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fad7dcec000
read(7, "\0\0\0\4\254\0317\227\0\0010\0\22MIT-MAGIC-COOKIE-1\0"..., 4096) = 176
close(7)                                = 0
munmap(0x7fad7dcec000, 4096)            = 0
getsockname(6, {sa_family=AF_LOCAL, NULL}, [2]) = 0
fcntl(6, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(6, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
fcntl(6, F_SETFD, FD_CLOEXEC)           = 0
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{"l\0\v\0\0\0\22\0\20\0\0\0", 12}, {"", 0}, {"MIT-MAGIC-COOKIE-1", 18}, {"\0\0", 2}, {"i\220r\325\377\177\21\304\v\364\346DP\240\204\255", 16}, {"", 0}], 6) = 48
recvfrom(6, 0xd88a00, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN}], 1, -1)    = 1 ([{fd=6, revents=POLLIN}])
recvfrom(6, "\1\0\v\0\0\0\212\5", 8, 0, NULL, NULL) = 8
recvfrom(6, "\300\226\262\0\0\0\340\t\377\377\37\0\0\1\0\0\16\0\377\377\1\7\0\0  \10\377\0\0\0\0"..., 5672, 0, NULL, NULL) = 5672
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{"b\0\5\0\f\0\0\0BIG-REQUESTS", 20}], 1) = 20
poll([{fd=6, events=POLLIN}], 1, -1)    = 1 ([{fd=6, revents=POLLIN}])
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"\1\0\1\0\0\0\0\0\1\205\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{"\205\0\1\0", 4}], 1)       = 4
poll([{fd=6, events=POLLIN}], 1, -1)    = 1 ([{fd=6, revents=POLLIN}])
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"\1\0\2\0\0\0\0\0\377\377?\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(6, 0x7ffe1e9a89e0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{"7\0\5\0\0\0\340\t\221\2\0\0\10\0\0\0\377\377\377\0\24\0\6\0\221\2\0\0\27\0\0\0"..., 44}, {NULL, 0}, {"", 0}], 3) = 44
poll([{fd=6, events=POLLIN}], 1, -1)    = 1 ([{fd=6, revents=POLLIN}])
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"\1\10\4\0\3\23\0\0\37\0\0\0\0\0\0\0\nL\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 4096
recvfrom(6, "1363b\n*XmFileSelectionBox.backgr"..., 15404, 0, NULL, NULL) = 15404
recvmsg(6, 0x7ffe1e9a8a20, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
writev(6, [{"b\0\5\0\t\0\340\t", 8}, {"XKEYBOARD", 9}, {"\0\0\0", 3}], 3) = 20
poll([{fd=6, events=POLLIN}], 1, -1)    = 1 ([{fd=6, revents=POLLIN}])
recvmsg(6, {msg_name(0)=NULL, msg_iov(1)=[{"\1\0\5\0\0\0\0\0\1\207U\211\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(6, 0x7ffe1e9a88f0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a88f0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=6, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=6, revents=POLLOUT}])
...
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 99) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(6, 0x7ffe1e9a9000, 0)           = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(6, 0x7ffe1e9a8fe0, 0)           = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}], 4, 0) = 0 (Timeout)


Is this expected behavior? It seem that there is select() call missing somewhere?

Thanks,
- Mitko



More information about the QScintilla mailing list