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

tracking: performance optimizations #451

Open
0xalpharush opened this issue Aug 22, 2024 · 2 comments
Open

tracking: performance optimizations #451

0xalpharush opened this issue Aug 22, 2024 · 2 comments

Comments

@0xalpharush
Copy link
Contributor

We don't need a state commitment and it's slow so let's mock it and re-execute transactions as needed (we are already doing this for tracing after the latest go-ethereum upgrade). The only trie that is loaded from the db rn is the genesis and/or post-deployment state AFAIK.

medusa/chain/test_chain.go

Lines 828 to 830 in b81a9bc

// Perform a state commit to obtain the root hash for our block.
root, err := t.state.Commit(t.pendingBlock.Header.Number.Uint64(), true)
t.pendingBlock.Header.Root = root

root = statedb.IntermediateRoot(config.IsEIP158(blockNumber)).Bytes()

We should simplify the main fuzz loop to just be changing the block num/timestamp in the block context and not doing all the complex stuff with pending/discarding blocks as if it's a real chain IMO

medusa/chain/test_chain.go

Lines 742 to 743 in b81a9bc

// Create a new context to be used in the EVM environment
blockContext := newTestChainBlockContext(t, t.pendingBlock.Header)

@bsamuels453
Copy link

bsamuels453 commented Aug 28, 2024

consider removing bloom filter calculations (CreateBloom) as well

eats up about 4-5% of the cpu time of EVMApplyTransaction.

if we do this, plan on adding a way to query the list of logs generated by a tx/block since we might still need it for other features

@0xalpharush
Copy link
Contributor Author

0xalpharush commented Aug 29, 2024

Looking at the CPU report of pprof the most notable improvement we can make is probably memoizing this

// Obtain our contract coverage map lookup hash.
if callFrameState.lookupHash == nil {
lookupHash := getContractCoverageMapHash(code, callFrameState.create)
callFrameState.lookupHash = &lookupHash
}

Screenshot 2024-08-29 at 12 36 17 PM

EDIT: This is done #472

@0xalpharush 0xalpharush changed the title Remove all trie computations tracking: performance optimizations Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants