structured-merge-diff
structured-merge-diff copied to clipboard
reconsider use of json-iterator / reflect2
The approach taken by json-iterator and its reflect library is not long-term stable (it pins to internal details of the stdlib reflect package), and requires maintenance per go release, which does not appear to be sustainable https://github.com/golang/go/issues/48238#issuecomment-917000973
Minimum versions to work with go1.18+ are:
- github.com/json-iterator/go v1.1.12
- github.com/modern-go/reflect2 v1.0.2
In addition to the maintenance aspect, it is hard to reason about the safety of the implementation (https://github.com/golang/go/issues/48238#issuecomment-916331048)
I'm exploring what it would look like to use the stdlib json decoder as a base and add in the features we rely on (case-sensitive keys, preservation of ints/floats, etc) in https://github.com/kubernetes/kubernetes/pull/105030
I would encourage this project to consider the long-term sustainability/safety of the json-iterator dependency as well.
I think the uses here are benchmarked and it should be easy to tell if swapping out json-iterator causes a regression.
https://github.com/kubernetes/kubernetes/pull/105030 is now merged and this is on the short-list of things in k/k that still use json-iterator
it looks like this uses really specialized serializing capabilities provided by json-iterator... not sure swapping will be easy
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale
- Mark this issue or PR as rotten with
/lifecycle rotten
- Close this issue or PR with
/close
- Offer to help out with Issue Triage
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 issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle rotten
- Close this issue or PR with
/close
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Reopen this issue or PR with
/reopen
- Mark this issue or PR as fresh with
/remove-lifecycle rotten
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close
@k8s-triage-robot: Closing this issue.
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied- After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied- After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closedYou can:
- Reopen this issue or PR with
/reopen
- Mark this issue or PR as fresh with
/remove-lifecycle rotten
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close
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.
/reopen /lifecycle frozen
@liggitt: Reopened this issue.
In response to this:
/reopen /lifecycle frozen
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.
with the release of go1.18, the json-iterator / reflect2 versions this lib uses as of today will not work with current versions of go
When json-next-experimental becomes non-experimental, we could consider this. I don't think we need to solve this right now though.
I would still consider use of json-iterator a risk due to its history with correctness issues and reliance on specific internal implementations of the go runtime
There is more trouble that reflect2 brings. It inhibits the dead code elimination in the golang compiler.
Golang 1.22 has learned to keep the DCE enabled when the usages of MethodByName()
are limited to MethodByName(compile-time constant)
. Usages of MethodByName()
in github.com/kubernetes/kubernetes
are DCE-friendly already, and various dependencies like google.golang.org/protobuf
and github.com/kubernetes/kube-openapi
were fixed to be DCE-friendly over several last months.
reflect2
plays tricks that confuse golang and disable the DCE. Everything that depends on structured-merge-diff
, even indirectly, compiles with the DCE disabled because of reflect2
.
@liggitt I created a first working version: https://github.com/kubernetes-sigs/structured-merge-diff/pull/257