SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

Fast cython evaluation for massive speedup #109

Closed VikingScientist closed 4 years ago

VikingScientist commented 4 years ago

Overview

At the very heart of all evaluation, interpolation and approximation schemes in splipy lies the basis function evaluation contained in BSplineBasis.evaluate. In this commit, this function is moved to a compiled language "cython" which greatly increases its speed at the cost of generality.

I'm opening a PR on this for increased visibility, but I do not plan to merge this on trunk anytime soon.

Limitations

This only works on linux platforms which is why it was never released officially on pip

Advantages

The speedup of cython evaluation when compared to the old pure python counterpart is a factor 100x as is seen when running benchmarks through pytest:

------------------------------------------------------------------------------------- benchmark 'evaluate-basis': 4 tests -------------------------------------------------------------------------------------
Name (time in us)                Min                    Max                   Mean              StdDev                 Median                 IQR            Outliers         OPS            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_evaluate_cython        289.3780 (1.0)         776.7820 (1.0)         297.1322 (1.0)       20.5085 (1.0)         293.4075 (1.0)        3.3030 (1.0)        68;269  3,365.5058 (1.0)        2382           1
test_evaluate_old        28,261.9550 (97.66)    33,605.0990 (43.26)    28,881.6505 (97.20)    937.1762 (45.70)    28,579.8615 (97.41)    494.0110 (149.56)        2;2     34.6241 (0.01)         34           1
test_evaluate_dense      29,232.9840 (101.02)   30,364.6940 (39.09)    29,676.2566 (99.88)    263.6799 (12.86)    29,627.2280 (100.98)   303.4720 (91.88)         9;2     33.6970 (0.01)         33           1
test_evaluate_sparse     29,367.1640 (101.48)   30,472.8860 (39.23)    29,852.1572 (100.47)   246.9262 (12.04)    29,851.6680 (101.74)   310.1035 (93.89)         9;1     33.4984 (0.01)         33           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
VikingScientist commented 4 years ago

I like the commit message on this one with its "revert revoke" prefix

VikingScientist commented 4 years ago

Merged in #115