-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
replace encoding/json with goccy/go-json (#2421 expanded) #3161
base: master
Are you sure you want to change the base?
Conversation
DO NOT MERGE THIS goccy/go-json IS NOT A DROP IN REPLACEMENT FOR STDLIB I would personally never use it on production. |
@adomaskizogian Yeah, I actually tried merging this a couple of times and ran into problems like what you described. I'm not categorically opposed to using goccy/go-json but there would need to be some better proof that the library is more of a drop in replacement for the standards lib. For instance, https://github.com/nst/JSONTestSuite is a comprehensive test suite for RFC 8259 compliant JSON parsers, and it would require goccy/go-json to pass that. |
It should be configurable, to generate code depends on the end-user choose, but I prefer standard library for all of cases. |
This is a revival of pr #2421.
I switched over to https://github.com/goccy/go-json instead of encoding/json. Previously it wasn't accepted because it only showed a ~5% improvement in performance in the starwars test suite. I added a test that handles larger json requests and responses (_examples/benchmarking) and in those cases the improvement was better than 5%.
As you can see here the runtime improvement is 37% on average and the memory allocations are less frequent averaging 5% less allocations and the memory usage increased by less than 10% on average.
If you prefer i can make this a configurable value, it'll be a bit tricky and i'll probably have to use some sort of global variable.
I have: