• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    Go
  • License
    BSD 2-Clause "Sim...
  • Created about 8 years ago
  • Updated about 2 years ago

Reviews

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

Repository Details

Very fast, very unsafe serialization for Go

Documentation Build Status Coverage Status Report Card

Very fast, very unsafe serialization for Go

This package provides a fast way to load large amounts of data into Go structs. Memdump can load datasets containing millions of small structs at over 1 GB/s (compared to ~30 MB/s for gob or json).

The price you pay is:

  • you cannot load structs that contain maps or interfaces
  • your data is not portable across machine architectures (64 bit vs 32 bit, big-endian vs small-endian)

Benchmarks

The benchmarks were measured by encoding and decoding a tree containing 2,097,151 small structs. Code is under the bench dir.

Decode

                 gob    28.17 MB/s      (39.8 MB in 1.41s)
                json    30.17 MB/s      (113.8 MB in 3.77s)
             memdump  1031.54 MB/s      (113.2 MB in 0.11s)

Encode

                 gob    37.07 MB/s      (39.8 MB in 1.07s)
                json    77.20 MB/s      (113.8 MB in 1.47s)
             memdump    61.25 MB/s      (113.2 MB in 1.85s)

To reproduce these results:

$ go run ./bench/summarize.go

Quick start

go get github.com/alexflint/go-memdump

Write data to a file:

type data struct {
	Foo string
	Bar int
}

w, err := os.Create("/tmp/data.memdump")
if err != nil {
	...
}

// note that you must pass a pointer when encoding
mydata := data{Foo: "abc", Bar: 123}
memdump.Encode(w, &mydata)

Load data from a file:

r, err := os.Open("/tmp/data.memdump")
if err != nil {
	...
}

// note that you muss pass a pointer to a pointer when decoding
var mydata *data
memdump.Decode(r, &mydata)

More Repositories

1

gallium

Build desktop applications in Go and HTML.
Go
3,672
star
2

go-arg

Struct-based argument parsing in Go
Go
1,990
star
3

go-restructure

Match regular expressions into struct fields
Go
591
star
4

go-cloudfile

A consistent way to work with remote files.
Go
93
star
5

go-filemutex

Like sync.Mutex, but works across processes
Go
74
star
6

fscanf-speed

How fast is fscanf?
C++
58
star
7

pysfm

Python implementation of bundle adjustment
Python
55
star
8

triangulation

High quality implementations of many triangulation algorithms in pure python.
Python
33
star
9

stdroots

Standard CA roots embedded in a Go package.
Python
23
star
10

process-isolation

Elegant process isolation in pure python
Python
23
star
11

go-scalar

Go
8
star
12

manhattan-vision

Dynamic programming algorithms for reconstructing indoor Manhattan scenes
C++
8
star
13

bigquery-storage-api-example

End-to-end example in Golang for Bigquery Storage API
Go
7
star
14

go-objectgraph

Walk a runtime object graph
Go
3
star
15

jsoncat

Streaming json pretty-printer
Python
2
star
16

bufferlinks

Go
2
star
17

thesis

My PhD thesis from my computer vision research at Oxford.
TeX
2
star
18

nix-environment

The standard system tools I use everywhere to feel at home.
Python
2
star
19

image-marks

A simple graphical tool to specify manual point-to-point correspondences between two images.
Python
2
star
20

sturm-triangulation

Using sturm sequences for triangulation in inverse depth parametrization
Python
1
star
21

SublimeHoon

1
star
22

sticky-sync

Sync stickies from OSX to iOS and Android
Python
1
star
23

orangetheory

Extract data from Orange Theory emails and write as CSV
Go
1
star
24

logical-induction

Code to support the guide to logical induction for software engineers (not yet published).
Python
1
star
25

rigidbody

Rigid body transforms in 3D
Python
1
star
26

printjson

JSON pretty printer
Go
1
star
27

spline-initialization

Linear and SOCP initialization
Python
1
star
28

convex-vins-paper

Latex source for "a convex formulation of visual inertial navigation"
TeX
1
star
29

threeplot

Browser-based 3D plotting in Python
Python
1
star
30

gproj

Manage GCP projects and enabled APIs using a yaml file
Go
1
star
31

doc-publisher

Publish blog posts from Google docs to medium, lesswrong, PDF
Go
1
star
32

mutablerecord

Recordset framework for small python structures
Python
1
star
33

manifolds

Utilities for dealing with differentiable manifolds
Python
1
star
34

stl-trajectories

Show SLAM trajectories as STL models
Python
1
star
35

go-mold

Load types from Go source files
Go
1
star