Commit 891d46b
authored
chore!: opcode gas multipliers to account for slow simulation opcodes (#19130)
After these multipliers, all opcode-spam tests take 300ms or less (1
cpu, 8g ram). I chose the smallest whole-number multipliers to get us
there.
| Opcode | Multiplier | Original Cost | New Cost | Notes |
|--------|------------|---------------|------------|-------|
| FDIV | 25x | 9 | 225 | |
| SLOAD | 10x | 129 | 1,290 | |
| SSTORE | 20x | 1,657 | 33,140 | |
| NOTEHASHEXISTS | 4x | 126 | 504 | +1x for slow proving |
| EMITNOTEHASH | 15x | 1,285 | 19,275 | |
| NULLIFIEREXISTS | 7x | 132 | 924 | +1x for slow proving |
| EMITNULLIFIER | 20x | 1,540 | 30,800 | |
| L1TOL2MSGEXISTS | 5x | 108 | 540 | +1x for slow proving |
| SENDL2TOL1MSG | 2x | 209 | 418 | |
| CALL | 3x | 3,312 | 9,936 | |
| STATICCALL | 3x | 3,312 | 9,936 | |
| GETCONTRACTINSTANCE | 4x | 1,527 | 6,108 | Slow simulation |
| POSEIDON2 | 15x | 24 | 360 | |
| ECADD | 10x | 27 | 270 | |
## Discussion
For certain exceptionally slow-to-simulate opcodes, we are multiplying
their *L2 Gas* by a factor to normalize them relative to others. This
brings mana/s and worst-case simulation (when spamming an opcode) of
these outlier opcodes back near the others.
More concretely, we measured simulation time when meaningfully spamming
each opcode as many times as possible in a transaction. For such
transactions, these multipliers bring worst-case simulation down under
300ms/tx.
For context, non-outlier opcodes generally range from 150-250ms/tx (for
txs that infinitely spam the opcode).
*Note: this is only for L2 gas and is completely separate from DA gas.*
We have plans to make merkle/db optimizations in the future that might
let us reduce some of these multipliers, but that will be substantial
work that will not be complete for Alpha.
## Other changes
Gas cost changes cause AVM VK changes along with inner and outer
recursive verifier changes
## Follow-up work:
1. Commit the scripts used to measure these with consistent resources1 parent dd42d7e commit 891d46b
File tree
7 files changed
+78
-53
lines changed- barretenberg/cpp/src/barretenberg/vm2
- common
- constraining
- dsl
- docs/docs-developers/docs/resources
- noir-projects/noir-protocol-circuits/crates/types/src
- yarn-project
- constants/src
- simulator/src/public/fixtures
7 files changed
+78
-53
lines changedLines changed: 14 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
221 | 221 | | |
222 | | - | |
223 | | - | |
224 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
12 | 35 | | |
13 | 36 | | |
14 | 37 | | |
| |||
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
1099 | 1101 | | |
1100 | 1102 | | |
1101 | 1103 | | |
1102 | 1104 | | |
1103 | | - | |
| 1105 | + | |
1104 | 1106 | | |
1105 | 1107 | | |
1106 | 1108 | | |
| |||
1122 | 1124 | | |
1123 | 1125 | | |
1124 | 1126 | | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1133 | 1135 | | |
1134 | | - | |
| 1136 | + | |
1135 | 1137 | | |
1136 | | - | |
1137 | | - | |
| 1138 | + | |
| 1139 | + | |
1138 | 1140 | | |
1139 | 1141 | | |
1140 | 1142 | | |
1141 | | - | |
| 1143 | + | |
1142 | 1144 | | |
1143 | 1145 | | |
1144 | | - | |
| 1146 | + | |
1145 | 1147 | | |
1146 | 1148 | | |
1147 | 1149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
452 | 452 | | |
453 | | - | |
454 | | - | |
455 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
0 commit comments