Skip to content

optimization: add back in the abi caching#492

Merged
gakonst merged 2 commits intomasterfrom
fix/cpu-usage
Apr 20, 2021
Merged

optimization: add back in the abi caching#492
gakonst merged 2 commits intomasterfrom
fix/cpu-usage

Conversation

@tynes
Copy link
Copy Markdown
Contributor

@tynes tynes commented Apr 19, 2021

Description
This adds back in geohot's optimization: ethereum-optimism/go-ethereum@8d13a77
It was recently removed but is still useful as it is still in the hot code path.

Below is a picture from the pprof CPU profiling before these changes

Screen Shot 2021-04-19 at 10 49 48 AM

This PR adds a cache to abi.Method.ID so that each call doesn't result in a bunch of hashing and reduces the amount of time that is spent in that method significantly.

It was generated with the following script on top of #477 so be sure to checkout that branch and make geth before running it:

#!/bin/bash

USING_OVM=true ./build/bin/geth \
    --datadir $HOME/.ethereum \
    --eth1.syncservice \
    --rollup.synctype sequenced \
    --eth1.l1crossdomainmessengeraddress 0xD1EC7d40CCd01EB7A305b94cBa8AB6D17f6a9eFE \
    --eth1.l1ethgatewayaddress 0xF20C38fCdDF0C790319Fd7431d17ea0c2bC9959c \
    --rollup.addressmanagerowneraddress 0x9BA6e03D8B90dE867373Db8cF1A58d2F7F006b3A \
    --rollup.statedumppath https://storage.googleapis.com/optimism/mainnet/3.json \
    --eth1.ctcdeploymentheight 12207792 \
    --rollup.clienthttp http://localhost:7878 \
    --rollup.verifier \
    --rpc \
    --dev \
    --chainid 10 \
    --rpcaddr 0.0.0.0 \
    --rpcport 8545 \
    --rpcvhosts '*' \
    --rpccorsdomain '*' \
    --ws \
    --wsaddr 0.0.0.0 \
    --wsport 8546 \
    --wsorigins '*' \
    --rpcapi 'eth,net,rollup,web3' \
    --gasprice 0 \
    --miner.gastarget 9000000 \
    --miner.gaslimit 9000000 \
    --nousb \
    --gcmode=archive \
    --ipcdisable \
    --verbosity=3 \
    --pprof \
    --cpuprofile cpu.prof

Run the above script and let geth run for some time and then SIGINT the process. This will result in the generation of the file cpu.prof.
Use pprof to create an SVG that can be viewed in the browser. The following command will drop you into the interactive pprof CLI, once you are in it use the svg command to generate an SVG

$ go tool pprof -lines cpu.prof

Once the SVG has been created, python3 can be used to serve it to the browser

$ python -m http.server --bind 0.0.0.0 8080 --directory .

Additional context
Need to do additional profiling to determine where the actual bottlenecks are but this was low hanging fruit

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 19, 2021

🦋 Changeset detected

Latest commit: 2ef52b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/l2geth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tynes tynes requested a review from gakonst April 19, 2021 18:03
Comment thread l2geth/accounts/abi/abi.go
@snario
Copy link
Copy Markdown
Contributor

snario commented Apr 19, 2021

We should consider adding some basic profiling to geth in the CI and upload a benchmark artifact that can we compare over time. If some benchmark gets worse than we can have an optional Check fail.

Copy link
Copy Markdown
Contributor

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

LGTM. Good catch.

@gakonst gakonst merged commit b290cfe into master Apr 20, 2021
@gakonst gakonst deleted the fix/cpu-usage branch April 20, 2021 05:36
InoMurko referenced this pull request in omgnetwork/optimism May 25, 2021
* optimization: add back in the geohot abi caching

* changeset: patch
theochap pushed a commit that referenced this pull request Jan 15, 2026
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

Successfully merging this pull request may close these issues.

3 participants