• Stars
    star
    349
  • Rank 117,589 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

an off-heap hash-table in Go. Used to be called go-offheap-hashtable, but we shortened it.

offheap (formerly go-offheap-hashtable)

Docs:

http://godoc.org/github.com/glycerine/offheap

When GC pauses are long because you've got big hash tables in Go, you need an off-heap hash-table.

The purpose here is to have a hash table that can work away from Go's Garbage Collector, to avoid long GC pause times.

We accomplish this by writing our own Malloc() and Free() implementation (see malloc.go) which requests memory directly from the OS. The keys, the values, and the entire hash table itself is kept in this off-heap storage. This storage can also optionally be backed by a memory mapped file for speedy persistence and fast startup times.

Update: the cgo-malloc branch of this github repo has an implementation that uses CGO to call the malloc/calloc/free functions in the C stdlib. Using CGO gives up the save-to-disk instantly feature and creates a portability issue where you have linked against a specific version of the C stdlib. However if you are making/destroying alot of tables, the CGO apporach may be faster.

See offheap.go for all the interesting code. Modify val_t to hold you values, and key_t to contain your keys. Current sample code for three types of keys (int64, []byte, and strings) is provided (see bytekey.go). For the hashing function itself, the incredibly fast xxhash64 is used to produce uint64 hashes of strings and []byte.

Note that all your key and values should be inline in the Cell. If you point back into the go-heap, such values maybe garbage collected by the Go runtime without notice.

On Save(), serialization of the HashTable itself is done using msgpack to write bytes to the first page (4k bytes) of the memory mapped file. This uses github.com/tinylib/msgp which is a blazing fast msgpack serialization library. It is fast because it avoids reflection and pre-computes the serializations (using go generate based inspection of your go source). If you need to serialize your values into the Val_t, I would suggest evaluating the msgp for serialization and deserialization. The author, Philip Hofer, has done a terrific job and put alot of effort into tuning it for performance. If you are still pressed for speed, consider also ommitting the field labels using the '//msgp:tuple MyValueType' annotation. As Mr. Hofer says, "For smaller objects, tuple encoding can yield serious performance improvements." [https://github.com/tinylib/msgp/wiki/Preprocessor-Directives].

Initial HashTable implementation inspired by the public domain C++ code of

https://github.com/preshing/CompareIntegerMaps

See also

http://preshing.com/20130107/this-hash-table-is-faster-than-a-judy-array/

for performance studies of the C++ code.

installation

 go get -t github.com/glycerine/go-offheap-hashtable

testing

go test -v

The implementation was test driven and includes over 4500 correctness checks.

Copyright (C) 2015 by Jason E. Aten, Ph.D.

License: MIT.

More Repositories

1

zygomys

Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy.
Go
1,636
star
2

rbuf

a small circular ring buffer library in go / golang
Go
182
star
3

sshego

golang/Go library for ssh tunneling (secure port forwarding)
Go
171
star
4

zebrapack

ZebraPack format is like gobs version 2: serialization in Go, *but* extremely fast and friendly to other languages. Use Go as your schema. Strong typing. Well documented (and msgpack2 compatible) format so other languages can be readily supported. See also https://github.com/glycerine/greenpack for a more recent alternative. Docs:
Go
168
star
5

greenpack

Cross-language serialization for Golang: greenpack adds versioning, stronger typing, and optional schema atop msgpack2. `greenpack -msgpack2` produces classic msgpack2, and handles nils. Cousin to ZebraPack (https://github.com/glycerine/zebrapack), greenpack's advantage is fully self-describing data. Oh, and faster than protobufs.
Go
113
star
6

goq

goq: a job queuing system written in go (golang). "Pronounced Go-Queue. Don't Gawk at this!"
Go
86
star
7

bambam

auto-generate capnproto schema from your golang source files. Depends on go-capnproto-1.0 at https://github.com/glycerine/go-capnproto
Go
67
star
8

sofia-ml

Automatically exported from code.google.com/p/sofia-ml
C++
61
star
9

go-sliding-window

a library for reliable and flow-controlled nats sessions using the sliding window protocol. Written in golang.
Go
58
star
10

golang-thrift-minimal-example

the apache thrift starter tutorial for golang, as a standalone repo
Go
44
star
11

gozbus

nanocap based messaging system
Go
43
star
12

grpc-demo

code to stream arbitrarily large files between hosts using gRPC and golang
Go
39
star
13

fast-elliptic-curve-p256

repackage the golang elliptic library enhancements by Vlad Krasnov and Shay Gueron as a stand alone library. Works with Go 1.4 or Go 1.5.
Go
35
star
14

tmframe

TMFRAME, pronounced "time frame", is a binary standard for compactly encoding time series data
Go
28
star
15

xcryptossh

golang.org/x/crypto/ssh the next generation: provide idle timeouts, avoid memory leaks, and gracefully cancel connections
Go
27
star
16

rmq

R package providing msgpack and websockets; demonstrates how to utilize Go libraries from R.
Go
24
star
17

libzipfs

Ship a zip file of media resources inside your golang web-app for complete standalone one-binary deployment
Go
21
star
18

golang-embed-julia

simple example of calling julia from Go
Go
20
star
19

thinkgo

Think Go. Pointers and resources for learning Go. Go (golang) is an elegant, fast, and rapid development language.
19
star
20

nack-oriented-reliable-multicast

NACK-Oriented Reliable Multicast (NORM): http://www.nrl.navy.mil/itd/ncs/products/norm
C++
15
star
21

hello_gio

hello world for Gio graphics for Golang. Gio runs on macOS, Windows, Wayland (linux), X11, WebASM, iOS, and Android. All in Go, no bridge C/Java to write.
Go
14
star
22

arogue

A Go-Repl using R underneath
Go
9
star
23

go-unsnap-stream

small golang library for decoding the snappy streaming format https://github.com/google/snappy/blob/master/framing_format.txt
Go
9
star
24

truepack

like https://github.com/glycerine/greenpack, but no integer compression based on the int's value
Go
8
star
25

lush2

Lush2 sources from svn 908, starting point -- https://lush.svn.sourceforge.net/svnroot/lush -- Last Changed Date: 2011-03-20 16:29:13 -0500 (Sun, 20 Mar 2011). Now patched for OSX 10.6 and up.
C
7
star
26

PrattParserInC

An implementation of Pratt Parsing (Vaughn Pratt 1973 "Top Down Operator Precedence") in C/C++
7
star
27

ruid

ruid: a really unique id
Go
6
star
28

webiperf

webiperf is a web-app that makes it easy to generate iperf commands
JavaScript
6
star
29

rustxi

rust + transactions + interpreter = rustxi. rustxi is a transactional jit-compilation-based REPL for the Rust language.
C
5
star
30

liblmdb

git clone -b mdb.master git://git.openldap.org/openldap.git # on June 11, 2014 / 17c09fa476a7dbd49aca5e4caf0384cb1c3d244a
C
5
star
31

monotime

Go library for monotonic time source on platforms where one is available to the Go runtime.
Go
4
star
32

low-level-lush

(LLL) : Low-Level-Lush with Lisp is a combination of Lush2.0.1 and LLVM2.8 to bring out the best in both.
C++
4
star
33

swig-cpp-to-cffi-for-common-lisp-enhancements

forking from SWIG svn 12570 to generate better common lisp bindings from c++
C++
4
star
34

gopass

Go
4
star
35

idem

idem.Halter: a pattern for halting goroutines in Go
Go
4
star
36

muse

golang code to convert from go/types.Type to reflect.Type
Go
3
star
37

crack-language

Crack programming language
C++
3
star
38

buzz

broadcasting channels in Go
Go
3
star
39

json2msgpack

convert from newline delimited json to size-header based msgpack frames
Go
3
star
40

shore-mt

shore-mt (Scalable Heterogeneous Object REpository - MultiThreaded version), import of the 6.0.2 release of 03-Jan-2012 http://research.cs.wisc.edu/shore-mt/ ( differs from the DIAS version from http://diaswww.epfl.ch/shore-mt/ )
C++
3
star
41

configs-in-golang

demonstrate pattern for command line flag handling that allows library configuration/reuse and testing
Go
3
star
42

golang-fisher-exact

Fisher's exact test for 2x2 contingency tables, in Golang
Go
2
star
43

spread-src-4.4.0

An open source implementation of virtual synchrony, package spread-src-4.4.0, from Spread Concepts LLC. Details at http://www.spread.org See also https://github.com/glycerine/spread-src-5.0.1
C
2
star
44

vprint

debug Go faster with this simple print library. prints show timestamp and file location
Go
2
star
45

selfie

generate and validate self-signed public keys
Go
2
star
46

nanomsgardvark

R bindings for nanomsg
C
2
star
47

justinjuddeasyssh

Go
2
star
48

golang-hex-dumper

Go
2
star
49

xml2csv

Parse an XML file on stdin, write csv to stdout. No schema, no structs required.
Go
2
star
50

gossainterpdemo

demonstration of the go ssa interpreter
Go
2
star
51

pingbuf

a minimal ring buffer
Go
2
star
52

libcmm

Ralf Juengling's libcmm: a C Memory Management Library, last commit f980fd1715780c99f54ebad8b49dbc10befe192d from Thu Nov 12 13:35:24 2009. Obtained from the sourceforge git repos on 28 April 2011 by: git clone git://libcmm.git.sourceforge.net/gitroot/libcmm/libcmm
C++
2
star
53

ugorji-go-codec

Go
1
star
54

latch

Go
1
star
55

spread-src-5.0.1

see motivation https://github.com/glycerine/spread-src-4.4.0
C
1
star
56

dyg

Go
1
star
57

rogue

use R as a repl and worker under golang master
Go
1
star
58

basic-bolt

basic boltdb example
Go
1
star
59

avfs

a virtual filesystem. mirror from http://avf.sourceforge.net/ and http://sourceforge.net/projects/avf/
C
1
star
60

vpython-emacs-mode

my vpython.el mode for ipython
Emacs Lisp
1
star
61

verb

Go
1
star
62

iris2

Community driven successor of the iris web framework
Go
1
star
63

yield

C++ web application server
C++
1
star
64

nats

friendly fork of nats-io/nats for use with glycerine/hnatsd
Go
1
star
65

lcon

local pipe that looks like net.Conn
Go
1
star
66

pelican-protocol

In ancient Egypt the pelican was believed to possess the ability to prophesy safe passage in the underworld. Pelicans are ferocious eaters of fish.
Go
1
star
67

mps-kit-1.108.0-x86_64-linux-port

See if the excellent Memory Pool System (MPS) can be ported to x86_64 on Linux
C
1
star
68

go-inthash

go version of basic hash map, open addressing with linear probing. uint64 keys. Inspired by http://preshing.com/20130107/this-hash-table-is-faster-than-a-judy-array/
Go
1
star
69

fastbit

fastbit-2.0.3 from https://sdm.lbl.gov/fastbit/, BSD licensed.
C++
1
star
70

geist

the geist script runner turns golang into a scripting language
Go
1
star
71

gopls-emacs-how-to

how to get gopls in emacs with golang go-mode working
1
star
72

double-messages-received-bug

Go
1
star
73

golang-repl

Go
1
star
74

python-extension-in-golang

code for https://hackernoon.com/extending-python-3-in-go-78f3a69552ac
Makefile
1
star
75

L3

L3: experiments in aggressive Garbage-collection and interpreter implementation based on the Pratt parser. Uses protocol buffers for serialization, and Judy arrays for fast, sparse arrays/hashtables. Linux and OSX.
1
star
76

SchemeTL

Scheme To Learn : Learning Scheme by implementing STL data structure equivalents
Common Lisp
1
star