GithubHelp home page GithubHelp logo

quick-patricia-trie's Introduction

quick-patricia-trie

A toy implementation of a patricia tree as used in ethereum.

The implementation is strongly inspired by parity patricia-trie.

Key difference

This is a total reimplementation from scratch so there are numerous differences.

The major ones are:

  • much less generic: everything is a &[u8] at some point. The only requirements is for the key/value being AsRef[u8]>.
  • use of Arena, a struct in charge of allocating all data. As a result, there is no need to use elastic-array or some other fixed array based crates. Everything is eventually stored in a unique Vec, all references are instead indexes that we can freely copy and lookups are thus very fast.
  • there is no backend database yet. While it will probably be done in the future, I wanted to implement the core idea of the Merkle Patricia Trie as defined in the ethereum doc and benchmark it against the parity one based on memory-db.
  • it is probably lacking many more features I are so far unecessary (like the iterator seek)

Benchmarks

So far results are promising. There is a criterion crate which tries to run the same benches as written in the original parity crates.

Trie insertion mirror 1k

trie_insertion_mir_1k

Trie insertion random 1k

trie_insertion_mir_1k

Trie insertion six high

trie_insertion_six_high

Trie insertion six mid

trie_insertion_six_mid

Trie insertion random mid

trie_insertion_random_mid

Iterator

iter

quick-patricia-trie's People

Contributors

tafia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.