[PyQt] QGraphicsView very slow under Linux and Mac OS X
Hans-Peter Jansen
hpj at urpla.net
Wed Apr 3 17:46:31 BST 2013
On Mittwoch, 3. April 2013 17:28:28 Clemens Brunner wrote:
> On 04/03/2013 04:23 PM, Hans-Peter Jansen wrote:
> > What you see is possibly related to the default Qt graphics engine:
> >
> > when using:
> > QT_GRAPHICSSYSTEM=opengl python graphicsviewtest.py
> >
> > the values are oscillating around 150 here. With "native" and "raster",
> > it's back to 25: openSUSE 12.2/x86_64, 2560x1600x32, nvidia proprietary
> > graphics,
> That's what I suspected initially. However, my graphics engine was set
> to native by default. I just tried all three engines:
> * native: around 100ms
> * raster: around 100ms
> * opengl: greater than 300ms
>
> I tested it on Arch Linux x86_64, 1920x1080, python2 2.7.3-4, sip
> 4.14.5-1, qt4 4.8.4-16, python2-pyqt 4.10-1.
Which graphic driver do you use? (that doesn't tell us much, since the C++
version behave with the same driver, just for the record..)
> That's really weird... I will try to set up an openSUSE box in my
> VirtualBox to see if that works.
Might be worth to compare the C++ version (that you should publish here¹)
and the Python versions with perf. Of course, they differ...
python versions, perf running for about 10 sec.
QT_GRAPHICSSYSTEM=raster perf record -f python graphicsviewtest.py
21,06% python libc-2.15.so [.] __memmove_ssse3_back
3,34% python libc-2.15.so [.] __strcmp_sse42
2,97% python libpython2.7.so.1.0 [.] PyEval_EvalFrameEx
2,67% python libpython2.7.so.1.0 [.] lookdict_string
2,65% python libQtGui.so.4.8.4 [.] QWidget::qt_metacast(char const*)
2,42% python libGL.so.304.64 [.] 0x00000000000a01ed
1,50% python libnvidia-tls.so.304.64 [.] 0x0000000000001c70
1,27% python libpython2.7.so.1.0 [.] PyDict_GetItem
1,12% python libpthread-2.15.so [.] pthread_mutex_lock
1,07% python sip.so [.] parsePass1
1,04% python libpthread-2.15.so [.] __pthread_mutex_unlock_usercnt
1,03% python libQtCore.so.4.8.4 [.] QObject::qt_metacast(char const*)
1,00% python libpython2.7.so.1.0 [.] _init
QT_GRAPHICSSYSTEM=opengl perf record -f python graphicsviewtest.py
10,12% python libpython2.7.so.1.0 [.] PyEval_EvalFrameEx
4,94% python libpython2.7.so.1.0 [.] lookdict_string
4,63% python libnvidia-glcore.so.304.64 [.] 0x00000000013aed80
3,53% python sip.so [.] parsePass1
3,26% python libpython2.7.so.1.0 [.] PyDict_GetItem
2,68% python libpython2.7.so.1.0 [.] _PyType_Lookup
1,91% python libm-2.15.so [.] __sin_sse2
1,72% python libQtGui.so.4.8.4 [.] QBrush::~QBrush()
1,69% python libQtOpenGL.so.4.8.4 [.] QTriangulatingStroker::process(QVectorPath const&, QPen const&, QRectF
1,51% python libpython2.7.so.1.0 [.] _init
1,39% python libpython2.7.so.1.0 [.] binary_op1
1,29% python libpython2.7.so.1.0 [.] _PyObject_GenericGetAttrWithDict
1,27% python sip.so [.] parsePass2
1,21% python libGL.so.304.64 [.] 0x00000000000a19c6
1,16% python libQtOpenGL.so.4.8.4 [.] QTriangulatingStroker::moveTo(double const*)
1,15% python libpython2.7.so.1.0 [.] PyErr_Restore
1,11% python libc-2.15.so [.] _int_free
1,09% python libc-2.15.so [.] malloc
1,08% python libQtGui.so.4.8.4 [.] QPainter::drawLines(QLine const*, int)
1,00% python libQtOpenGL.so.4.8.4 [.] QGL2PaintEngineExPrivate::updateMatrix()
The former looks nice, it's a great example, why PyQt rocks. The hottest
areas are there, where they should be: down under, moving bits. Great.
But the latter looks strange indeed.
Phil, do you have any idea, why PyEval_EvalFrameEx is the top sucker in
this scenario? This looks, like in opengl mode, it is evaluating some
python expression in its hottest path (data type conversions or the like?).
BTW: the opengl version crashes always on exit for me:
Program received signal SIGSEGV, Segmentation fault.
XQueryExtension (dpy=dpy at entry=0x0, name=name at entry=0x7ffff0a374b4 "GLX", major_opcode=major_opcode at entry=
0x7fffffffd104, first_event=first_event at entry=0x7fffffffd108, first_error=first_error at entry=0x7fffffffd10c)
at QuExt.c:57
#0 XQueryExtension (dpy=dpy at entry=0x0, name=name at entry=0x7ffff0a374b4 "GLX", major_opcode=major_opcode at entry=
0x7fffffffd104, first_event=first_event at entry=0x7fffffffd108, first_error=first_error at entry=0x7fffffffd10c)
at QuExt.c:57
rep = {type = 0 '\000', pad1 = 0 '\000', sequenceNumber = 0, length = 0, present = 0 '\000', major_opcode =
0 '\000', first_event = 0 '\000', first_error = 0 '\000', pad3 = 1, pad4 = 0, pad5 = 0, pad6 = 4036989387, pad7 =
32767}
req = <optimized out>
#1 0x00007ffff2813492 in XInitExtension (dpy=dpy at entry=0x0, name=name at entry=0x7ffff0a374b4 "GLX") at InitExt.c:47
codes = {extension = 9386192, major_opcode = 0, first_event = -145781712, first_error = 32767}
ext = <optimized out>
#2 0x00007ffff2b2d93d in XextAddDisplay (extinfo=0x8f38d0, dpy=0x0, ext_name=0x7ffff0a374b4 "GLX", hooks=
0x7ffff0c651e0, nevents=17, data=0x0) at extutil.c:110
dpyinfo = 0xf010d0
#3 0x00007ffff09fa807 in ?? () from /usr/X11R6/lib64/libGL.so.1
No symbol table info available.
#4 0x00007ffff09fb01a in ?? () from /usr/X11R6/lib64/libGL.so.1
No symbol table info available.
#5 0x00007ffff09fb75a in ?? () from /usr/X11R6/lib64/libGL.so.1
No symbol table info available.
#6 0x00007ffff09fcbab in ?? () from /usr/X11R6/lib64/libGL.so.1
No symbol table info available.
#7 0x00007ffff0d40f29 in QGLContext::makeCurrent (this=0x990e00) at qgl_x11.cpp:934
d = <optimized out>
ok = true
#8 0x00007ffff0d1c60a in QGLShareContextScope (ctx=0x990e00, this=<synthetic pointer>) at ../../src/opengl/qgl_p.h:493
currentContext = 0x0
#9 ~QGLContextGroupResource (this=0x9919b0, __in_chrg=<optimized out>) at ../../src/opengl/qgl_p.h:768
scope = {m_oldContext = 0x0, m_ctx = <optimized out>}
context = 0x990e00
resource = 0x9b2150
i = <optimized out>
#10 QGLContextGroupResource<QGLEngineSharedShaders>::~QGLContextGroupResource (this=0x9919b0,
__in_chrg=<optimized out>) at ../../src/opengl/qgl_p.h:772
No locals.
#11 0x00007ffff51720b8 in QThreadStorageData::finish (p=0x8ada68) at thread/qthreadstorage.cpp:203
q = 0x9919b0
i = 26
locker = {val = 6686448}
destructor =
0x7ffff0d1bf50 <QThreadStorage<QGLContextGroupResource<QGLEngineSharedShaders>*>::deleteData(void*)>
tls = 0x8ada68
#12 0x00007ffff5272bcf in QCoreApplicationPrivate::~QCoreApplicationPrivate (this=0x8ad880, __in_chrg=<optimized out>)
at kernel/qcoreapplication.cpp:470
data = <optimized out>
locker = {val = 9131600}
#13 0x00007ffff57acb29 in QApplicationPrivate::~QApplicationPrivate (this=0x8ad880, __in_chrg=<optimized out>)
at kernel/qapplication.cpp:226
No locals.
#14 0x00007ffff52861cc in cleanup (pointer=<optimized out>) at ../../src/corelib/tools/qscopedpointer.h:62
No locals.
#15 ~QScopedPointer (this=0x8b5658, __in_chrg=<optimized out>) at ../../src/corelib/tools/qscopedpointer.h:100
oldD = <optimized out>
#16 QObject::~QObject (this=0x8b5650, __in_chrg=<optimized out>) at kernel/qobject.cpp:816
No locals.
#17 0x00007ffff57b6b31 in QApplication::~QApplication (this=0x8b5650, __in_chrg=<optimized out>)
at kernel/qapplication.cpp:1098
No locals.
#18 0x00007ffff689fd39 in sipQApplication::~sipQApplication (this=0x8b5650, __in_chrg=<optimized out>)
at sipQtGuiQApplication.cpp:211
No locals.
#19 0x00007ffff68a0777 in release_QApplication (sipCppV=0x8b5650) at sipQtGuiQApplication.cpp:2783
_save = 0x6020a0
sipCpp = 0x8b5650
tlw = {{p = {static shared_null = {ref = {_q_value = 317}, alloc = 0, begin = 0, end = 0, sharable = 1,
array = {0x0}}, d = 0x60b110}, d = 0x60b110}}
#20 0x00007ffff170fbee in forgetObject (sw=sw at entry=0x7ffff121d950) at siplib.c:10427
ctd = 0x7ffff6d28580 <sipTypeDef_QtGui_QApplication>
#21 0x00007ffff1711549 in sipWrapper_dealloc (self=0x7ffff121d950) at siplib.c:9979
No locals.
#22 0x00007ffff7ae6c76 in subtype_dealloc (self=0x7ffff121d950) at Objects/typeobject.c:1014
type = 0x787c00
base = <optimized out>
basedealloc = 0x7ffff1711540 <sipWrapper_dealloc>
#23 0x00007ffff7ae0cb8 in insertdict (mp=mp at entry=0x640f80, key=0x7ffff6d4a300, hash=<optimized out>,
value=value at entry=0x7ffff7da4e20 <_Py_NoneStruct>) at Objects/dictobject.c:530
old_value = <optimized out>
ep = 0x6d0cf0
#24 0x00007ffff7ae16b5 in PyDict_SetItem (op=op at entry=0x640f80, key=<optimized out>, value=value at entry=
0x7ffff7da4e20 <_Py_NoneStruct>) at Objects/dictobject.c:775
mp = 0x640f80
hash = <optimized out>
n_used = 16
#25 0x00007ffff7b0cbe8 in _PyModule_Clear (m=<optimized out>) at Objects/moduleobject.c:138
s = 0x7ffff6d4a324 "app"
pos = 27
key = 0x7ffff6d4a300
value = 0x7ffff121d950
d = 0x640f80
Cheers,
Pete
¹) since it might help to diagnose the problem, this is usually considered
*not* off-topic!
More information about the PyQt
mailing list