Skip to content

Speed up connect='all' in the presence of non-finite#2036

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:connect_all_no_backfill
Oct 22, 2021
Merged

Speed up connect='all' in the presence of non-finite#2036
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:connect_all_no_backfill

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Oct 22, 2021

While developing #2011 and #2032, which use alternative techniques for creating the plotting path, it was realized that connect='all' does not require the use of functions._compute_backfill_indices. One could simply filter away the non-finite data.

The functionality of functions._compute_backfill_indices came from #1287. However that was for when all path creation went through the >> operator technique, which would reject the entire path in the presence of any non-finite data (since Qt 5.12.3 according to #1287.)

With the implementation of #1796, connect='all' path creation no longer goes through the >> operator technique. Thus the reason for running the data through functions._compute_backfill_indices was no longer valid. And hence this PR.

Thanks to the non-copy technique used in #1965, removing the non-finite data does not involve an extra copy.

asv execution: only relevant column is "all"
For the 10000 element rows, timing of WithNonFinite dropped from 203us (master) to 125us (this PR), making it competitive with the AllFinite timing of 101us.

(allqt) PS C:\work\github\pyqtgraph> asv run -b arrayToQPath HEAD~2..
· Creating environments
· Discovering benchmarks
· Running 8 total benchmarks (2 commits * 2 environments * 2 benchmarks)
[  0.00%] · For pyqtgraph commit dd1e87b7 <connect_all_no_backfill>:
[ 25.00%] ·· Building for virtualenv-py3.8-numpy-pyside2
[ 25.00%] ·· Benchmarking virtualenv-py3.8-numpy-pyside2
[ 31.25%] ··· Running (arrayToQPath.TimeSuiteAllFinite.time_test--)..
[ 43.75%] ··· arrayToQPath.TimeSuiteAllFinite.time_test                                                              ok
[ 43.75%] ··· ========= ============= ============= ============= =============
              --                                 param2
              --------- -------------------------------------------------------
                param1       all          finite        pairs         array
              ========= ============= ============= ============= =============
                10000      101±4μs      110±0.4μs    1.05±0.01ms     1.02±0ms
                100000   2.84±0.02ms   3.04±0.04ms    11.1±0.3ms   10.7±0.04ms
               1000000    26.5±0.2ms    27.2±0.1ms     109±2ms      107±0.5ms
              ========= ============= ============= ============= =============

[ 50.00%] ··· arrayToQPath.TimeSuiteWithNonFinite.time_test                                                          ok
[ 50.00%] ··· ========= ============= ============= ============= =============
              --                                 param2
              --------- -------------------------------------------------------
                param1       all          finite        pairs         array
              ========= ============= ============= ============= =============
                10000     125±0.3μs      142±8μs       1.12±0ms      1.11±0ms
                100000   3.44±0.04ms     1.58±0ms    11.9±0.09ms   12.0±0.05ms
               1000000    31.2±0.9ms   16.4±0.08ms    120±0.5ms      118±1ms
              ========= ============= ============= ============= =============

[ 50.00%] · For pyqtgraph commit 5ed6e6a8 <master>:
[ 75.00%] ·· Building for virtualenv-py3.8-numpy-pyside2
[ 75.00%] ·· Benchmarking virtualenv-py3.8-numpy-pyside2
[100.00%] ··· arrayToQPath.TimeSuiteWithNonFinite.time_test                                                          ok
[100.00%] ··· ========= ============ ============= ============= =============
              --                                param2
              --------- ------------------------------------------------------
                param1      all          finite        pairs         array
              ========= ============ ============= ============= =============
                10000     203±9μs       143±4μs     1.16±0.03ms   1.15±0.03ms
                100000   3.92±0.2ms   1.61±0.04ms    12.0±0.1ms   11.9±0.09ms
               1000000   35.6±0.1ms   16.3±0.06ms     121±1ms       120±3ms
              ========= ============ ============= ============= =============

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 22, 2021

Nice find @pijyoi this LGTM. It's interesting the performance improvement, while improving with the size of the array, doesn't seem to improve at the same rate as the size of the array. Guess that's just a testament to how efficient you made functions._compute_backfill_indices to begin with. 👍🏻

Always great to have a performance boost for our most common use-case.

@j9ac9k j9ac9k merged commit b1ce6ba into pyqtgraph:master Oct 22, 2021
@pijyoi pijyoi deleted the connect_all_no_backfill branch October 23, 2021 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants