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

eth/tracers: improve tracing performance #23016

Merged
merged 4 commits into from
Jul 1, 2021
Merged

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Jun 8, 2021

This PR first adds a benchmark of the "opcode tracer", i.e, the barebones tracer which stores data in memory before sending it out over RPC. The benchmark is a very simple loop which just runs through 1M gas.

The second commit adds some optimizations which improves the performance quite a lot:

name                old time/op    new time/op    delta
TransactionTrace-6     100ms ±12%      28ms ±13%  -72.03%  (p=0.000 n=10+9)

name                old alloc/op   new alloc/op   delta
TransactionTrace-6    40.1MB ± 4%     9.0MB ±12%  -77.58%  (p=0.000 n=10+10)

name                old allocs/op  new allocs/op  delta
TransactionTrace-6      571k ± 0%      163k ± 0%  -71.42%  (p=0.000 n=10+8)

@holiman holiman changed the title Bench trace eth/tracers: improve tracing performance Jun 8, 2021
@holiman
Copy link
Contributor Author

holiman commented Jun 8, 2021

Further improvements:

name                old time/op    new time/op    delta
TransactionTrace-6    28.1ms ±13%    22.7ms ± 8%  -19.07%  (p=0.000 n=9+9)

name                old alloc/op   new alloc/op   delta
TransactionTrace-6    8.98MB ±12%    7.14MB ±14%  -20.55%  (p=0.000 n=10+10)

name                old allocs/op  new allocs/op  delta
TransactionTrace-6      163k ± 0%       82k ± 0%  -49.98%  (p=0.002 n=8+10)

Total:

name                old time/op    new time/op    delta
TransactionTrace-6     100ms ±12%      23ms ± 8%  -77.36%  (p=0.000 n=10+9)

name                old alloc/op   new alloc/op   delta
TransactionTrace-6    40.1MB ± 4%     7.1MB ±14%  -82.18%  (p=0.000 n=10+10)

name                old allocs/op  new allocs/op  delta
TransactionTrace-6      571k ± 0%       82k ± 0%  -85.71%  (p=0.000 n=10+10)

@ethereum ethereum deleted a comment Jun 8, 2021
@holiman
Copy link
Contributor Author

holiman commented Jun 11, 2021

I ran this against this transaction,

#!/bin/bash

time ./build/bin/geth attach --exec "debug.traceTransaction('0x87ba373aa69ee675ae764b49c3d179d2367dd0d970c36b9177dc67f00603b4e9', {'disableMemory':true, 'disableStorage':true})" 

It took about 52s, and 27s with stack disabled.
I also took a cpu profile when running it with stack enabled:
profile001

@MariusVanDerWijden
Copy link
Member

So I tried this on a really heavy tx we have on ropsten
time ./build/bin/geth --ropsten attach --exec "debug.traceTransaction('0xcafaf3669df640365da47527902e3e4dff48bd334ab0c5c894dae5ba1f82df27', {'disableMemory':true, 'disableStorage':true, reexec:10000})"

This PR:
(60 seconds of it is state regeneration)

Executed in  281.69 secs    fish           external
   usr time  151.47 secs  323.00 micros  151.47 secs
   sys time  103.44 secs   67.00 micros  103.44 secs

Current Master:
(59 seconds of it is state regeneration)
(I killed the node, call didn't finish)

Executed in  269.17 mins    fish           external
   usr time    6.21 secs  358.00 micros    6.21 secs
   sys time    0.50 secs   77.00 micros    0.50 secs

@holiman
Copy link
Contributor Author

holiman commented Jun 30, 2021

So I tried this on a really heavy tx we have on ropsten

Looks like it worked then? Can the PR haz an approve?

core/vm/logger.go Outdated Show resolved Hide resolved
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman added this to the 1.10.5 milestone Jul 1, 2021
@holiman holiman merged commit f5f906d into ethereum:master Jul 1, 2021
@holiman
Copy link
Contributor Author

holiman commented Jul 1, 2021

0xcafaf3669df640365da47527902e3e4dff48bd334ab0c5c894dae5ba1f82df27

18M gas on that transactions -- yeah might be a bit slow :)

sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Jul 1, 2021
Improves the performance of debug.traceTransaction
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Aug 20, 2021
* eth/tracers: improve tracing performance (ethereum#23016)

Improves the performance of debug.traceTransaction

* Update the import order

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: John.H <john.h@binance.com>
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
Improves the performance of debug.traceTransaction
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.

4 participants