Added downsampling cache functionality to PlotDataItem #3337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Downsampling, especially with peak mode and "auto", is a way to significantly speed up the zooming performance of line plots, because it limits the number of points that need to be drawn at each redraw. However, when a lot of data is shown, the computation of the downsampled signal itself becomes a bottleneck.
In this pull request, I have implemented caching of a downsampled signal, so that it does not have to be re-calculated for each change in view. For fixed downsampling, this has no drawbacks besides a slight increase in memory.
For auto-dowsampling, it is a bit more complicated. I have made it so that one cached downsampled signal is used for all zoom levels until it is zoomed enough that there are too few samples to show the signal in a nice way, at which point it starts using the existing "real-time" computation. Since, at that point, there are much fewer samples in the clipped signal to be processed, the performance of the real time downsampling is usually good enough.
This solves issue #3301