go-ethereum/core/vm
Martin HS 25bc07749c
core/vm: speed up push and interpreter loop (#30662)
Looking at the cpu profile of a burntpix benchmark, I noticed that a lot
of time was spent in gas-used, in the interpreter loop. It's an actual
call (not inlined), which explicitly wants to be ignored by tracing
("tracing.GasChangeIgnored"), so it can be safely and simply inlined.

The other change is in `pushX`. These also do a call to
`common.RightPadBytes`. I replaced that by a doing a corresponding `Lsh`
on the `u256` if needed. Note: it's needed only to make the stack output
look right, for fuzzers. It technically doesn't matter what we put
there: if code ends on a pushdata immediate, nothing will consume the
stack element. We could just as well just ignore it, if we didn't care
about fuzzers (which I do).

Seems quite a lot faster on burntpix, according to my runs. 

This PR:
```
EVM gas used:    5642735088
execution time:  34.84609475s
allocations:     915683
allocated bytes: 175334088
```
```
EVM gas used:    5642735088
execution time:  36.671958278s
allocations:     915701
allocated bytes: 175340528
```

Master
```
EVM gas used:    5642735088
execution time:  49.349209526s
allocations:     915684
allocated bytes: 175333368
```
```
EVM gas used:    5642735088
execution time:  46.581006598s
allocations:     915681
allocated bytes: 175330728
```

---------

Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2024-10-30 18:01:47 +01:00
..
runtime core/vm: speed up push and interpreter loop (#30662) 2024-10-30 18:01:47 +01:00
testdata core/vm: more benchmarks for bls g1/g2-multiexp precompiles (#30459) 2024-09-24 13:53:46 +02:00
analysis_eof.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
analysis_legacy.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
analysis_legacy_test.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
common.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-10-20 14:41:51 +03:00
contract.go cmd, core, params, trie: add verkle access witness gas charging (#29338) 2024-05-10 20:13:11 +02:00
contracts.go common: drop BigMin and BigMax, they pollute our dep graph (#30645) 2024-10-21 12:45:33 +03:00
contracts_fuzz_test.go eth/tracers: live chain tracing with hooks (#29189) 2024-03-22 18:53:53 +01:00
contracts_test.go core/vm: add KZG benchmark (#29583) 2024-04-19 13:46:43 +02:00
doc.go core/vm: remove JIT VM codes (#16362) 2018-03-26 13:48:04 +03:00
eips.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof_control_flow.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof_immediates.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof_instructions.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof_test.go core/vm: remove debug printout in eof test (#30665) 2024-10-24 09:13:01 +02:00
eof_validation.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
eof_validation_test.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
errors.go build: update to golangci-lint 1.61.0 (#30587) 2024-10-14 19:25:22 +02:00
evm.go eth/tracers: various fixes (#30540) 2024-10-17 06:51:47 +02:00
gas.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
gas_table.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
gas_table_test.go core/state: state reader abstraction (#29761) 2024-09-05 13:10:47 +03:00
instructions.go core/vm: speed up push and interpreter loop (#30662) 2024-10-30 18:01:47 +01:00
instructions_test.go core/vm: speed up push and interpreter loop (#30662) 2024-10-30 18:01:47 +01:00
interface.go core/state: move state log mechanism to a separate layer (#30569) 2024-10-23 08:03:36 +02:00
interpreter.go core/vm: speed up push and interpreter loop (#30662) 2024-10-30 18:01:47 +01:00
interpreter_test.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-10-20 14:41:51 +03:00
jump_table.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
jump_table_export.go core: fix typos (#28255) 2023-10-10 10:22:03 +02:00
jump_table_test.go all: fix typos in comments (#28881) 2024-02-05 22:16:32 +01:00
memory.go core/vm: reuse Memory instances (#30137) 2024-08-20 14:31:06 +02:00
memory_table.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
memory_test.go core/vm: implement EIP-5656, mcopy instruction (#26181) 2023-07-11 03:55:34 -04:00
opcodes.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
operations_acl.go core/vm, cmd/evm: implement eof validation (#30418) 2024-10-02 15:05:50 +02:00
operations_verkle.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-10-20 14:41:51 +03:00
stack.go core/vm: improved stack swap performance (#30249) 2024-08-06 14:38:47 +02:00
stack_table.go core/vm: 64 bit memory and gas calculations (#19210) 2019-03-12 11:40:05 +02:00