GithubHelp home page GithubHelp logo

cornedbeef's Introduction

cornedbeef

Writing a hashmap in Rust for learning and fun.

Please see the accompanying blog posts:

The design was inspired by Google's Swiss Tables map and Rust's std::collections::HashMap aka hashbrown (based on Swiss Tables).

This repo contains 6 iterations on a hashmap, building from a naive design toward (a simplified) Swiss Tables:

  • first::Map: separate chaining using std::collections::LinkedList
  • second::Map: open addressing (quadratic probing)
  • third::Map: open addressing with Swiss tables metadata
  • fourth::Map: same as third but using std::mem::MaybeUninit as an optimization
  • fifth::Map: same as fourth but adding SIMD probing
  • sixth::Map (unfinished): same as fifth but putting the metadata and backing storage in the same allocation (with a lot of unsafe)

Speed comparison with std

These are done with the benchmarks in /benches.

Reported times are for my laptop (Intel i7-10750H, 32 GB RAM, Fedora 37).

Benchmark name std runtime (ms) fifth::Map runtime (ms) Ratio
insert_grow_seq 1 3.85 4.58 1.19
insert_grow_seq 8 4.81 5.79 1.20
insert_grow_random 1 3.95 4.75 1.20
insert_grow_random 8 4.87 5.87 1.21
insert_reserved 1 2.03 2.26 1.11
insert_reserved 8 2.47 2.74 1.11
lookup 1 2.14 2.61 1.22
lookup 8 3.11 4.3 1.38
lookup string 1 4.32 4.61 1.07
lookup string 8 7.07 7.17 1.01
lookup miss 1 1.84 1.99 1.08
lookup miss 8 2.02 2.26 1.12
remove 1 3.07 3.49 1.14
remove 8 5.00 5.60 1.12

cornedbeef's People

Watchers

 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.