Skip to content

Perf: Cache PosForwardHeaderProvider.GetBlockHeaders #8573

@asdacap

Description

@asdacap

Is your feature request related to a problem? Please describe.

  • The IForwardHeaderProvider.GetBlockHeaders returns the currently pending canonical chain that block downloader should download and process.
  • This method is called on every peer allocation repeatedly.
  • For PowHeaderProvider, which download header directly from best peer, this call is cached, because a p2p call is just straight up too slow.
  • For PosHeaderProvider, this was not done for simplicity, preferring to call ChainLevelHelper which re-fetch header.
  • This is the reason why there is a hard limit to header lookup in BlockDownloader BlockDownloader.MaxHeaderLookup which limits the parallelism of block downloader. Which, is not nice, but at least much better than downloading from just a single peer.

Describe the solution you'd like

  • Cache the result of GetBlockHeaders so that it can be called a few hundreds time per sec without much overhead.
  • I don't have a cache invalidation strategy in mind, so that need to be resolved.

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