decred / dcrwallet

A secure Decred wallet daemon written in Go (golang).
https://decred.org
ISC License
216 stars 155 forks source link

spv: Process header batches in parallel #2311

Closed matheusd closed 10 months ago

matheusd commented 10 months ago

This switches the initial SPV header fetching process to process each batch of headers in parallel through its various stages.

The initial header sync process is split into a 3-stage pipeline, where batches of headers progress through. Each stage is run on a separate goroutine, providing some parallelism for the entire process.

The following is a rough comparison of sync times with/without this PR (all on mainnet, reference master):

master
[DBG] SYNC: Initial sync completed in 13m3s
[DBG] SYNC: Initial sync completed in 13m2s
[DBG] SYNC: Initial sync completed in 13m34s

master, spvconnect to a known fast peer
[DBG] SYNC: Initial sync completed in 7m42s
[DBG] SYNC: Initial sync completed in 7m4s
[DBG] SYNC: Initial sync completed in 7m22s

this PR
[DBG] SYNC: Initial sync completed in 9m53s
[DBG] SYNC: Initial sync completed in 8m32s
[DBG] SYNC: Initial sync completed in 8m42s

this PR, spvconnect to a known fast peer
[DBG] SYNC: Initial sync completed in 4m49s
[DBG] SYNC: Initial sync completed in 4m46s
[DBG] SYNC: Initial sync completed in 4m43s

Part of #2289.