Skip to content

Commit 97abf44

Browse files
authored
Object Serialization Benchmarks (#32)
1 parent 7084810 commit 97abf44

14 files changed

+3189
-1
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,21 @@ The Honu Database is an eventually consistent replicated document database that
88
Smart anti-entropy uses reinforcement learning with multi-armed bandits to optimize replication. Adaptive consistency reduces costs (ingress and egress data transfer) as well as improves consistency by lowering the likelihood of stale reads or forked writes.
99

1010
The goal of the database is to provide scalable data retrieval both in terms of number of nodes (e.g. scale to 100s of nodes) and amount of data (hundreds of terabytes). In addition to scale, this database provides data access controls, privacy and provenance, and other security related features. In short, HonuDB is a distributed data governance database for machine learning and artificial intelligence workloads.
11+
12+
13+
## Object Storage
14+
15+
Protocol Buffers are a compact, cross-language compatible data serialization format that facilitates compact network communications. However, in order to make them general purpose and flexible, they require a lot of reflection to work in Go. Since a database is a high performance application, I've implemented a data serialization format that uses no reflection and as a result performs far better at decoding than Protocol Buffers:
16+
17+
```
18+
goos: darwin
19+
goarch: arm64
20+
pkg: github.com/rotationalio/honu/pkg/store
21+
cpu: Apple M1 Max
22+
BenchmarkSerialization/Small/Encode/Honu-10 653840 1905 ns/op 1471 bytes 4319 B/op 2 allocs/op
23+
BenchmarkSerialization/Small/Encode/Protobuf-10 346150 3164 ns/op 2426 bytes 4044 B/op 1 allocs/op
24+
BenchmarkSerialization/Small/Decode/Honu-10 343032 3421 ns/op 4784 B/op 62 allocs/op
25+
BenchmarkSerialization/Small/Decode/Protobuf-10 161241 7889 ns/op 8367 B/op 127 allocs/op
26+
```
27+
28+
![Benchmarks](./docs/serialization-benchmark.png)

docs/serialization-benchmark.png

15.9 KB
Loading

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module github.com/rotationalio/honu
22

3-
go 1.23.2
3+
go 1.23.1
44

55
require (
66
github.com/joho/godotenv v1.5.1
7+
github.com/oklog/ulid v1.3.1
78
github.com/rotationalio/confire v1.1.0
89
github.com/rs/zerolog v1.33.0
910
github.com/stretchr/testify v1.9.0
1011
github.com/urfave/cli/v2 v2.27.5
12+
google.golang.org/protobuf v1.35.1
1113
)
1214

1315
require (

go.sum

+8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
7+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
8+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
79
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
810
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
911
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
1012
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
1113
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
1214
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
1315
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
16+
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
17+
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
1418
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1519
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1620
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -31,6 +35,10 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
3135
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3236
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
3337
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
39+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
40+
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
41+
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
3442
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3543
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3644
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

pkg/object/generate.go

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package object
2+
3+
//go:generate bash generate.sh

pkg/object/generate.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
PROTOS="${GOPATH}/src/github.com/rotationalio/honu/proto"
4+
5+
if [[ ! -d $PROTOS ]]; then
6+
echo "cannot find ${PROTOS}"
7+
exit 1
8+
fi
9+
10+
MODULE="github.com/rotationalio/honu/pkg/object/v1"
11+
MOD="github.com/rotationalio/honu/pkg/object/v1;object"
12+
OUT="./v1"
13+
14+
if [[ ! -d $OUT ]]; then
15+
mkdir $OUT
16+
fi
17+
18+
protoc -I=${PROTOS} \
19+
--go_out=${OUT} \
20+
--go_opt=module="${MODULE}" \
21+
--go_opt=Mobject/v1/object.proto="${MOD}" \
22+
object/v1/object.proto

0 commit comments

Comments
 (0)