Skip to content
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

Optimize EvmStack #5364

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Optimize EvmStack #5364

merged 1 commit into from
Mar 6, 2023

Conversation

benaadams
Copy link
Member

Changes

  • Load and endianness swap in one instruction
  • Tail call for Int256
  • Move exceptions out of flow
  • Move tracing loops out of flow

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

@benaadams
Copy link
Member Author

Running hive tests: https://github.com/NethermindEth/nethermind/actions/runs/4333660864 https://github.com/NethermindEth/nethermind/actions/runs/4333663830

✖ Invalid Transition Payload Re-Org, Incomplete Transactions, Reveal using sync (nethermind)
✖ Withdraw many accounts (nethermind)

These errors from this change? 🤔

@MarekM25
Copy link
Contributor

MarekM25 commented Mar 6, 2023

Running hive tests: https://github.com/NethermindEth/nethermind/actions/runs/4333660864 https://github.com/NethermindEth/nethermind/actions/runs/4333663830

✖ Invalid Transition Payload Re-Org, Incomplete Transactions, Reveal using sync (nethermind)
✖ Withdraw many accounts (nethermind)

These errors from this change? 🤔

Withdraw many accounts (nethermind) - this test is unstable for sure.
Unfortunately, I think this might be unstable as well:
✖ Invalid Transition Payload Re-Org, Incomplete Transactions, Reveal using sync (nethermind)

@rubo
Copy link
Contributor

rubo commented Mar 6, 2023

These errors from this change? 🤔

@benaadams Nope. They are just flaky.

}
}

public void PushSignedInt256(in Int256.Int256 value)
{
PushUInt256((UInt256)value);
// tail call into UInt256
Copy link
Contributor

Choose a reason for hiding this comment

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

QQ: Can you elaborate what you mean by "tail call" here? Does .net have some specific optimication in this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

No stack to clean up; return type and parameters match; so in the asm these method just turns into a single jump to the other methods

; Method Nethermind.Evm.EvmStack:PushSignedInt256(byref):this
G_M000_IG01:

G_M000_IG02:
       FF25D23F1400         tail.jmp [Nethermind.Evm.EvmStack:PushUInt256(byref):this]
; Total bytes of code: 6
; Method Nethermind.Evm.EvmStack:PopSignedInt256(byref):this
G_M000_IG01:

G_M000_IG02:
       FF2532401400         tail.jmp [Nethermind.Evm.EvmStack:PopUInt256(byref):this]
; Total bytes of code: 6

Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

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

Code looks fine, hive consensus tests are green, if engine tests would pass as well (or we will have same false-positive fails from master) I will feel comfortable with merging it

@LukaszRozmej LukaszRozmej merged commit ac2bafb into master Mar 6, 2023
@LukaszRozmej LukaszRozmej deleted the EvmStack branch March 6, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants