Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switched to msgpack for encoding #66

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danhab99
Copy link

MSGPACK is known to be a faster alternative to JSON while fulfilling all the same features. Go's msgpack is written to be a drop in replacement for code that already uses json, so I dropped in the replacement.

Benchmarks

# Old JSON

goos: linux
goarch: amd64
pkg: github.com/nakabonne/tstorage
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkStorage_InsertRows-8                  	 9356394	       432.3 ns/op	     229 B/op	       4 allocs/op
BenchmarkStorage_SelectAmongThousandPoints-8   	14496987	       369.8 ns/op	      56 B/op	       2 allocs/op
BenchmarkStorage_SelectAmongMillionPoints-8    	16722625	       268.8 ns/op	      56 B/op	       2 allocs/op
PASS
ok  	github.com/nakabonne/tstorage	17.837s
# New MSGPACK

goos: linux
goarch: amd64
pkg: github.com/nakabonne/tstorage
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkStorage_InsertRows-8                  	11978878	       409.6 ns/op	     228 B/op	       4 allocs/op
BenchmarkStorage_SelectAmongThousandPoints-8   	13840152	       352.6 ns/op	      56 B/op	       2 allocs/op
BenchmarkStorage_SelectAmongMillionPoints-8    	17263482	       268.4 ns/op	      56 B/op	       2 allocs/op
PASS
ok  	github.com/nakabonne/tstorage	22.404s

As we can see there's a 22.6ns performance improvement in insertions representing a 5% performance buff. This aswell as smaller encoded bits yield smaller DBs and less ram usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant