Comments (7)
I agree with @robzan8. It make a misunderstanding on Gob. Gob is the same fast as protobuf in my tests.
from go_serialization_benchmarks.
I'd welcome a PR for this. I tried, but kept getting corrupt message errors:
BenchmarkGobMarshal-8 1000000 1207 ns/op 48 B/op 2 allocs/op
BenchmarkGobUnmarshal-8 b=61
--- FAIL: BenchmarkGobUnmarshal-8
serialization_benchmarks_test.go:114: gob failed to unmarshal: gob: unknown type id or corrupted data (<��b9b2b4faa77947cf�4���IL�
1ca61f574b��Y�K���?)
ok github.com/alecthomas/go_serialization_benchmarks 1.244s
from go_serialization_benchmarks.
I'm pretty sure I understand where the issue comes from.
The first time a gob encoder encodes a value of a certain type that has never encountered before, it also transmits type information needed by the decoder for that type.
in function benchUnmarshal, ser[0] also contains serialized type info that is needed to decode elements of type A. So, for everything to work correctly, ser[0] should be the first thing decoded by the decoder.
Unfortunately, the decoder chooses at random what to decode, and it reports that a value with unknown type id has been encountered.
To fix the problem, ser[0] should be decoded only once, before anything else (before some other ser[i]). Another thing that may work is calling gob.Register(a) (where "a" is a value of type A), before doing the encoding/decoding (former method works for sure, I'm not sure about the latter).
I may be able to do a PR in the next few days.
from go_serialization_benchmarks.
I can't run the benchmarks on master because zombiezen.com/go/capnproto2 has been moved.
I tried go-getting https://github.com/zombiezen/go-capnproto2
but I get the following error:
can't load package: package github.com/zombiezen/go-capnproto2: code in directory $GOPATH/src/github.com/zombiezen/go-capnproto2 expects import "zombiezen.com/go/capnproto2"
Am I missing something?
from go_serialization_benchmarks.
zombiezen.com/go/capnproto2 uses a go-import meta redirect, so it should still work. It works for me:
[alec@cavern:~/Projects/go_serialization_benchmarks]go get -u zombiezen.com/go/capnproto2
[alec@cavern:~/Projects/go_serialization_benchmarks]
PS. Did you try using the Makefile? make clean && make install && make
from go_serialization_benchmarks.
zombiezen.com/go/capnproto2 was down yesterday when I tried; works now.
from go_serialization_benchmarks.
Before first use you to gob.Register
. That's where the errors came from.
from go_serialization_benchmarks.
Related Issues (20)
- Add benchmark for gjson
- Command, go get -u -t get error
- gob: unknown type id or corrupted data HOT 2
- Buffer Reuse Inconsistency HOT 1
- Skip running benchmarks for X if X fails to build HOT 4
- Gogoprotobuf Alternative? HOT 4
- How to test serializing a map?
- Limitations of the benchmarking HOT 2
- gogoprotobuf is deprecated
- Mus Strings HOT 24
- Bebop input data HOT 6
- Buffer Reuse Inconsistency Again HOT 6
- BENC's unsafe code HOT 10
- why is greenpack and zebrapack not included in the benchmarks? HOT 2
- panic: not implemented HOT 1
- What does tt.kb means in marshall benchmarks? HOT 1
- Bebop "message" and "union" definition benchmarks HOT 1
- I think it should be warned that gogo/protobuf is almost discontinued HOT 1
- Add Go Protobuf APIv2 tests
- Feature request: add benchmark for google protobuf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go_serialization_benchmarks.