Coder Social home page Coder Social logo

cuckoo's Introduction

cuckoo

Package cuckoo implements d-ary bucketized cuckoo hashing with stash (bucketized cuckoo hashing is also known as splash tables). This implementation uses configurable number of hash functions and cells per bucket. Greedy algorithm for collision resolution is a random walk.

Purpose

Cuckoo is a memory-efficient alternative to the built-in map[Key]Value type (where Key is an integer type and Value can be any type) with zero per-item overhead. Hence, the memory-efficiency is equal to the load factor (which can be as high as 99%).

Performance

Benchmark results on linux/amd64 with i7-4770S (2M uint32 Key/Value insertion) with gc compiler (version 1.7):

go test -bench=. -v -cpu 1
=== RUN   TestZero
--- PASS: TestZero (0.00s)
=== RUN   TestSimple
--- PASS: TestSimple (1.28s)
=== RUN   TestMem
--- PASS: TestMem (0.41s)
		cuckoo_test.go:148: LoadFactor: 0.9534401893615723
		cuckoo_test.go:149: Built-in map memory usage (MiB): 65.57434844970703
		cuckoo_test.go:150: Cuckoo hash  memory usage (MiB): 16.000137329101562
BenchmarkCuckooInsert   10000000               121 ns/op               0 B/op          0 allocs/op
BenchmarkCuckooSearch   20000000                83.8 ns/op             0 B/op          0 allocs/op
BenchmarkCuckooDelete   20000000               132 ns/op               0 B/op          0 allocs/op
BenchmarkMapInsert      10000000               130 ns/op               9 B/op          0 allocs/op
BenchmarkMapSearch      20000000                81.6 ns/op             0 B/op          0 allocs/op
BenchmarkMapDelete      100000000               11.7 ns/op             0 B/op          0 allocs/op
PASS
ok      github.com/salviati/cuckoo      12.941s

Arch-specific optimizations

Cuckoo is SIMD-friendly by design, and there are plans for fast-path SIMD functions.

Usage

After cloning the repository, modify the definitions of Key and Value types to fit your needs. For optimal performance, you should also experiment with the fine-grade parameters of the algorithm listed in config.go.

Documentation

godoc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

cuckoo's People

Contributors

salviati avatar

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.