# VTK 8.2, performance degradation on upgrade Qt 5.12 -\> 5.15

**URL:** https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536
**Category:** Support
**Created:** [May 20, 2022, 1:41pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536 "2022-05-20T13:41:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![miro](https://discourse.vtk.org/user_avatar/discourse.vtk.org/miro/32/1896_2.png) [@miro](https://discourse.vtk.org/u/miro)
#### Post date: [May 20, 2022, 1:41pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536/1 "2022-05-20T13:41:55Z")

</div>

Hello all,  
Asking for help on VTK/Qt performance issue.  
We are using VTK 8.2 on Linux (based on Ubuntu 18.04) in software for medical device, with several VTK views within a Qt application. There is a live camera view using pure OpenGL calls in addition to the VTK views. We have been using VTK 8.2 and Qt 5.12.2 successfully. Now after upgrading to Qt 5.15.2 (and recompiling the same version VTK 8.2 against the new Qt 5.15.2) we are seeing performance degradation due to slower render times in the VTK views.

Each VTK view has its own visualization pipeline with its own vtkRenderWindow.  
There are 3 orthogonal image slice views, these render fast before (~1.5-2ms) as well as after (~3ms) upgrade.  
Then there is a 3D view rendering polygonal geometry (45k polys + some smaller objects), which rendered in ~4.5ms before, and ~7ms after Qt upgrade.  
The most impacted is a volume rendered scene, which took ~7ms per render before, now doubled to 14-15ms per render.

The timings are measured as delta between vtkRenderWindow’s StartEvent and EndEvent.

We use QVTKOpenGLNativeWidget for the Qt/VTK interface, same before and after upgrade.

The live camera view was performing at ~30fps stable before with Qt 5.12, now it’s ~10fps. When the VTK views are hidden, the camera view gets to stable 30fps again.

Using NVIDIA P4000 GPU with 470.\* drivers, which seems to work correctly (checked with `nvidia-smi`, `glxgears`) with vsync turned off (`__GL_SYNC_TO_VBLANK=0`). Some relevant output of glxinfo:

```auto
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro P4000/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 470.103.01
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 470.103.01
OpenGL shading language version string: 4.60 NVIDIA

```

Although the vsync should be disabled (`glxgears` confirms that \_\_GL\_SYNC\_TO\_VBLANK=0 works), I see this in the log when I set QSG\_INFO=1:

```auto
[23:45:20.125 DEBUG] >>> [QT/QML] threaded render loop
[23:45:20.125 DEBUG] >>> [QT/QML] Using sg animation driver
[23:45:20.125 DEBUG] >>> [QT/QML] Animation Driver: using vsync: 16.67 ms

```

It seems the Qt SG thread still syncs to vblank regardless of the \_\_GL\_SYNC\_TO\_VBLANK.

Has anyone experienced similar performance issues in VTK views after Qt upgrade? Any pointers to improve performance with Qt + multiple VTK renderwindows?

For reference, the new Qt 5.15.2 was compiled with

```auto
$QT5_SRC_DIR/configure -commercial -confirm-license \
                 -release \
                 -shared \
                 -no-static \
                 -no-pch \
                 -c++std c++17 \
                 -silent \
                 -prefix $INSTALL_DIR \
                 -nomake tests \
                 -nomake examples \
                 -inotify \
                 -icu \
                 -ssl \
                 -cups \
                 -libudev \
                 -qt-doubleconversion \
                 -qt-pcre \
                 -qt-zlib \
                 -qt-harfbuzz \
                 -qt-libpng \
                 -qt-libjpeg \
                 -qt-sqlite \
                 -qt-webengine-icu \
                 -qt-webengine-ffmpeg \
                 -system-freetype \
                 -alsa \
                 -webengine-alsa \
                 -opengl desktop \
                 -qpa xcb \
                 -xcb-xlib \
                 -xkbcommon

```

Unfortunately I don’t have build notes from previous build Qt 5.12.

Any and all thoughts/comments/advice greatly appreciated!!  
Cheers,  
Miro

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 20, 2022, 2:11pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536/2 "2022-05-20T14:11:59Z")

</div>

@sankhesh

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 21, 2022, 1:15pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536/3 "2022-05-21T13:15:35Z")

</div>

We have not noticed such performance degradation in 3D Slicer when switching from 5.12 to 5.15 on Windows. Linux and macOS users did not report slowdown either. So, it is unlikely to be a widespread general issue with Qt-5.15.

What differences do you see in performance profiling results? Where the most time is spent?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 21, 2022, 2:04pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536/4 "2022-05-21T14:04:56Z")

</div>

Hello,

My two cents: I’d suspect of some antialiasing default that has changed between 5.12 and 5.15. Try to disable it via code (bolth in direct OpenGL calls and in VTK API) an see wether performance improves.

take care,

Paulo

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [May 24, 2022, 2:20pm UTC](https://discourse.vtk.org/t/vtk-8-2-performance-degradation-on-upgrade-qt-5-12-5-15/8536/5 "2022-05-24T14:20:55Z")

</div>

@miro Some confusion here:

> [@miro](#):
>
> The timings are measured as delta between vtkRenderWindow’s StartEvent and EndEvent.

IMO, the vtk rendered image is blitted to the Qt context after the render window’s EndEvent i.e. Qt should not have affected the timing between Start and End events.

> [@miro](#):
>
> Although the vsync should be disabled (`glxgears` confirms that \_\_GL\_SYNC\_TO\_VBLANK=0 works), I see this in the log when I set QSG\_INFO=1:

The Qt scenegraph is not used with QtWidgets. That is QtQuick specific which `QVTKOpenGLNativeWidget` doesn’t do.

> [@miro](#):
>
> Has anyone experienced similar performance issues in VTK views after Qt upgrade? Any pointers to improve performance with Qt + multiple VTK renderwindows?

None that I have noticed anywhere. You could potentially try upgrading VTK to the latest version as well to see if that resolves your issues.
