-
Notifications
You must be signed in to change notification settings - Fork 62
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
Migrate github.com/json-iterator/go to sigs.k8s.io/json #257
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: inteon The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Yeah, that's ambitious. There's a reason we had written the code the way we did, but let's see what the benchmarks say. You can do ... IIRC
to run the benchmark. Do that against master and the tip of your branch, save the output in files, run |
Benchmarks will be essential here. This code was hyper-optimized because it was on a hot path. |
This is what I get:
|
/hold |
b7e17b3
to
b8f304c
Compare
I applied a few hacks and optimisations in 59b4860 and 4f4fbff. These changes improved the performance quite a bit compared to the initial version. However, the performance is still a bit worse than the current version on master (
|
For context, there were quite a few months of engineering effort to optimize the performance of SSA, and in particular, managed fields. I'm supportive of making this code better, but I feel responsible to ensure that we don't regress significantly here. |
This PR aims to be the very best attempt at making #202 work. If we do achieve the required performance, this PR will be the proof that it is not possible to switch to the "encoding/json" package unless the performance of that package is improved. |
@inteon: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
For more context,
Suck it up and be correct first. |
I don't get it, what are we supposed to suck up? And who is even supposed to? Are we supposed to suck up the performance impact, or are we supposed to get it done somehow? |
@liggitt In 2024, what's the best json library in Go to build a json part by part and stream it directly rather than serialize everything in a big string? |
Gojay seems like a good alternative, it seems to have good performance, custom encoding/decoding, and a streaming API: https://github.com/francoispqt/gojay |
if we were going to pull in another json library, I'd aim for the same one we used in kube-openapi (https://github.com/kubernetes/kube-openapi/tree/master/pkg/internal/third_party/go-json-experiment) since that's where it looks like the stdlib is headed (golang/go#63397) and supports streaming / custom encoding/decoding, etc |
"bytes" | ||
gojson "encoding/json" | ||
"runtime" | ||
"unsafe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really not a fan of adding unsafe usages
//go:nosplit | ||
//go:nocheckptr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really not a fan of point-in-time copies of runtime code that could become unsafe in the future
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
fixes #202
Replaces "github.com/json-iterator/go" with "sigs.k8s.io/json" and "encoding/json".
TODO: compare benchmarks before and after <- help would be appreciated here.