Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fetching transaction receipt performance #9430

Closed
adyshimony opened this issue Aug 28, 2018 · 7 comments
Closed

Fetching transaction receipt performance #9430

adyshimony opened this issue Aug 28, 2018 · 7 comments
Assignees
Labels
F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M6-rpcapi 📣 RPC API.
Milestone

Comments

@adyshimony
Copy link

adyshimony commented Aug 28, 2018

Hi,

100 blocks txs receipts - total of 15324 - takes 102 seconds.

I am with latest Parity, on ubuntu, this is a constant issue.

I am indexing all transaction, and getting very slow performance when fetching transaction receipt.

For example:

blocks 4832000 - 4832099
To get the 100 blocks, the duration in sec:, 8.921 (block include transactions body)

// now get the receipts for each transaction per block (I am waiting for all txs per block. waiting for all txs for all blocks didn't improve performance)

getTransactionsFromBlockAsync for block: 4832000, txs: 252, duration in sec:, 1.929
getTransactionsFromBlockAsync for block: 4832001, txs: 103, duration in sec:, 0.190
getTransactionsFromBlockAsync for block: 4832002, txs: 79, duration in sec:, 0.134
getTransactionsFromBlockAsync for block: 4832003, txs: 64, duration in sec:, 0.064
getTransactionsFromBlockAsync for block: 4832004, txs: 251, duration in sec:, 2.090
getTransactionsFromBlockAsync for block: 4832005, txs: 258, duration in sec:, 2.317
getTransactionsFromBlockAsync for block: 4832006, txs: 302, duration in sec:, 3.510
getTransactionsFromBlockAsync for block: 4832007, txs: 87, duration in sec:, 0.162
getTransactionsFromBlockAsync for block: 4832008, txs: 192, duration in sec:, 1.355
getTransactionsFromBlockAsync for block: 4832009, txs: 323, duration in sec:, 4.140
getTransactionsFromBlockAsync for block: 4832010, txs: 162, duration in sec:, 0.754
getTransactionsFromBlockAsync for block: 4832011, txs: 54, duration in sec:, 0.047
getTransactionsFromBlockAsync for block: 4832012, txs: 43, duration in sec:, 0.032
getTransactionsFromBlockAsync for block: 4832013, txs: 24, duration in sec:, 0.014
getTransactionsFromBlockAsync for block: 4832014, txs: 68, duration in sec:, 0.084
getTransactionsFromBlockAsync for block: 4832015, txs: 121, duration in sec:, 0.376
getTransactionsFromBlockAsync for block: 4832016, txs: 15, duration in sec:, 0.011
getTransactionsFromBlockAsync for block: 4832017, txs: 247, duration in sec:, 2.373
getTransactionsFromBlockAsync for block: 4832018, txs: 109, duration in sec:, 0.288
getTransactionsFromBlockAsync for block: 4832019, txs: 73, duration in sec:, 0.096
getTransactionsFromBlockAsync for block: 4832020, txs: 45, duration in sec:, 0.036
getTransactionsFromBlockAsync for block: 4832021, txs: 271, duration in sec:, 2.648
getTransactionsFromBlockAsync for block: 4832022, txs: 270, duration in sec:, 2.719
getTransactionsFromBlockAsync for block: 4832023, txs: 6, duration in sec:, 0.004
getTransactionsFromBlockAsync for block: 4832024, txs: 241, duration in sec:, 1.988
getTransactionsFromBlockAsync for block: 4832025, txs: 276, duration in sec:, 2.150
getTransactionsFromBlockAsync for block: 4832026, txs: 230, duration in sec:, 1.597
getTransactionsFromBlockAsync for block: 4832027, txs: 267, duration in sec:, 2.671
getTransactionsFromBlockAsync for block: 4832028, txs: 179, duration in sec:, 1.248
getTransactionsFromBlockAsync for block: 4832029, txs: 125, duration in sec:, 0.421
getTransactionsFromBlockAsync for block: 4832030, txs: 8, duration in sec:, 0.006
getTransactionsFromBlockAsync for block: 4832031, txs: 85, duration in sec:, 0.142
getTransactionsFromBlockAsync for block: 4832032, txs: 278, duration in sec:, 2.998
getTransactionsFromBlockAsync for block: 4832033, txs: 162, duration in sec:, 0.812
getTransactionsFromBlockAsync for block: 4832034, txs: 167, duration in sec:, 0.930
getTransactionsFromBlockAsync for block: 4832035, txs: 91, duration in sec:, 0.148
getTransactionsFromBlockAsync for block: 4832036, txs: 237, duration in sec:, 2.112
getTransactionsFromBlockAsync for block: 4832037, txs: 138, duration in sec:, 0.512
getTransactionsFromBlockAsync for block: 4832038, txs: 271, duration in sec:, 2.873
getTransactionsFromBlockAsync for block: 4832039, txs: 287, duration in sec:, 3.034
getTransactionsFromBlockAsync for block: 4832040, txs: 276, duration in sec:, 2.624
getTransactionsFromBlockAsync for block: 4832041, txs: 216, duration in sec:, 1.572
getTransactionsFromBlockAsync for block: 4832042, txs: 14, duration in sec:, 0.010
getTransactionsFromBlockAsync for block: 4832043, txs: 49, duration in sec:, 0.038
getTransactionsFromBlockAsync for block: 4832044, txs: 211, duration in sec:, 1.392
getTransactionsFromBlockAsync for block: 4832045, txs: 232, duration in sec:, 1.703
getTransactionsFromBlockAsync for block: 4832046, txs: 266, duration in sec:, 1.941
getTransactionsFromBlockAsync for block: 4832047, txs: 208, duration in sec:, 1.238
getTransactionsFromBlockAsync for block: 4832048, txs: 145, duration in sec:, 0.593
getTransactionsFromBlockAsync for block: 4832049, txs: 122, duration in sec:, 0.298
getTransactionsFromBlockAsync for block: 4832050, txs: 182, duration in sec:, 1.150
getTransactionsFromBlockAsync for block: 4832051, txs: 114, duration in sec:, 0.256
getTransactionsFromBlockAsync for block: 4832052, txs: 165, duration in sec:, 0.902
getTransactionsFromBlockAsync for block: 4832053, txs: 25, duration in sec:, 0.019
getTransactionsFromBlockAsync for block: 4832054, txs: 148, duration in sec:, 0.576
getTransactionsFromBlockAsync for block: 4832055, txs: 219, duration in sec:, 1.371
getTransactionsFromBlockAsync for block: 4832056, txs: 81, duration in sec:, 0.153
getTransactionsFromBlockAsync for block: 4832057, txs: 185, duration in sec:, 0.891
getTransactionsFromBlockAsync for block: 4832058, txs: 281, duration in sec:, 3.002
getTransactionsFromBlockAsync for block: 4832059, txs: 283, duration in sec:, 2.852
getTransactionsFromBlockAsync for block: 4832060, txs: 42, duration in sec:, 0.034
getTransactionsFromBlockAsync for block: 4832061, txs: 83, duration in sec:, 0.109
getTransactionsFromBlockAsync for block: 4832062, txs: 153, duration in sec:, 0.543
getTransactionsFromBlockAsync for block: 4832063, txs: 43, duration in sec:, 0.029
getTransactionsFromBlockAsync for block: 4832064, txs: 251, duration in sec:, 2.527
getTransactionsFromBlockAsync for block: 4832065, txs: 156, duration in sec:, 0.789
getTransactionsFromBlockAsync for block: 4832066, txs: 178, duration in sec:, 0.895
getTransactionsFromBlockAsync for block: 4832067, txs: 203, duration in sec:, 1.319
getTransactionsFromBlockAsync for block: 4832068, txs: 113, duration in sec:, 0.303
getTransactionsFromBlockAsync for block: 4832069, txs: 222, duration in sec:, 1.545
getTransactionsFromBlockAsync for block: 4832070, txs: 106, duration in sec:, 0.240
getTransactionsFromBlockAsync for block: 4832071, txs: 83, duration in sec:, 0.126
getTransactionsFromBlockAsync for block: 4832072, txs: 77, duration in sec:, 0.104
getTransactionsFromBlockAsync for block: 4832073, txs: 65, duration in sec:, 0.077
getTransactionsFromBlockAsync for block: 4832074, txs: 145, duration in sec:, 0.546
getTransactionsFromBlockAsync for block: 4832075, txs: 61, duration in sec:, 0.067
getTransactionsFromBlockAsync for block: 4832076, txs: 57, duration in sec:, 0.060
getTransactionsFromBlockAsync for block: 4832077, txs: 205, duration in sec:, 1.150
getTransactionsFromBlockAsync for block: 4832078, txs: 121, duration in sec:, 0.265
getTransactionsFromBlockAsync for block: 4832079, txs: 52, duration in sec:, 0.038
getTransactionsFromBlockAsync for block: 4832080, txs: 115, duration in sec:, 0.236
getTransactionsFromBlockAsync for block: 4832081, txs: 147, duration in sec:, 0.413
getTransactionsFromBlockAsync for block: 4832082, txs: 278, duration in sec:, 2.294
getTransactionsFromBlockAsync for block: 4832083, txs: 262, duration in sec:, 2.163
getTransactionsFromBlockAsync for block: 4832084, txs: 186, duration in sec:, 0.987
getTransactionsFromBlockAsync for block: 4832085, txs: 249, duration in sec:, 1.837
getTransactionsFromBlockAsync for block: 4832086, txs: 57, duration in sec:, 0.066
getTransactionsFromBlockAsync for block: 4832087, txs: 38, duration in sec:, 0.029
getTransactionsFromBlockAsync for block: 4832088, txs: 24, duration in sec:, 0.014
getTransactionsFromBlockAsync for block: 4832089, txs: 162, duration in sec:, 0.641
getTransactionsFromBlockAsync for block: 4832090, txs: 345, duration in sec:, 4.140
getTransactionsFromBlockAsync for block: 4832091, txs: 89, duration in sec:, 0.135
getTransactionsFromBlockAsync for block: 4832092, txs: 41, duration in sec:, 0.031
getTransactionsFromBlockAsync for block: 4832093, txs: 82, duration in sec:, 0.119
getTransactionsFromBlockAsync for block: 4832094, txs: 121, duration in sec:, 0.356
getTransactionsFromBlockAsync for block: 4832095, txs: 156, duration in sec:, 0.743
getTransactionsFromBlockAsync for block: 4832096, txs: 122, duration in sec:, 0.394
getTransactionsFromBlockAsync for block: 4832097, txs: 37, duration in sec:, 0.026
getTransactionsFromBlockAsync for block: 4832098, txs: 221, duration in sec:, 1.721
getTransactionsFromBlockAsync for block: 4832099, txs: 293, duration in sec:, 3.366

getBlockTransactionsAsync tx for blocks #4832000 - #4832099 : 15324, duration in sec:, 102.119!!!

100 blocks txs receipts - total of 15324 - 102 seconds.

Any way to improve that?

Thanks,
Ady.

@Tbaut Tbaut added Z1-question 🙋‍♀️ Issue is a question. Closer should answer. M6-rpcapi 📣 RPC API. labels Aug 29, 2018
@Tbaut Tbaut added this to the 2.1 milestone Aug 29, 2018
@Tbaut
Copy link
Contributor

Tbaut commented Aug 29, 2018

For the sake of precision, can you confirm the version of Parity Ethereum, the way you're querying the receipts (web3?), what RPC you use and give as many info about your setup as possible.

@adyshimony
Copy link
Author

Ethereum main net, latest parity version, web3 ("web3": "^1.0.0-beta.33"), ipc provider, nodejs.
Parity is fully sync. This is something that I had in all pervious versions.

@adyshimony
Copy link
Author

I wrote a simpler version so you can see the code, same results as the app version.
https://gist.github.com/adyshimony/687c17be1e5016ce0513c00252d3a9f3

Here are the results:
https://gist.github.com/adyshimony/db79064867ff7f05b7fce90e38a56563

@Tbaut Tbaut added F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. and removed Z1-question 🙋‍♀️ Issue is a question. Closer should answer. labels Aug 30, 2018
@tomusdrw
Copy link
Collaborator

Hi @adyshimony,
indeed fetching all receipts from a block is quite inefficient on our side, the reason for this is that to construct nth receipt in a block we need to fetch all n-1 previous receipts from the db to compute the log indices correctly.

There are two ways I see to solve this:

  1. Change the database format and store accumulated number of logs in every receipt (so that we can compute log indices from this without querying previous receipts)
  2. Implement parity_getBlockReceipts(BlockId) to efficiently handle the use case where all receipts from a block are needed.

Personally I'm more in favour of the second option since it's simpler to implement, doesn't require db migration nor increases db size and simplifies required RPC queries on your side as well.

@adyshimony
Copy link
Author

Hi @tomusdrw

Yes, I like the second option too, exactly what I need.

Do you think it can be done in the near future? its taking weeks to index ethereum logs with the current get receipt performance.

@xlk3099
Copy link

xlk3099 commented Aug 31, 2018

Looking forward to the parity_getBlockReceipts method.

@adyshimony
Copy link
Author

Ok, checked it with geth.
Performance is ~ 10 times better.

Here are the restults:
https://gist.github.com/adyshimony/da18f715c1007e05471a8db82e3c273d

Parity:
100 blocks txs receipts - total of 15324 - 102 seconds.

Geth:
100 blocks txs receipts - total of 15324 - 11.785 seconds.

I am switching to geth until partiy will provide getBlockReceipts api.

@tomusdrw tomusdrw self-assigned this Sep 11, 2018
@5chdn 5chdn modified the milestones: 2.1, 2.2 Sep 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F3-annoyance 💩 The client behaves within expectations, however this “expected behaviour” itself is at issue. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

No branches or pull requests

5 participants