replace encoding/json with goccy/go-json (#2421 expanded)#3161
replace encoding/json with goccy/go-json (#2421 expanded)#3161roeest wants to merge 5 commits into99designs:masterfrom
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: