Skip to content

Ideas for speeding up validator sync #237

@torkelrogstad

Description

@torkelrogstad
  1. Fetch blocks in JSON-RPC batches
    Preliminary findings are that the network latency isn't actually that big of a deal.
    Serial fetch (debug build): 8.8k blocks per minute
    Batched fetch (debug build): 10.5k blocks per minute
    Initial version of this is implemented in validator: fetch blocks with batched JSON-RPC during initial sync, reduce DB commits #236
  2. Implement a pipeline of batch fetch -> deserialize -> process consisting of multiple threads
  3. Fetch blocks by reading raw data from disk.
    Network calls does NOT seem to be a limiting factor here. Not sure this would yield anything.
  4. Skip committing every block. Sync for example 1k blocks before comitting? Should we then avoid emitting sync events until after the commit? This is implemented in validator: fetch blocks with batched JSON-RPC during initial sync, reduce DB commits #236. Does a massive 10-20x speedup!

Not related to speeding up directly, but should also do:


Notes

In general, it appears we are bottle-necked by disk. From my analysis it seems like up to 85% of time is spent waiting for disk on my machine (M2 macbook pro). Wins would probably be found in:

  1. Batching DB operations where possible
  2. Avoiding DB operations where possible (lots of stuff should be storeable in-memory, especially during initial sync)
  3. Tuning DB commit behavior
  4. Tuning LMDB sync behavior. Summary of these shown below.
Mode fsync on Commit Meta Safe Crash Safe Speed
Default 🔴 Slow
MDB_NOSYNC 🟢 Fast
MDB_NOMETASYNC ⚠️ Partial 🟡 Medium
MDB_MAPASYNC 🟢 Fastest
MDB_WRITEMAP ⚠️ Risky 🟡 Fast

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions