XinFinOrg / XDPoSChain

Customer centric, Hybrid & Interoperable XinFin Network
https://www.xinfin.org
GNU Lesser General Public License v3.0
50 stars 58 forks source link

`eth_getLogs` optimizations #560

Open s1na opened 2 weeks ago

s1na commented 2 weeks ago

Hello I got a report from @0xbeny that eth_getLogs can be slow at times. I want to list a few optimizations that have been applied upstream. They yielded around 30% improvement in speed. They need to be applied in order.

  1. https://github.com/ethereum/go-ethereum/pull/23147 Logs are stored as part of receipts in the database. Crucially not all fields of a receipt are persisted to disk. Some are re-computed on read. The most expensive field to re-compute is the bloom filter which will not even be returned in eth_getLogs. Here we define a new decoding of receipts specifically for this use-case which avoids extra processing.
  2. https://github.com/ethereum/go-ethereum/pull/25459 Previous PR caused an accidental regression in which receipts would not be cached anymore. Hence concurrently querying same blocks would slow down. This PR re-introduces a cache specifically for logs.
  3. https://github.com/ethereum/go-ethereum/pull/25199 as the title suggests we postpone fetching block bodies from disk until we are sure that it is a matching log that needs to be returned to user.
JukLee0ira commented 1 week ago

Thank you, s1na! We have checked the performance. PR # 568 will solve this problem