Skip to content

[Optimization] Make Z inline better #6839

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plutus-benchmark/bitwise/test/9.6/8 queens.budget.golden
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 409142294016
| mem: 1575213647})
({cpu: 432732134016
| mem: 1722650147})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm rather puzzled as to how eta-expanding Z leads to such a massive slowdown.

2 changes: 1 addition & 1 deletion plutus-benchmark/bitwise/test/9.6/8 queens.size.golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
397
400
4 changes: 2 additions & 2 deletions plutus-benchmark/bitwise/test/9.6/Ed25519.budget.golden
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 2137054479882
| mem: 7088444574})
({cpu: 2137708431882
| mem: 7092531774})
2 changes: 1 addition & 1 deletion plutus-benchmark/bitwise/test/9.6/Ed25519.size.golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3417
3420
134 changes: 67 additions & 67 deletions plutus-benchmark/bls12-381-costs/test/9.6/bls12-381-costs.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,88 @@ Hash n bytestrings onto G1 and add points

n Script size CPU usage Memory usage
----------------------------------------------------------------------
0 115 (0.7%) 53556222 (0.5%) 3918 (0.0%)
10 224 (1.4%) 593877682 (5.9%) 37278 (0.3%)
20 334 (2.0%) 1134199142 (11.3%) 70638 (0.5%)
30 444 (2.7%) 1674520602 (16.7%) 103998 (0.7%)
40 554 (3.4%) 2214842062 (22.1%) 137358 (1.0%)
50 664 (4.1%) 2755163522 (27.6%) 170718 (1.2%)
60 774 (4.7%) 3295484982 (33.0%) 204078 (1.5%)
70 884 (5.4%) 3835806442 (38.4%) 237438 (1.7%)
80 994 (6.1%) 4376127902 (43.8%) 270798 (1.9%)
90 1104 (6.7%) 4916449362 (49.2%) 304158 (2.2%)
100 1214 (7.4%) 5456770822 (54.6%) 337518 (2.4%)
110 1324 (8.1%) 5997092282 (60.0%) 370878 (2.6%)
120 1434 (8.8%) 6537413742 (65.4%) 404238 (2.9%)
130 1544 (9.4%) 7077735202 (70.8%) 437598 (3.1%)
140 1654 (10.1%) 7618056662 (76.2%) 470958 (3.4%)
150 1764 (10.8%) 8158378122 (81.6%) 504318 (3.6%)
0 112 (0.7%) 53508222 (0.5%) 3618 (0.0%)
10 222 (1.4%) 593829682 (5.9%) 36978 (0.3%)
20 332 (2.0%) 1134151142 (11.3%) 70338 (0.5%)
30 442 (2.7%) 1674472602 (16.7%) 103698 (0.7%)
40 552 (3.4%) 2214794062 (22.1%) 137058 (1.0%)
50 662 (4.0%) 2755115522 (27.6%) 170418 (1.2%)
60 772 (4.7%) 3295436982 (33.0%) 203778 (1.5%)
70 882 (5.4%) 3835758442 (38.4%) 237138 (1.7%)
80 992 (6.1%) 4376079902 (43.8%) 270498 (1.9%)
90 1102 (6.7%) 4916401362 (49.2%) 303858 (2.2%)
100 1212 (7.4%) 5456722822 (54.6%) 337218 (2.4%)
110 1322 (8.1%) 5997044282 (60.0%) 370578 (2.6%)
120 1432 (8.7%) 6537365742 (65.4%) 403938 (2.9%)
130 1542 (9.4%) 7077687202 (70.8%) 437298 (3.1%)
140 1652 (10.1%) 7618008662 (76.2%) 470658 (3.4%)
150 1762 (10.8%) 8158330122 (81.6%) 504018 (3.6%)


Hash n bytestrings onto G2 and add points

n Script size CPU usage Memory usage
----------------------------------------------------------------------
0 163 (1.0%) 75306572 (0.8%) 3936 (0.0%)
10 272 (1.7%) 1769766432 (17.7%) 37656 (0.3%)
20 382 (2.3%) 3464226292 (34.6%) 71376 (0.5%)
30 492 (3.0%) 5158686152 (51.6%) 105096 (0.8%)
40 602 (3.7%) 6853146012 (68.5%) 138816 (1.0%)
50 712 (4.3%) 8547605872 (85.5%) 172536 (1.2%)
60 822 (5.0%) 10242065732 (102.4%) 206256 (1.5%)
70 932 (5.7%) 11936525592 (119.4%) 239976 (1.7%)
80 1042 (6.4%) 13630985452 (136.3%) 273696 (2.0%)
90 1152 (7.0%) 15325445312 (153.3%) 307416 (2.2%)
100 1262 (7.7%) 17019905172 (170.2%) 341136 (2.4%)
110 1372 (8.4%) 18714365032 (187.1%) 374856 (2.7%)
120 1482 (9.0%) 20408824892 (204.1%) 408576 (2.9%)
130 1592 (9.7%) 22103284752 (221.0%) 442296 (3.2%)
140 1702 (10.4%) 23797744612 (238.0%) 476016 (3.4%)
150 1812 (11.1%) 25492204472 (254.9%) 509736 (3.6%)
0 160 (1.0%) 75258572 (0.8%) 3636 (0.0%)
10 270 (1.6%) 1769718432 (17.7%) 37356 (0.3%)
20 380 (2.3%) 3464178292 (34.6%) 71076 (0.5%)
30 490 (3.0%) 5158638152 (51.6%) 104796 (0.7%)
40 600 (3.7%) 6853098012 (68.5%) 138516 (1.0%)
50 710 (4.3%) 8547557872 (85.5%) 172236 (1.2%)
60 820 (5.0%) 10242017732 (102.4%) 205956 (1.5%)
70 930 (5.7%) 11936477592 (119.4%) 239676 (1.7%)
80 1040 (6.3%) 13630937452 (136.3%) 273396 (2.0%)
90 1150 (7.0%) 15325397312 (153.3%) 307116 (2.2%)
100 1260 (7.7%) 17019857172 (170.2%) 340836 (2.4%)
110 1370 (8.4%) 18714317032 (187.1%) 374556 (2.7%)
120 1480 (9.0%) 20408776892 (204.1%) 408276 (2.9%)
130 1590 (9.7%) 22103236752 (221.0%) 441996 (3.2%)
140 1700 (10.4%) 23797696612 (238.0%) 475716 (3.4%)
150 1810 (11.0%) 25492156472 (254.9%) 509436 (3.6%)


Uncompress n G1 points and add the results

n Script size CPU usage Memory usage
----------------------------------------------------------------------
0 112 (0.7%) 53556222 (0.5%) 3918 (0.0%)
10 661 (4.0%) 597620792 (6.0%) 35278 (0.3%)
20 1211 (7.4%) 1141685362 (11.4%) 66638 (0.5%)
30 1761 (10.7%) 1685749932 (16.9%) 97998 (0.7%)
40 2311 (14.1%) 2229814502 (22.3%) 129358 (0.9%)
50 2861 (17.5%) 2773879072 (27.7%) 160718 (1.1%)
60 3411 (20.8%) 3317943642 (33.2%) 192078 (1.4%)
70 3961 (24.2%) 3862008212 (38.6%) 223438 (1.6%)
80 4511 (27.5%) 4406072782 (44.1%) 254798 (1.8%)
90 5061 (30.9%) 4950137352 (49.5%) 286158 (2.0%)
100 5611 (34.2%) 5494201922 (54.9%) 317518 (2.3%)
110 6161 (37.6%) 6038266492 (60.4%) 348878 (2.5%)
120 6711 (41.0%) 6582331062 (65.8%) 380238 (2.7%)
130 7261 (44.3%) 7126395632 (71.3%) 411598 (2.9%)
140 7811 (47.7%) 7670460202 (76.7%) 442958 (3.2%)
150 8361 (51.0%) 8214524772 (82.1%) 474318 (3.4%)
0 109 (0.7%) 53508222 (0.5%) 3618 (0.0%)
10 659 (4.0%) 597572792 (6.0%) 34978 (0.2%)
20 1209 (7.4%) 1141637362 (11.4%) 66338 (0.5%)
30 1759 (10.7%) 1685701932 (16.9%) 97698 (0.7%)
40 2309 (14.1%) 2229766502 (22.3%) 129058 (0.9%)
50 2859 (17.4%) 2773831072 (27.7%) 160418 (1.1%)
60 3409 (20.8%) 3317895642 (33.2%) 191778 (1.4%)
70 3959 (24.2%) 3861960212 (38.6%) 223138 (1.6%)
80 4509 (27.5%) 4406024782 (44.1%) 254498 (1.8%)
90 5059 (30.9%) 4950089352 (49.5%) 285858 (2.0%)
100 5609 (34.2%) 5494153922 (54.9%) 317218 (2.3%)
110 6159 (37.6%) 6038218492 (60.4%) 348578 (2.5%)
120 6709 (40.9%) 6582283062 (65.8%) 379938 (2.7%)
130 7259 (44.3%) 7126347632 (71.3%) 411298 (2.9%)
140 7809 (47.7%) 7670412202 (76.7%) 442658 (3.2%)
150 8359 (51.0%) 8214476772 (82.1%) 474018 (3.4%)


Uncompress n G2 points and add the results

n Script size CPU usage Memory usage
----------------------------------------------------------------------
0 160 (1.0%) 75306572 (0.8%) 3936 (0.0%)
10 1189 (7.3%) 847209652 (8.5%) 35656 (0.3%)
20 2219 (13.5%) 1619112732 (16.2%) 67376 (0.5%)
30 3249 (19.8%) 2391015812 (23.9%) 99096 (0.7%)
40 4279 (26.1%) 3162918892 (31.6%) 130816 (0.9%)
50 5309 (32.4%) 3934821972 (39.3%) 162536 (1.2%)
60 6339 (38.7%) 4706725052 (47.1%) 194256 (1.4%)
70 7369 (45.0%) 5478628132 (54.8%) 225976 (1.6%)
80 8399 (51.3%) 6250531212 (62.5%) 257696 (1.8%)
90 9429 (57.6%) 7022434292 (70.2%) 289416 (2.1%)
100 10459 (63.8%) 7794337372 (77.9%) 321136 (2.3%)
110 11489 (70.1%) 8566240452 (85.7%) 352856 (2.5%)
120 12519 (76.4%) 9338143532 (93.4%) 384576 (2.7%)
130 13549 (82.7%) 10110046612 (101.1%) 416296 (3.0%)
140 14579 (89.0%) 10881949692 (108.8%) 448016 (3.2%)
150 15609 (95.3%) 11653852772 (116.5%) 479736 (3.4%)
0 157 (1.0%) 75258572 (0.8%) 3636 (0.0%)
10 1187 (7.2%) 847161652 (8.5%) 35356 (0.3%)
20 2217 (13.5%) 1619064732 (16.2%) 67076 (0.5%)
30 3247 (19.8%) 2390967812 (23.9%) 98796 (0.7%)
40 4277 (26.1%) 3162870892 (31.6%) 130516 (0.9%)
50 5307 (32.4%) 3934773972 (39.3%) 162236 (1.2%)
60 6337 (38.7%) 4706677052 (47.1%) 193956 (1.4%)
70 7367 (45.0%) 5478580132 (54.8%) 225676 (1.6%)
80 8397 (51.3%) 6250483212 (62.5%) 257396 (1.8%)
90 9427 (57.5%) 7022386292 (70.2%) 289116 (2.1%)
100 10457 (63.8%) 7794289372 (77.9%) 320836 (2.3%)
110 11487 (70.1%) 8566192452 (85.7%) 352556 (2.5%)
120 12517 (76.4%) 9338095532 (93.4%) 384276 (2.7%)
130 13547 (82.7%) 10109998612 (101.1%) 415996 (3.0%)
140 14577 (89.0%) 10881901692 (108.8%) 447716 (3.2%)
150 15607 (95.3%) 11653804772 (116.5%) 479436 (3.4%)


Apply pairing to two pairs of points in G1 x G2 and run finalVerify on the results
Expand All @@ -103,7 +103,7 @@ VRF example

n Script size CPU usage Memory usage
----------------------------------------------------------------------
- 714 (4.4%) 1220805236 (12.2%) 48149 (0.3%)
- 717 (4.4%) 1220901236 (12.2%) 48749 (0.3%)

G1 Verify

Expand All @@ -121,13 +121,13 @@ Aggregate Single Key

n Script size CPU usage Memory usage
----------------------------------------------------------------------
- 846 (5.2%) 2720886359 (27.2%) 70002 (0.5%)
- 849 (5.2%) 2720982359 (27.2%) 70602 (0.5%)

Aggregate Multi Key

n Script size CPU usage Memory usage
----------------------------------------------------------------------
- 1832 (11.2%) 3446371236 (34.5%) 422386 (3.0%)
- 1834 (11.2%) 3447091236 (34.5%) 426886 (3.0%)

Schnorr Signature G1

Expand Down
32 changes: 16 additions & 16 deletions plutus-benchmark/ed25519-costs/test/9.6/ed25519-costs.golden
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
n Script size CPU usage Memory usage
----------------------------------------------------------------------
0 458 (2.8%) 5130441 (0.1%) 25722 (0.2%)
10 2185 (13.3%) 646555741 (6.5%) 514552 (3.7%)
20 3912 (23.9%) 1287981041 (12.9%) 1003382 (7.2%)
30 5639 (34.4%) 1929406341 (19.3%) 1492212 (10.7%)
40 7366 (45.0%) 2570831641 (25.7%) 1981042 (14.2%)
50 9092 (55.5%) 3212256941 (32.1%) 2469872 (17.6%)
60 10819 (66.0%) 3853682241 (38.5%) 2958702 (21.1%)
70 12546 (76.6%) 4495107541 (45.0%) 3447532 (24.6%)
80 14272 (87.1%) 5136532841 (51.4%) 3936362 (28.1%)
90 15999 (97.7%) 5777958141 (57.8%) 4425192 (31.6%)
100 17726 (108.2%) 6419383441 (64.2%) 4914022 (35.1%)
110 19453 (118.7%) 7060808741 (70.6%) 5402852 (38.6%)
120 21179 (129.3%) 7702234041 (77.0%) 5891682 (42.1%)
130 22906 (139.8%) 8343659341 (83.4%) 6380512 (45.6%)
140 24633 (150.3%) 8985084641 (89.9%) 6869342 (49.1%)
150 26360 (160.9%) 9626509941 (96.3%) 7358172 (52.6%)
0 460 (2.8%) 5226441 (0.1%) 26322 (0.2%)
10 2187 (13.3%) 646651741 (6.5%) 515152 (3.7%)
20 3914 (23.9%) 1288077041 (12.9%) 1003982 (7.2%)
30 5641 (34.4%) 1929502341 (19.3%) 1492812 (10.7%)
40 7368 (45.0%) 2570927641 (25.7%) 1981642 (14.2%)
50 9094 (55.5%) 3212352941 (32.1%) 2470472 (17.6%)
60 10821 (66.0%) 3853778241 (38.5%) 2959302 (21.1%)
70 12548 (76.6%) 4495203541 (45.0%) 3448132 (24.6%)
80 14274 (87.1%) 5136628841 (51.4%) 3936962 (28.1%)
90 16001 (97.7%) 5778054141 (57.8%) 4425792 (31.6%)
100 17728 (108.2%) 6419479441 (64.2%) 4914622 (35.1%)
110 19455 (118.7%) 7060904741 (70.6%) 5403452 (38.6%)
120 21181 (129.3%) 7702330041 (77.0%) 5892282 (42.1%)
130 22908 (139.8%) 8343755341 (83.4%) 6381112 (45.6%)
140 24635 (150.4%) 8985180641 (89.9%) 6869942 (49.1%)
150 26362 (160.9%) 9626605941 (96.3%) 7358772 (52.6%)

Off-chain version succeeded on 100 inputs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 197510904
| mem: 846852})
({cpu: 199958904
| mem: 862152})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 16499812194
| mem: 70488132})
({cpu: 16523860194
| mem: 70638432})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 59141074
| mem: 255392})
({cpu: 60389074
| mem: 263192})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 4212184144
| mem: 17998532})
({cpu: 4224232144
| mem: 18073832})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 117905780
| mem: 564480})
({cpu: 120353780
| mem: 579780})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 8992550900
| mem: 41599800})
({cpu: 9016598900
| mem: 41750100})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 37925190
| mem: 186640})
({cpu: 39173190
| mem: 194440})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 2323012500
| mem: 10794400})
({cpu: 2335060500
| mem: 10869700})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 203554074
| mem: 988490})
({cpu: 207634074
| mem: 1013990})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 296248136
| mem: 1507304})
({cpu: 302728136
| mem: 1547804})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 218828188
| mem: 1072854})
({cpu: 223052188
| mem: 1099254})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 177375938
| mem: 850422})
({cpu: 180495938
| mem: 869922})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 199201946
| mem: 960932})
({cpu: 202417946
| mem: 981032})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 185596754
| mem: 887072})
({cpu: 189100754
| mem: 908972})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 184435055
| mem: 880470})
({cpu: 187939055
| mem: 902370})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 231014344
| mem: 1131576})
({cpu: 234710344
| mem: 1154676})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 214343877
| mem: 1046444})
({cpu: 218327877
| mem: 1071344})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 198142226
| mem: 955410})
({cpu: 201742226
| mem: 977910})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 219510582
| mem: 1070794})
({cpu: 223590582
| mem: 1096294})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 220655269
| mem: 1084970})
({cpu: 224639269
| mem: 1109870})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 261001580
| mem: 1305298})
({cpu: 266425580
| mem: 1339198})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 181828760
| mem: 871944})
({cpu: 185332760
| mem: 893844})
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
({cpu: 195736220
| mem: 946208})
({cpu: 198952220
| mem: 966308})
Loading