PlotPyStack / PythonQwt

Qt plotting widgets for Python (pure Python reimplementation of Qwt C++ library)
https://pypi.org/project/PythonQwt/
Other
86 stars 25 forks source link

Performance issue with High DPI displays #83

Closed PierreRaybaut closed 4 months ago

PierreRaybaut commented 4 months ago

This issue is related to this PlotPy Issue.

cercata commented 4 months ago

I have been trying your example, and it's similar to what we have.

In my computer, with QT_SCALE_FACTOR = 1 it makes zoom in and zoom out in around 0.3s With QT_SCALE_FACTOR = 2 the same it's around 3s

With 10 curves of 500.000 points instead of one curve os 5.000.000 the results are similar.

PierreRaybaut commented 4 months ago

After investigating this, I think that there is not much we can do about it: the high DPI display is directly handled by Qt itself. When setting the scale factor to 2, it should be at least 4 times slower because of the higher pixel density. Apparently, it's worse than that for an unknown reason, but fundamentally, we won't be able to improve the situation significantly.

What we need is a strategy to not plot unnecessary dense curves (like showing a million of points along a few thousand pixels screen width). And that is where the downsampling feature may be more than a workaround: maybe it's the solution.

Discussion to be continued on the PlotPy's Issue...

cercata commented 4 months ago

With 1.25 scale factor the degradation seems similar, it's not only the amount of pixels, but the great amount of floating point operations it seems.

For performance, we will have to use downsampling, but there are other collateral effects like some "aliasing" added, curves that are sometimes 1 pixel wide, other times 2 pixel wide. I hope QT will improve this in the future, adding several scaling options, maybe GPU acceleration, maybe optimize their code, maybe aplying it for text and icons, but not for other things ...

Thanks for looking into it and confirming what we suspected, and for the downsampling option.

PierreRaybaut commented 4 months ago

From your side, what's the impact of enabling/disabling curve antialiasing? (have you tried to play with this option?)

cercata commented 4 months ago

Antialising is cool, with that option activated, the lines are uniform with DPI scaling active.

The performance impact of antialising is not noticeable, neither with DPI scaling, neither without it. I guess if you do some profiling there will be some impact, but not something a user notices when using it.

PierreRaybaut commented 4 months ago

Thanks for the feedback.

In other words, with both anti-aliasing and downsampling options enabled (using PlotPy), we have a good workaround for this issue.

As we can't do much at PythonQwt's level, I propose to close this issue.