Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rust-based formula dispersion #140

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

domna
Copy link
Member

@domna domna commented May 17, 2023

This is an example for using the rust-based formula dispersion. The idea was that it would be faster but currently it is beaten by the python code with caching.

Remaining steps:

  • Add caching in rust to see how it competes against python
  • Check the failing tests due to divide by zero.

@domna
Copy link
Member Author

domna commented May 17, 2023

Current benchmark with rust bindings:

---------------------------------------------------------------------------------------- benchmark: 6 tests ----------------------------------------------------------------------------------------
Name (time in ms)                    Min                 Max                Mean            StdDev              Median               IQR            Outliers       OPS            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_solver2x2                    4.0192 (1.0)        4.3147 (1.0)        4.1237 (1.0)      0.1047 (1.0)        4.0976 (1.0)      0.1540 (1.06)          2;0  242.4982 (1.0)          10           1
test_solver4x4_linear             4.5520 (1.13)       5.1403 (1.19)       4.7223 (1.15)     0.2002 (1.91)       4.6689 (1.14)     0.1447 (1.0)           2;2  211.7610 (0.87)         10           1
test_formula_solver2x2           34.5330 (8.59)      37.3116 (8.65)      35.0623 (8.50)     0.9151 (8.74)      34.6667 (8.46)     0.4209 (2.91)          2;2   28.5206 (0.12)         10           1
test_solver4x4_expm              97.3387 (24.22)    113.2001 (26.24)    102.1455 (24.77)    5.8321 (55.72)     99.5078 (24.28)    6.1350 (42.40)         2;0    9.7900 (0.04)         10           1
test_solver4x4_eig              116.8847 (29.08)    142.2197 (32.96)    122.6364 (29.74)    8.0648 (77.05)    119.1867 (29.09)    4.6113 (31.87)         2;2    8.1542 (0.03)         10           1
test_formula_solver4x4_expm     130.7959 (32.54)    157.7426 (36.56)    141.9801 (34.43)    7.0223 (67.09)    141.1741 (34.45)    6.8183 (47.12)         2;1    7.0432 (0.03)         10           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

and with the lark solution

----------------------------------------------------------------------------------------- benchmark: 6 tests -----------------------------------------------------------------------------------------
Name (time in ms)                    Min                 Max                Mean             StdDev              Median                IQR            Outliers       OPS            Rounds  Iterations
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_solver2x2                    3.9415 (1.0)        4.3081 (1.0)        4.0660 (1.0)       0.1016 (1.0)        4.0562 (1.0)       0.0822 (1.0)           3;1  245.9445 (1.0)          10           1
test_solver4x4_linear             4.4783 (1.14)       8.3134 (1.93)       5.0594 (1.24)      1.1572 (11.39)      4.7603 (1.17)      0.3639 (4.43)          1;1  197.6522 (0.80)         10           1
test_formula_solver2x2            6.4304 (1.63)       7.3308 (1.70)       6.8158 (1.68)      0.3166 (3.11)       6.6792 (1.65)      0.5148 (6.27)          3;0  146.7171 (0.60)         10           1
test_solver4x4_expm              96.9094 (24.59)    112.8189 (26.19)    103.5800 (25.47)     5.8240 (57.31)    103.3014 (25.47)    11.4601 (139.48)        5;0    9.6544 (0.04)         10           1
test_formula_solver4x4_expm     104.3337 (26.47)    114.8527 (26.66)    109.5190 (26.94)     3.7164 (36.57)    109.3881 (26.97)     5.3687 (65.34)         3;0    9.1308 (0.04)         10           1
test_solver4x4_eig              117.8164 (29.89)    175.5635 (40.75)    131.5376 (32.35)    19.2656 (189.56)   122.8863 (30.30)    16.9499 (206.29)        2;1    7.6024 (0.03)         10           1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Lark w/o caching

----------------------------------------------------------------------------------------- benchmark: 6 tests -----------------------------------------------------------------------------------------
Name (time in ms)                    Min                 Max                Mean             StdDev              Median                IQR            Outliers       OPS            Rounds  Iterations
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_solver2x2                    4.0126 (1.0)        4.9825 (1.0)        4.2277 (1.0)       0.2915 (1.0)        4.1439 (1.0)       0.2139 (1.0)           1;1  236.5371 (1.0)          10           1
test_solver4x4_linear             4.7363 (1.18)       5.6909 (1.14)       5.1664 (1.22)      0.3476 (1.19)       5.1904 (1.25)      0.6990 (3.27)          4;0  193.5601 (0.82)         10           1
test_formula_solver2x2           14.9416 (3.72)      22.6433 (4.54)      17.9399 (4.24)      3.0592 (10.50)     17.0598 (4.12)      4.6519 (21.75)         2;0   55.7416 (0.24)         10           1
test_solver4x4_expm             112.5193 (28.04)    233.2547 (46.81)    134.6708 (31.85)    35.4077 (121.49)   123.9062 (29.90)    13.5108 (63.16)         1;1    7.4255 (0.03)         10           1
test_solver4x4_eig              124.5915 (31.05)    192.9339 (38.72)    141.7874 (33.54)    21.6871 (74.41)    130.9245 (31.59)    28.0991 (131.36)        1;0    7.0528 (0.03)         10           1
test_formula_solver4x4_expm     138.4375 (34.50)    318.3715 (63.90)    213.8903 (50.59)    62.7734 (215.38)   206.2821 (49.78)    75.0714 (350.94)        5;0    4.6753 (0.02)         10           1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@domna
Copy link
Member Author

domna commented May 18, 2023

Benchmark with caching in rust (formula-dispersion>=0.1.1)

---------------------------------------------------------------------------------------- benchmark: 6 tests ----------------------------------------------------------------------------------------
Name (time in ms)                    Min                 Max                Mean            StdDev              Median               IQR            Outliers       OPS            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_solver2x2                    4.0317 (1.0)        4.3632 (1.0)        4.1157 (1.0)      0.0982 (1.0)        4.0971 (1.0)      0.0969 (1.0)           1;1  242.9706 (1.0)          10           1
test_solver4x4_linear             4.5299 (1.12)       5.8187 (1.33)       4.9238 (1.20)     0.4041 (4.11)       4.7483 (1.16)     0.4865 (5.02)          2;0  203.0957 (0.84)         10           1
test_formula_solver2x2            6.6203 (1.64)       8.9543 (2.05)       7.0274 (1.71)     0.7218 (7.35)       6.6708 (1.63)     0.5754 (5.94)          1;1  142.2999 (0.59)         10           1
test_solver4x4_expm              94.2108 (23.37)    109.6198 (25.12)     99.4445 (24.16)    5.1493 (52.44)     97.7993 (23.87)    7.9399 (81.96)         3;0   10.0559 (0.04)         10           1
test_formula_solver4x4_expm      98.1222 (24.34)    107.2682 (24.58)    101.2886 (24.61)    3.2138 (32.73)    100.1234 (24.44)    3.7288 (38.49)         2;0    9.8728 (0.04)         10           1
test_solver4x4_eig              117.1295 (29.05)    132.7289 (30.42)    120.4412 (29.26)    5.5503 (56.52)    117.6996 (28.73)    2.2705 (23.44)         2;2    8.3028 (0.03)         10           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@domna domna marked this pull request as draft July 15, 2023 08:22
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.

None yet

1 participant