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

Rewrite SplitLocale to not allocate #23

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

Jacalz
Copy link
Contributor

@Jacalz Jacalz commented Feb 19, 2024

This improves performance and makes the code more readable. It also updates to use Go 1.19 as the base in go.mod so we get pruned module graphs (old Go compilers can still compile the code).

Benchstat:

goos: linux
goarch: amd64
pkg: github.com/fyne-io/go-locale
cpu: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
              │   old.txt    │              new.txt               │
              │    sec/op    │   sec/op     vs base               │
SplitLocale-8   119.75n ± 1%   20.55n ± 1%  -82.84% (p=0.002 n=6)

              │  old.txt   │              new.txt              │
              │    B/op    │   B/op     vs base                │
SplitLocale-8   64.00 ± 0%   0.00 ± 0%  -100.00% (p=0.002 n=6)

              │  old.txt   │              new.txt               │
              │ allocs/op  │ allocs/op   vs base                │
SplitLocale-8   2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.002 n=6)

@Jacalz
Copy link
Contributor Author

Jacalz commented Feb 22, 2024

Looks like the workflows need to be updated to run on Go 1.19.

@Jacalz
Copy link
Contributor Author

Jacalz commented Feb 22, 2024

I can get that fixed later today.

@jeandeaual
Copy link
Owner

Thanks for the PR, this does simplify the code and makes it easier to read 👍

This improves performance and makes the code more readable. It also updates to use Go 1.19 as the base in go.mod so we get pruned module graphs (old Go compilers can still compile the code).

I don't think that's true, since you're using strings.Cut, Go 1.18+ will be required to compile the code.

This improves performance and makes the code more readable. It also updates to use Go 1.19 as the base in go.mod so we get pruned module graphs (old Go compilers can still compile the code).

Since graph pruning was introduced in Go 1.17 and we now rely on strings.Cut, we can set the minimum supported version to be Go 1.18.

Looks like the workflows need to be updated to run on Go 1.19.

At least, removing Go 1.17 from the pipeline should be enough to run the tests.

go.mod Outdated
@@ -1,6 +1,6 @@
module github.com/jeandeaual/go-locale

go 1.14
go 1.19
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
go 1.19
go 1.18

@jeandeaual jeandeaual self-assigned this Feb 23, 2024
Copy link
Owner

@jeandeaual jeandeaual left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for your contribution!

@jeandeaual jeandeaual merged commit ce5225d into jeandeaual:master Feb 23, 2024
20 checks passed
@Jacalz Jacalz deleted the splitlocale-no-alloc branch February 23, 2024 14:19
@Jacalz
Copy link
Contributor Author

Jacalz commented Feb 23, 2024

I'm happy to help. You might get more contributions for the team given that we are planning on using your package in Fyne going forward :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants