Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Optimize finality tracker to handle much longer period #1908

@rphmeier

Description

@rphmeier

After #1619

The finality tracker keeps track of what N recent block authors think the highest finalized block height was ("opinions"). If the median slips too far in the past, a callback to other modules is made.

Currently, all the recent opinions are kept in two Vec<Number> of length N in storage. One is sorted by recency, and the other is sorted by block number. This is very inefficient and doesn't scale to large N -- where we would probably want N to be 1,000 to 10,000 or even higher.

One approach for this optimization is to select a smaller number K (~100?) and split up the recent opinions into a doubly-linked list of Vec<Number> with length 0..2K. When a sub-list reaches length 2K, it is split into two smaller lists of length K. A combination of binary and linear search can be used to find the correct place to insert into the block number set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I9-optimisationAn enhancement to provide better overall performance in terms of time-to-completion for a task.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions