ethereumjs-monorepo icon indicating copy to clipboard operation
ethereumjs-monorepo copied to clipboard

Hybrid EVM Stack Experiment

Open holgerd77 opened this issue 2 years ago • 2 comments

This is a pretty extensive experiment switching the current BigInt based EVM stack with a hybrid stack which stores either the Bytes or the BigInt values and - if matches - serves the respetive values without conversion.

Results are unfortunately a lot more mixed than I anticipated. One opcode significantly increases in performance (MLOAD, going from 2.9 to 4.4 or so), but other values are mixed throughout the range, some somewhat faster, some somewhat slower.

Might come back to this with some distance, atm I am bit baffled that there is "not more to see".

Here is e.g. a resultset on the same block (left is with the hybrid stack).

grafik

My initial idea was to keep the old stack, but introduce a flag which would allow to switch to the new one. If results remain this mixed this might be obsolete though.

This work might nevertheless be useful for some things, e.g. it is now extremely easily possible to switch e.g. arithmetic operations from being done bigint based to byte based and see how performance reacts.

holgerd77 avatar Sep 15 '23 11:09 holgerd77

  • This stack implementation is significantly more performant than the single type stack. Atm it is however
  • not activated by default for backwards compatibility reasons.

I was so confident in the outcome here that I had even already written class documentation before I had first results mentioning the increased performance. 😆

holgerd77 avatar Sep 15 '23 11:09 holgerd77

Codecov Report

Merging #3029 (e71f171) into master (67a20de) will increase coverage by 3.39%. The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.73% <ø> (ø)
blockchain 92.58% <ø> (ø)
client 87.47% <ø> (+0.04%) :arrow_up:
common 98.18% <ø> (ø)
ethash ∅ <ø> (∅)
evm ?
rlp ∅ <ø> (∅)
statemanager 89.91% <ø> (ø)
trie 90.18% <ø> (ø)
tx 96.35% <ø> (ø)
util 86.78% <ø> (ø)
vm ?

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Sep 15 '23 11:09 codecov[bot]