Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockchain: Use skip list for ancestor traversal. #2010

Merged
merged 2 commits into from
Nov 23, 2019

Commits on Nov 23, 2019

  1. Configuration menu
    Copy the full SHA
    ad46c71 View commit details
    Browse the repository at this point in the history
  2. blockchain: Use skip list for ancestor traversal.

    There are several places when processing blocks and headers that require
    the ability to traverse the chain to ancestors of a given block such as
    tallying votes and versions to determine threshold states, finding
    forks, and calculating PoW difficulty, ticket price, and sequence locks.
    
    Currently most traversal of this type is linear and therefore does not
    scale well as the chain height grows.  In addition, the ability to
    quickly locate ancestors, potentially deep in history, will be needed
    when decoupling the connection code from the download logic as well as
    several planned future optimizations.
    
    Consequently, this significantly optimizes ancestor traversal by
    introducing a deterministic skip list and adds tests to ensure proper
    functionality.
    
    The following is a before and after comparison of ancestor traversal for
    a large number of nodes:
    
    benchmark           old ns/op     new ns/op   delta
    ------------------------------------------------------
    BenchmarkAncestor   67901581      158         -100.00%
    
    benchmark           old allocs   new allocs   delta
    ------------------------------------------------------
    BenchmarkAncestor   0            0            +0.00%
    
    benchmark           old bytes    new bytes    delta
    ------------------------------------------------------
    BenchmarkAncestor   0            0            +0.00%
    davecgh committed Nov 23, 2019
    Configuration menu
    Copy the full SHA
    b50cadc View commit details
    Browse the repository at this point in the history