trueblocks-core icon indicating copy to clipboard operation
trueblocks-core copied to clipboard

chifra export - poor performance of logs query

Open tjayrush opened this issue 1 year ago • 4 comments

This query takes a very long time through chifra

time chifra export --cache \
   --logs \
   --fmt json \
   0xBBAAc125DCE2B69d2a516C90559af1eD7B7d5EAf \
   --emitter=0xC36442b4a4522E871399CD717aBDD847Ab11FE88 \
   --topic 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef \
           0x0000000000000000000000000000000000000000000000000000000000000000 \
           0x000000000000000000000000BBAAc125DCE2B69d2a516C90559af1eD7B7d5EAf

The equivilant using just the RPC (see below) is MUCH faster.

tjayrush avatar Feb 22 '24 01:02 tjayrush

here's the corresponding eth_getLogs request:

curl --request POST \
     --url <ETH_MAINNET_RPC_URL> \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "address": [
        "0xc36442b4a4522e871399cd717abdd847ab11fe88"
      ],
      "fromBlock": "0x429d3b",
      "toBlock": "latest",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        "0x000000000000000000000000BBAAc125DCE2B69d2a516C90559af1eD7B7d5EAf"
      ]
    }
  ]
}
'

gphil avatar Feb 22 '24 14:02 gphil

Some timings:

Description Time
Into the cache with chifra export: 4.72 seconds
Out of the cache with chifra export: .313 seconds
Curl 9.9 seconds (then on rerun: .868 seconds, .813, .843)

tjayrush avatar Jul 17 '24 11:07 tjayrush

Thanks for looking into this. Are these timings from a new release?

gphil avatar Jul 17 '24 18:07 gphil

Current release. Yes.

tjayrush avatar Jul 18 '24 00:07 tjayrush