-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Consider moving away from unmaintained gojay #3373
Comments
@marten-seemann can you update accordingly?
|
What is there to update? We're already using the most recent gojay version. |
I don't think there's anything to update. And I don't understand under what circumstances that build issue is happening (doesn't for me). Maybe there's some build modes where said proxy isn't used? Anyway my request is more about dropping an unmaintained library (gojay), that also adds unnecessary dependencies - which as a nice side-effect will also fix this build error. |
@marten-seemann the thrift source site is outdated |
@imsodin, sorry, I was only replying to @dmanlfc yesterday.
You're right, the only thing we care about is decoding JSON. It's used for qlog, where we're logging (when enabled) every single frame in every single packet received (plus a bunch of other internal events). It's super valuable for debugging QUIC transfers, especially when combined with the awesome qvis. I'd be very happy to move to encoding/json, but last time I benchmarked it, it was really slow (unfortunately, I don't have that benchmark lying around any more). Unfortunately, I don't currently have the time to tackle this transition. |
To add more details why The frames passed to qlog are defined in the Now one might argue that one could define the JSON serialization of frames in the
Note that this also immediately excludes these two candidates, as they try to emulate the interface of |
Could perhaps use something more like: |
Also doesn't allow serialization without allocations. Really, moving away from gojay is only an option if we can preserve the performance properties. If not, I don't see any problem staying with gojay, even if it's unmaintained (it outputs correct JSON really fast, and that's the main thing that matters). |
My main motivation were the build failures caused by transitive dependencies. With module graph pruning since go1.17 this isn't a problem anymore, as the problematic dependency isn't actually used by quic-go thus since 1.17 go doesn't try to build it anymore. Now having benchmarks for this to check performance would still be good, e.g. in case gojay breaks somehow in the future, however it's a no longer an important concern for me so I don't plan to work on it in the near future. |
gojay has a dependency on Apache Thrift. Apache's git repo is now on GH, so the url for the dependency is out of date and won't build. |
Can’t reproduce. Builds on my machine, and builds on CI. |
https://github.com/mailru/easyjson might be an alternative. It works with code generation (and generates quite a lot of LOC), but it is fast! Here's a benchmark:
Code: var h = packetHeader{
PacketType: getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake),
PacketNumber: 1337,
Version: protocol.Version1,
}
func BenchmarkPacketHeaderGoJay(b *testing.B) {
buf := bytes.NewBuffer(make([]byte, 0, 1000))
enc := gojay.NewEncoder(buf)
for i := 0; i < b.N; i++ {
if err := enc.Encode(h); err != nil {
b.Fatal(err)
}
buf.Reset()
}
}
func BenchmarkPacketHeaderEasyJSON(b *testing.B) {
buf := buffer.Buffer{Buf: make([]byte, 0, 1000)}
w := &jwriter.Writer{Buffer: buf}
for i := 0; i < b.N; i++ {
h.MarshalEasyJSON(w)
buf.DumpTo(io.Discard)
}
} One thing we'd need to figure out is how to rewrite custom marshaling logic such that the encoding output doesn't change. For example, we can't use "omitempty" for the |
One more option we could look into: https://github.com/bytedance/sonic |
Gojay has not seen any activity in a long time, and one of it's dependencies isn't available at the given source path anymore, causing build failures:
francoispqt/gojay#128
syncthing/syncthing#8256
Looking at a recent comparison (https://medium.com/geekculture/my-golang-json-evaluation-20a9ca6ef79c) it looks like the standard
encoding/json
library is pretty decent for encoding (and there's only encoding in the usecase here, right?). Otherwise https://github.com/goccy/go-json or https://github.com/json-iterator/go look like good candidates.The text was updated successfully, but these errors were encountered: