-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Change JSON library to improve performance #840
Conversation
I'll check the quality of github.com/json-iterator some times later |
Can you try |
@hjweddie Hi do you have any response for it? |
sorry for late, I will try it in this week |
I agree with your concern, maybe we could use another more active json repo, like https://github.com/goccy/go-json |
You can inspect the workload to see which table the JSON parsing comes from. If the table is not needed, we can use |
In fact we use jsonitor in production for years and did not encounter Marshal/Unmarshal failures. Maybe it is with good functionality |
I agree |
I have reviewed my production program, it is a monitor towards binlog size to get original data difference, is it necessary to parse it ? I guest it may be necessary ? |
@atercattus PTAL |
We also have some incompatibilities with stdlib in github.com/json-iterator/go. So I cannot recommend it. @hjweddie, can you show your pprof with github.com/goccy/go-json? Is performance difference significant? |
I have replaced github.com/json-iterator/go with github.com/goccy/go-json in this pr |
ping @atercattus |
Sorry for the late response. pprof with go-json looks good. So good that I don't see this library at all :) |
I think I can generate a binlog file that's full of JSON change, and let this library consume it, to see the performance improvement. I'm busy now, will do it in next week |
I started a MySQL in localhost, and generate some JSON INSERT to get a 1G binlog file. Then I compare the time of reading and parsing that file master: this PR: so LGTM |
I confirm that Following your concern regarding exchanging standard I'm encountering unusual errors such as: When encoding :
It points somewhere to
When decoding :
Upon reverting to standard |
Thanks for reporting @slotix , can you find the JSON content when error happens? We can check if the error pattern will also occur in MySQL binlog.
@atercattus not sure if we should give github.com/goccy/go-json a chance 😂 |
Bad news... @slotix, could you catch this json? Maybe I can fix goccy or at least I’ll understand what’s wrong. Upd. I found goccy/go-json#493 :) |
Please wait for a moment. I need to conduct more thorough testing. Interestingly, for some reason, I haven't been able to reproduce this bug at all since this morning :) P.S. Please disregard my initial message about errors caused by goccy/go-json. I thoroughly tested my code throughout the day, marshaling/unmarshaling over 150GB of randomly generated JSON data, and encountered none of the errors reported yesterday. I suspect that some ghost instances of my services may have caused these strange problems. |
我们在生产环境解析full image binlog时,cpu使用率非常高。进行pprof之后发现在json.Unmarshal函数的消费非常大。
我们是否可以使用性能更优的json库来替换encoding/json呢?
We found heavy cpu usage when parsing full image binlog. As our pprof result, find that encoding/json.Unmarshal consumes much cpu time. Is it posible to use jsonitor or other json libary for better json unmarshal performance ?