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

Drop support for go 1.18 #587

Merged
merged 1 commit into from
Dec 1, 2022
Merged

Drop support for go 1.18 #587

merged 1 commit into from
Dec 1, 2022

Conversation

fishy
Copy link
Member

@fishy fishy commented Nov 30, 2022

Use the new atomic package API introduced in go 1.19:

  • Replace atomic.Value with atomic.Pointer
  • Replace atomic.Add*/Store*/Load*/etc. with new Int*/Uint* atomic types
  • Except the atomic.Value used in filewatcher, as to take full advantage of that we would need to make breaking API changes to filewatcher

@fishy fishy requested a review from a team as a code owner November 30, 2022 19:41
@fishy fishy requested review from kylelemons, pacejackson and ghirsch-reddit and removed request for a team November 30, 2022 19:41
if c := kc.getConsumer(); c != nil {
if err := c.Close(); err != nil {
if c := kc.consumer.Load(); c != nil && *c != nil {
if err := (*c).Close(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔕 The change here definitely feels worse. (*c)s and &c both? It looks wrong, at least.

As long as the type safety ensures that people don't mess it up, I'm probably fine with it, but it just doesn't seem great.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's kind of a compromise between excessive pointer (dereference) vs. type assertions to deal with any, as atomic.Pointer forces pointer even if the interface itself is already a pointer. the main problem is basically that there's not a way to say "pointer-like" in go's type system (e.g. make it happy to accept a pointer that implements an interface).

between the two I think type assertions are worse, but maybe that's just me :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can keep the helper function to return a (possibly nil) interface instead, so the code here won't look as bad ¯\_(ツ)_/¯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracing/tags.go Outdated
// never mutate the returned result, so skip copying is OK.
//
// But if any of those assumptions are broken in the future, we can not storing
// the atomic.Pointer[[]string] naively, and would need to either make a copy or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔕 What you could also do is store an atomic.Pointer[string] and do a split whenver you need to access it. Splitting a string into a slice is quite fast, and in some cases you might even get escape analysis to notice the slice isn't leaked.

(only works if there is a safe way to use some delimiter without messing up the tags)

Copy link
Contributor

@pacejackson pacejackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the commit message you want is "Drop support for go 1.18", "drop support to" sounds like you are dropping the support down to 1.18 rather than removing it.

@fishy fishy changed the title Drop support to go 1.18 Drop support for go 1.18 Nov 30, 2022
Use the new atomic package API introduced in go 1.19:

* Replace atomic.Value with atomic.Pointer
* Replace atomic.Add*/Store*/Load*/etc. with new Int*/Uint* atomic types
* Except the atomic.Value used in filewatcher, as to take full advantage
  of that we would need to make breaking API changes to filewatcher
@fishy
Copy link
Member Author

fishy commented Dec 1, 2022

Made a slight word tweak on the comments because the original one has some grammar errors :) merging it.

@fishy fishy merged commit 2dd3ab8 into reddit:master Dec 1, 2022
@fishy fishy deleted the atomic-pointer branch December 1, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants