Skip to content

perf: maintain a cache of block information in ChainStore #12997

Open
@nagisa

Description

@nagisa

Currently all ChainStore queries such as get_block_header, get_block_hash_by_height, get_block_height, get_block_header_on_chain_by_height and so on go straight to rocksdb.

In practice most of the queries will involve just a couple dozen most recent heights1, so in theory it should be possible to improve certain workloads significantly. If ChainStore maintained deserialized data for these recent blocks in warm memory, these queries could avoid a trip through the rocksdb layers (all the way to its block cache,) deserialization overhead, etc.

A particular workload where such queries appear to have a significant overhead is a native token transfer benchmark with a lower number of accounts. A profile of such a workload can be seen here.

Footnotes

  1. verify this theory! both in a benchmark and a real node -- I imagine we could log how far behind HEAD queries reach to for each query and then plot a frequency graph. My intuition is that it should take a shape of a normal distribution bell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions