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

msm: semaphore to limit CPUs + better split strategy (up to 25% perf boost on 96cores) #403

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented May 8, 2023

This PR fixes #269 by introducing a semaphore when the MSM has a NbTasks parameter smaller than available CPUs.

Additionally, it revisits the heuristic to decide if it's worth it to split a msm into 2 (parallelization) and this result in some noticeable gains on our reference machine (aws hpc w/ 96 cores);

BenchmarkMultiExpG1/32_points-96                       327401         321755         -1.72%
BenchmarkMultiExpG1/32_points-smallvalues-96           311009         314889         +1.25%
BenchmarkMultiExpG1/32_points-redundancy-96            304380         309269         +1.61%
BenchmarkMultiExpG1/64_points-96                       386807         399116         +3.18%
BenchmarkMultiExpG1/64_points-smallvalues-96           382944         405201         +5.81%
BenchmarkMultiExpG1/64_points-redundancy-96            353195         350016         -0.90%
BenchmarkMultiExpG1/128_points-96                      508717         485115         -4.64%
BenchmarkMultiExpG1/128_points-smallvalues-96          500944         488468         -2.49%
BenchmarkMultiExpG1/128_points-redundancy-96           444654         454710         +2.26%
BenchmarkMultiExpG1/256_points-96                      631444         592283         -6.20%
BenchmarkMultiExpG1/256_points-smallvalues-96          575041         575244         +0.04%
BenchmarkMultiExpG1/256_points-redundancy-96           521282         534379         +2.51%
BenchmarkMultiExpG1/512_points-96                      752645         738090         -1.93%
BenchmarkMultiExpG1/512_points-smallvalues-96          788867         727497         -7.78%
BenchmarkMultiExpG1/512_points-redundancy-96           708452         679447         -4.09%
BenchmarkMultiExpG1/1024_points-96                     982689         944976         -3.84%
BenchmarkMultiExpG1/1024_points-smallvalues-96         990555         924593         -6.66%
BenchmarkMultiExpG1/1024_points-redundancy-96          923502         875818         -5.16%
BenchmarkMultiExpG1/2048_points-96                     1449082        1294379        -10.68%
BenchmarkMultiExpG1/2048_points-smallvalues-96         1414236        1229068        -13.09%
BenchmarkMultiExpG1/2048_points-redundancy-96          1295271        1175792        -9.22%
BenchmarkMultiExpG1/4096_points-96                     2085203        1781633        -14.56%
BenchmarkMultiExpG1/4096_points-smallvalues-96         2157690        1865174        -13.56%
BenchmarkMultiExpG1/4096_points-redundancy-96          2092848        1736579        -17.02%
BenchmarkMultiExpG1/8192_points-96                     3025724        2480464        -18.02%
BenchmarkMultiExpG1/8192_points-smallvalues-96         2892254        2425291        -16.15%
BenchmarkMultiExpG1/8192_points-redundancy-96          2783529        2320568        -16.63%
BenchmarkMultiExpG1/16384_points-96                    4510822        3794422        -15.88%
BenchmarkMultiExpG1/16384_points-smallvalues-96        4611577        4137253        -10.29%
BenchmarkMultiExpG1/16384_points-redundancy-96         4917603        3740932        -23.93%
BenchmarkMultiExpG1/32768_points-96                    7498927        6453743        -13.94%
BenchmarkMultiExpG1/32768_points-smallvalues-96        7904327        7382794        -6.60%
BenchmarkMultiExpG1/32768_points-redundancy-96         9362676        6137316        -34.45%
BenchmarkMultiExpG1/65536_points-96                    13543243       10923930       -19.34%
BenchmarkMultiExpG1/65536_points-smallvalues-96        13774630       11240420       -18.40%
BenchmarkMultiExpG1/65536_points-redundancy-96         15251163       11893144       -22.02%
BenchmarkMultiExpG1/131072_points-96                   24667428       18600625       -24.59%
BenchmarkMultiExpG1/131072_points-smallvalues-96       16858509       19325035       +14.63%
BenchmarkMultiExpG1/131072_points-redundancy-96        17304408       21860954       +26.33%
BenchmarkMultiExpG1/262144_points-96                   31878446       27247364       -14.53%
BenchmarkMultiExpG1/262144_points-smallvalues-96       31506573       29903329       -5.09%
BenchmarkMultiExpG1/262144_points-redundancy-96        33713084       32366152       -4.00%
BenchmarkMultiExpG1/524288_points-96                   58810510       52820165       -10.19%
BenchmarkMultiExpG1/524288_points-smallvalues-96       64905743       56003531       -13.72%
BenchmarkMultiExpG1/524288_points-redundancy-96        84538547       63161207       -25.29%
BenchmarkMultiExpG1/1048576_points-96                  113699503      102988409      -9.42%
BenchmarkMultiExpG1/1048576_points-smallvalues-96      127858512      108100661      -15.45%
BenchmarkMultiExpG1/1048576_points-redundancy-96       133258407      123546612      -7.29%
BenchmarkMultiExpG1/2097152_points-96                  223833891      216214307      -3.40%
BenchmarkMultiExpG1/2097152_points-smallvalues-96      237968346      228441042      -4.00%
BenchmarkMultiExpG1/2097152_points-redundancy-96       249153114      259179318      +4.02%
BenchmarkMultiExpG1/4194304_points-96                  398882329      338510504      -15.14%
BenchmarkMultiExpG1/4194304_points-smallvalues-96      428621784      362486074      -15.43%
BenchmarkMultiExpG1/4194304_points-redundancy-96       462562064      406775819      -12.06%
BenchmarkMultiExpG1/8388608_points-96                  739058637      662146690      -10.41%
BenchmarkMultiExpG1/8388608_points-smallvalues-96      806492486      699046536      -13.32%
BenchmarkMultiExpG1/8388608_points-redundancy-96       898269025      708105713      -21.17%
BenchmarkMultiExpG1/16777216_points-96                 1488257482     1191146328     -19.96%
BenchmarkMultiExpG1/16777216_points-smallvalues-96     1492737756     1252325303     -16.11%
BenchmarkMultiExpG1/16777216_points-redundancy-96      1746767789     1322819146     -24.27%
BenchmarkMultiExpG2/32_points-96                       638585         638668         +0.01%
BenchmarkMultiExpG2/32_points-smallvalues-96           634666         634983         +0.05%
BenchmarkMultiExpG2/32_points-redundancy-96            592647         600617         +1.34%
BenchmarkMultiExpG2/64_points-96                       761122         757613         -0.46%
BenchmarkMultiExpG2/64_points-smallvalues-96           749023         750656         +0.22%
BenchmarkMultiExpG2/64_points-redundancy-96            695057         707707         +1.82%
BenchmarkMultiExpG2/128_points-96                      906985         913358         +0.70%
BenchmarkMultiExpG2/128_points-smallvalues-96          899359         894607         -0.53%
BenchmarkMultiExpG2/128_points-redundancy-96           887100         835173         -5.85%
BenchmarkMultiExpG2/256_points-96                      1133083        1079976        -4.69%
BenchmarkMultiExpG2/256_points-smallvalues-96          1121605        1075911        -4.07%
BenchmarkMultiExpG2/256_points-redundancy-96           1095646        1000072        -8.72%
BenchmarkMultiExpG2/512_points-96                      1411844        1361207        -3.59%
BenchmarkMultiExpG2/512_points-smallvalues-96          1386061        1384758        -0.09%
BenchmarkMultiExpG2/512_points-redundancy-96           1335372        1281565        -4.03%
BenchmarkMultiExpG2/1024_points-96                     2084482        1962867        -5.83%
BenchmarkMultiExpG2/1024_points-smallvalues-96         1996537        1907398        -4.46%
BenchmarkMultiExpG2/1024_points-redundancy-96          1895181        1695670        -10.53%
BenchmarkMultiExpG2/2048_points-96                     2683672        2354556        -12.26%
BenchmarkMultiExpG2/2048_points-smallvalues-96         2670599        2480385        -7.12%
BenchmarkMultiExpG2/2048_points-redundancy-96          2661723        2295406        -13.76%
BenchmarkMultiExpG2/4096_points-96                     3997941        3751463        -6.17%
BenchmarkMultiExpG2/4096_points-smallvalues-96         3998818        3702869        -7.40%
BenchmarkMultiExpG2/4096_points-redundancy-96          3936731        3591620        -8.77%
BenchmarkMultiExpG2/8192_points-96                     6397008        5934513        -7.23%
BenchmarkMultiExpG2/8192_points-smallvalues-96         6306886        5723582        -9.25%
BenchmarkMultiExpG2/8192_points-redundancy-96          6006736        5713436        -4.88%
BenchmarkMultiExpG2/16384_points-96                    10376980       9306092        -10.32%
BenchmarkMultiExpG2/16384_points-smallvalues-96        10379099       9642047        -7.10%
BenchmarkMultiExpG2/16384_points-redundancy-96         11196384       8781211        -21.57%
BenchmarkMultiExpG2/32768_points-96                    17250773       16208197       -6.04%
BenchmarkMultiExpG2/32768_points-smallvalues-96        18644895       16881485       -9.46%
BenchmarkMultiExpG2/32768_points-redundancy-96         21795695       15883130       -27.13%
BenchmarkMultiExpG2/65536_points-96                    26781600       24341193       -9.11%
BenchmarkMultiExpG2/65536_points-smallvalues-96        32814865       25981450       -20.82%
BenchmarkMultiExpG2/65536_points-redundancy-96         32165668       30469548       -5.27%
BenchmarkMultiExpG2/131072_points-96                   39070259       40439373       +3.50%
BenchmarkMultiExpG2/131072_points-smallvalues-96       40481212       40295419       -0.46%
BenchmarkMultiExpG2/131072_points-redundancy-96        47162983       52780730       +11.91%
BenchmarkMultiExpG2/262144_points-96                   76631778       68889621       -10.10%
BenchmarkMultiExpG2/262144_points-smallvalues-96       76471465       72575848       -5.09%
BenchmarkMultiExpG2/262144_points-redundancy-96        89791042       91834827       +2.28%
BenchmarkMultiExpG2/524288_points-96                   137436942      129320175      -5.91%
BenchmarkMultiExpG2/524288_points-smallvalues-96       155879149      147114332      -5.62%
BenchmarkMultiExpG2/524288_points-redundancy-96        246710904      180653627      -26.78%
BenchmarkMultiExpG2/1048576_points-96                  344298791      275237375      -20.06%
BenchmarkMultiExpG2/1048576_points-smallvalues-96      350704216      303612692      -13.43%
BenchmarkMultiExpG2/1048576_points-redundancy-96       352475308      362878166      +2.95%
BenchmarkMultiExpG2/2097152_points-96                  644483916      573325482      -11.04%
BenchmarkMultiExpG2/2097152_points-smallvalues-96      618112810      619546779      +0.23%
BenchmarkMultiExpG2/2097152_points-redundancy-96       663478718      666394920      +0.44%
BenchmarkMultiExpG2/4194304_points-96                  1032104377     837934765      -18.81%
BenchmarkMultiExpG2/4194304_points-smallvalues-96      1119005923     885782366      -20.84%
BenchmarkMultiExpG2/4194304_points-redundancy-96       1254040458     1003086447     -20.01%
BenchmarkMultiExpG2/8388608_points-96                  1994499528     1791175296     -10.19%
BenchmarkMultiExpG2/8388608_points-smallvalues-96      2108917042     1725956851     -18.16%
BenchmarkMultiExpG2/8388608_points-redundancy-96       2405604610     1858394300     -22.75%
BenchmarkMultiExpG2/16777216_points-96                 3805535019     3099428789     -18.55%
BenchmarkMultiExpG2/16777216_points-smallvalues-96     4068009844     3128809045     -23.09%
BenchmarkMultiExpG2/16777216_points-redundancy-96      4727332985     3492094011     -26.13%

@gbotrel gbotrel requested a review from Tabaie May 10, 2023 21:38
Copy link
Collaborator

@yelhousni yelhousni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the logic of the split heuristics and the semaphore when NbTasks < NumCPU and it look good to me — but that's all ^^
I guess the PR might need an additional review of the code?

ecc/bls12-377/multiexp.go Outdated Show resolved Hide resolved
@gbotrel gbotrel merged commit 1f40d7c into develop Jun 6, 2023
@gbotrel gbotrel deleted the perf/msmtuning branch June 6, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiExponentiation: handle less tasks (go routines) than chunks
2 participants