Recipe: Simple Speedup

Thomas Jay Rush
2 min readMay 5, 2023

How to speed up rendering transaction histories with TrueBlocks

Do this:

chifra list --no_header trueblocks.eth | \
cut -f2,3 | tr '\t' '.' | tee tx_list

That is, put the transaction identifiers into a file.

And then this:

chifra transactions --cache --file tx_list

That is, read the transactions list from a file.

This has the effect of calling into the RPC for all the transactions with one command line invocation instead of loading chifra from the command line for each individual transaction.

In a simple test we just did, this is significantly faster.

A Niave Test

We ran chifra list trueblocks.eth and got around 2,230 transaction identifiers. When then ran this command to create a simple shell script:

cat tx_list | sed 's/^/chifra transactions /' | tee script1.sh

In other words, create a shell script that calls chifra transactions once for each transaction identifier. We then timed it with:

time source script1.sh

and got the following results:

________________________________________________________
Executed in 237.37 secs fish external
usr time 76.14 secs 0.28 secs 75.86 secs
sys time 26.12 secs 2.21 secs 23.91 secs

Faster

Next, we ran this test:

time chifra transactions --cache --file tx_list

(Notice the use of the --cache.)

This returns:

________________________________________________________
Executed in 218.02 secs fish external
usr time 105.69 secs 0.13 millis 105.69 secs
sys time 22.59 secs 4.84 millis 22.58 secs

Not as much faster as we’d like, but some improvement.

Let’s run that again:

________________________________________________________
Executed in 132.51 secs fish external
usr time 42.51 secs 0.17 millis 42.51 secs
sys time 5.11 secs 4.78 millis 5.10 secs

About twice as fast as the original. Local caching and avoiding repeated calls into the operating system matters.

Just for Fun

Just for fun, we did this:

chifra transactions --no_header trueblocks.eth | cut -f3 | \
cut -f1 -d: | uniq -c | tee hourly.txt

And made this meager chart (sorry, we’re tired, and it’s late).

Support Our Work

TrueBlocks is funded from personal funds and grants from The Ethereum Foundation (2018), Consensys (2019), Moloch DAO (2021), Filecoin/IPFS (2021), our GitCoin donors, The Ethereum Foundation (2022), and (recently) Optimism Retro PGF (2023).

If you like this article and wish to support our work, please donate to our GitCoin grant ETH or any other token to us directly at trueblocks.eth or 0xf503017d7baf7fbc0fff7492b751025c6a78179b.

--

--

Thomas Jay Rush

Blockchain Enthusiast, Founder TrueBlocks, LLC and Philadelphia Ethereum Meetup, MS Computer Science UPenn