-
Notifications
You must be signed in to change notification settings - Fork 390
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
Reduce Evm Stackspace clearing #5826
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need all tests known to man to run here (hive ect.)
Do you know what is the speedup?
Maybe all the created methods should also have [SkipLocalsInit] ?
(long)length * GasCostOf.LogData, ref gasAvailable)) return false; | ||
|
||
ReadOnlyMemory<byte> data = vmState.Memory.Load(in position, length); | ||
Keccak[] topics = new Keccak[topicsCount]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea - Pool those arrays between blocks?
|
||
LogEntry logEntry = new( | ||
vmState.Env.ExecutingAccount, | ||
data.ToArray(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here, maybe we can do some between-block Pool? Need to check all other places in VM.
As there are a large number of
CALL
/DELEGATECALL
/STATICCALL
per transaction and each call becomes both a call and call back theExecuteCall
/Code
method is executed many times. On currently on entering the method it zeros 9136 bytes of stack.Some blocks can make up to 4k+ calls meaning 8k+ method entries for these heavy blocks or 70MB. Also the method is 26.5kb of asm which reduces the Jits willingness to optimize and is a large code chunk for a hot loop.
e.g. in the example below 7 blocks execute 724 txs which calls ExecuteCall 10.5k times meaning 92MB of stack needs to be cleared
This change reduces to to 1328 bytes of stack or 78MB less in the example above; and reduced the hot loop from 26.5kB to 17.2kB so is more likely to be hotter in the CPU L1 execution cache (32KB - 48KB)
Changes
ExecuteCall
->ExecuteCall
+ExecuteCode
; the first being setup and second being hot loop to reduce register pressure on the loop from the setup.if
checks from the compiled Asm when tracing is not enabled (the Jit will generate a new method for each different struct generic parameter, so can use this to make compile time if checks and then remove the branching and dead code)Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Optional. Remove if not applicable.
Remarks
Optional. Remove if not applicable.