core/vm: avoid unnecessary stack memory copies during gas calc#15561
Closed
karalabe wants to merge 1 commit into
Closed
core/vm: avoid unnecessary stack memory copies during gas calc#15561karalabe wants to merge 1 commit into
karalabe wants to merge 1 commit into
Conversation
Contributor
|
The copy was introduced for trace compatibility in #15035. I already complained there that this is a super annoying hack. This PR makes the hack more complicated. The real solution is to add a struct field, e.g. |
Contributor
I agree, but I also thinks that this change -- which only touches code within |
Contributor
|
#15563 implements my suggestion. |
Member
Author
|
Closing in favor of #15563. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes two batches of unnecessary memory allocations and copies with regard to EVM stack and gas calculation:
CALL*opcode is executed, the gas allowance on the EVM stack is replaced according to the63/64fork rule. I don't see a reason to allocate a newbig.Intfor the new stack item. If we're overwriting anyway, we can overwrite the existing content.CALL*opcodes, the EVM tracer currently copied the entire stack for every single opcode. This is insanely wasteful since we're only changing 1 value very rarely, and the tracer copied all values all the time to handle it. The PR contains a very very selective logic for saving the original stack item only if it will actually change. This saves us about 27% of tracing time.