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

remove use of json-iterator / reflect2 #202

Open
liggitt opened this issue Sep 14, 2021 · 15 comments
Open

remove use of json-iterator / reflect2 #202

liggitt opened this issue Sep 14, 2021 · 15 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@liggitt
Copy link

liggitt commented Sep 14, 2021

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 golang/go#48238 (comment)

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 (golang/go#48238 (comment))

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 kubernetes/kubernetes#105030

I would encourage this project to consider the long-term sustainability/safety of the json-iterator dependency as well.

@lavalamp
Copy link
Contributor

I think the uses here are benchmarked and it should be easy to tell if swapping out json-iterator causes a regression.

@liggitt
Copy link
Author

liggitt commented Oct 22, 2021

kubernetes/kubernetes#105030 is now merged and this is on the short-list of things in k/k that still use json-iterator

@liggitt
Copy link
Author

liggitt commented Oct 22, 2021

it looks like this uses really specialized serializing capabilities provided by json-iterator... not sure swapping will be easy

@k8s-triage-robot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 20, 2022
@k8s-triage-robot
Copy link

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

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 19, 2022
@k8s-triage-robot
Copy link

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-ci-robot
Copy link
Contributor

@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 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

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.

@liggitt
Copy link
Author

liggitt commented Mar 30, 2022

/reopen
/lifecycle frozen

@k8s-ci-robot
Copy link
Contributor

@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.

@k8s-ci-robot k8s-ci-robot reopened this Mar 30, 2022
@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Mar 30, 2022
@liggitt
Copy link
Author

liggitt commented Mar 30, 2022

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

@apelisse
Copy link
Contributor

apelisse commented Oct 6, 2022

When json-next-experimental becomes non-experimental, we could consider this. I don't think we need to solve this right now though.

@liggitt
Copy link
Author

liggitt commented Oct 10, 2022

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

@dominiquelefevre
Copy link

dominiquelefevre commented Jan 3, 2024

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.

@inteon
Copy link
Member

inteon commented Apr 11, 2024

@liggitt I created a first working version: #257

@liggitt liggitt changed the title reconsider use of json-iterator / reflect2 remove use of json-iterator / reflect2 Nov 21, 2024
@liggitt
Copy link
Author

liggitt commented Nov 21, 2024

/cc @jpbetz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants