nimbus-eth1/nimbus
Jacek Sieka 8857fccb44
create per-fork opcode dispatcher (#2579)
In the current VM opcode dispatcher, a two-level case statement is
generated that first matches the opcode and then uses another nested
case statement to select the actual implementation based on which fork
it is, causing the dispatcher to grow by `O(opcodes) * O(forks)`.

The fork does not change between instructions causing significant
inefficiency for this approach - not only because it repeats the fork
lookup but also because of code size bloat and missed optimizations.

A second source of inefficiency in dispatching is the tracer code which
in the vast majority of cases is disabled but nevertheless sees multiple
conditionals being evaluated for each instruction only to remain
disabled throughout exeuction.

This PR rewrites the opcode dispatcher macro to generate a separate
dispatcher for each fork and tracer setting and goes on to pick the
right one at the start of the computation.

This has many advantages:

* much smaller dispatcher
* easier to compile
* better inlining
* fewer pointlessly repeated instruction
* simplified macro (!)
* slow "low-compiler-memory" dispatcher code can be removed

Net block import improvement at about 4-6% depending on the contract -
synthetic EVM benchmnarks would show an even better result most likely.
2024-08-28 10:20:36 +02:00
..
beacon Rewire blockValue from Txpool to EngineAPI (#2554) 2024-08-09 06:05:18 +07:00
common move db init to init (#2552) 2024-08-08 07:45:30 +02:00
core avoid exceptions, tx copy (#2569) 2024-08-19 09:42:07 +02:00
db Avoid unnecessary layer copy (#2567) 2024-08-19 08:46:04 +02:00
evm create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
graphql Use simpler schema when writing transactions, receipts, and withdrawals (#2420) 2024-06-29 12:43:17 +07:00
rpc Cleanup unused exp_getProofsByBlockNumber endpoint (#2577) 2024-08-23 22:39:33 +08:00
stateless Cleanup stateless and block witness code. (#2295) 2024-06-08 15:05:00 +07:00
sync Small updates and fixes for rlpx suite (#2571) 2024-08-19 14:00:10 +00:00
transaction avoid exceptions, tx copy (#2569) 2024-08-19 09:42:07 +02:00
utils avoid digest when loading era block (#2572) 2024-08-20 15:23:14 +02:00
common.nim implement better hardfork management 2022-12-02 13:51:42 +07:00
compile_info.nim Small updates and fixes for rlpx suite (#2571) 2024-08-19 14:00:10 +00:00
config.nim Don't write slot hashes on import (#2564) 2024-08-16 08:22:51 +02:00
constants.nim Convert GasInt to uint64, bump nim-eth and nimbus-eth2 (#2461) 2024-07-07 06:52:11 +00:00
errors.nim Remove EVM indirect imports and unused EVM errors (#2370) 2024-06-17 09:56:39 +02:00
launcher.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
makefile Snap sync fix trie interpolation fringe condition (#1457) 2023-02-01 18:56:06 +00:00
nim.cfg import: read from era files (#2254) 2024-05-31 09:13:56 +02:00
nimbus.nim move db init to init (#2552) 2024-08-08 07:45:30 +02:00
nimbus_desc.nim rm full sync (#2324) 2024-06-08 07:41:44 +07:00
nimbus_import.nim import: reduce stack usage (#2575) 2024-08-22 10:06:45 +02:00
rpc.nim log http/jwt information on startup (#2553) 2024-08-08 10:03:30 +00:00
tracer.nim Don't write slot hashes on import (#2564) 2024-08-16 08:22:51 +02:00
transaction.nim avoid exceptions, tx copy (#2569) 2024-08-19 09:42:07 +02:00
version.nim Add startup banner (#2354) 2024-06-14 10:08:44 +02:00