Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

roeest
Copy link
Contributor

@roeest roeest commented Nov 7, 2022

goccy/go-json is a more performant version of encoding/json.
Using it seems to improve the amount of memory allocated and ns/op.
I used the benchmark in _examples/starwars to compare the performance:

encoding/json version:

BenchmarkSimpleQueryNoArgs-12              48986             23931 ns/op            8237 B/op        146 allocs/op

goccy/go-json version:

BenchmarkSimpleQueryNoArgs-12              53048             21194 ns/op            7824 B/op        141 allocs/op

On average i observed about a 5% improvement

@coveralls
Copy link

coveralls commented Nov 7, 2022

Coverage Status

Coverage remained the same at 75.653% when pulling df55d5d on roeest:master into 3087cf3 on 99designs:master.

@mtibben
Copy link
Member

mtibben commented Dec 12, 2022

With just a 5% improvement in reality this might shave off microseconds from a typical request. Personally I don't think it's worth diverging from the stdlib for tiny gains

@auvn
Copy link
Contributor

auvn commented May 30, 2023

@roeest may you check the diff if it goes with https://github.com/json-iterator/go ?

@roeest
Copy link
Contributor Author

roeest commented Jun 1, 2023

@roeest may you check the diff if it goes with https://github.com/json-iterator/go ?

I could do that. I'm also considering expanding the size of the requests and responses and adding another test to the benchmark, I was looking at the doc and the improvement is more significant for larger data. Now I just need to find some time to do it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants