Open jhendrixMSFT opened 2 years ago
Unfortunately, json.Decoder
has some perf problems which prevents us from building performant, custom unmarshallers on top of it (see https://github.com/golang/go/issues/40128). For now, we'll just fix up the marshallers.
BenchmarkCurrentUnmarshaller-4 46093 26880 ns/op 4857 B/op 87 allocs/op
BenchmarkPrototypeUnmarshaller-4 44324 25808 ns/op 7200 B/op 286 allocs/op
Hi @jhendrixMSFT, we deeply appreciate your input into this project. Regrettably, this issue has remained unresolved for over 2 years and inactive for 30 days, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.
Our reliance on the standard library's JSON marshaller/unmarshaller is unnecessary (and expensive) as we have all the type information available during code generation. Consider the below benchmarks.
The second benchmark (
BenchmarkPrototypeMarshaller
) uses a custom JSON marshaller that builds the JSON string with astrings.Builder
. It starts with a 512-byte buffer (more didn't improve things). However, this value might need to be tuned for optimal performance.The win is very clear and is worth investigating further.