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

Update to Go 1.18 #9677

Closed
bep opened this issue Mar 15, 2022 · 7 comments
Closed

Update to Go 1.18 #9677

bep opened this issue Mar 15, 2022 · 7 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Mar 15, 2022

  • The go command now embeds version control information in binaries. New debug/buildinfo package
  • go work (OK)
  • {{break}} command will end the loop early and the new {{continue}}
  • The and function no longer always evaluates all arguments;
  • TryLock

Notes

@bep bep self-assigned this Mar 15, 2022
@bep bep modified the milestones: v0.95.0, v0.96.0 Mar 15, 2022
@kaushalmodi
Copy link
Contributor

These are awesome!

  • {{break}} command will end the loop early and the new {{continue}}
  • The and function no longer always evaluates all arguments;

@alexanderhansen
Copy link

I run Hugo in a docker container along with go. In the image build Hugo gets build from scratch (I run on an m1 mac and need extended and never dropped the process since the arm64 extended binary is available) - anyways I rebuild with Go 1.18 last night and everything looks fine. If there is anything I can test in particular, just let me know.

@bep
Copy link
Member Author

bep commented Mar 16, 2022

Just a quick note to whomever watches this -- when I push my updates for this, Hugo will no longer build with < Go 1.18. We usually have a "2 version" policy, but that doesn't work in this case, and the updates in Go 1.18 are a little too good to pass on. And this only applies to "building from source", the release binaries will run fine on "any" computer.

bep added a commit to bep/hugo that referenced this issue Mar 16, 2022
bep added a commit to bep/hugo that referenced this issue Mar 16, 2022
Using Go tag go1.18 4aa1efed4853ea067d665a952eee77c52faac774

Updates gohugoio#9677
bep added a commit to bep/hugo that referenced this issue Mar 16, 2022
Go 1.18 had some breaking changes on source level meaning we cannot build on older Go versions anymore.

The improvements in Go 1.18 (e.g. `break` and `continue`)  were to good to pass on.

Note that you don't need Go (or Go 1.18) to run a pre-built binary.

Updates gohugoio#9677
bep added a commit to bep/hugo that referenced this issue Mar 16, 2022
@bep
Copy link
Member Author

bep commented Mar 16, 2022

Some benchmarks comparing it to Go 1.17.8 ...

name                                      old time/op    new time/op    delta
SiteNew/Regular_Bundle_with_image-10        5.13ms ± 7%    4.23ms ± 7%  -17.47%  (p=0.029 n=4+4)
SiteNew/Regular_Bundle_with_JSON_file-10    5.12ms ± 1%    4.16ms ± 1%  -18.65%  (p=0.029 n=4+4)
SiteNew/Regular_Tags_and_categories-10      17.3ms ± 2%    15.1ms ± 1%  -12.53%  (p=0.029 n=4+4)
SiteNew/Regular_Canonify_URLs-10             106ms ± 1%      90ms ± 0%  -15.86%  (p=0.029 n=4+4)
SiteNew/Regular_Deep_content_tree-10        34.0ms ± 1%    30.0ms ± 2%  -11.72%  (p=0.029 n=4+4)
SiteNew/Regular_TOML_front_matter-10        22.7ms ± 2%    20.2ms ± 1%  -10.93%  (p=0.029 n=4+4)
SiteNew/Regular_Many_HTML_templates-10      16.7ms ± 0%    14.6ms ± 1%  -12.89%  (p=0.029 n=4+4)
SiteNew/Regular_Page_collections-10         22.2ms ± 1%    19.5ms ± 1%  -12.07%  (p=0.029 n=4+4)
SiteNew/Regular_List_terms-10               7.71ms ± 0%    6.59ms ± 1%  -14.52%  (p=0.029 n=4+4)

name                                      old alloc/op   new alloc/op   delta
SiteNew/Regular_Bundle_with_image-10        2.07MB ± 0%    2.04MB ± 0%   -1.40%  (p=0.029 n=4+4)
SiteNew/Regular_Bundle_with_JSON_file-10    1.85MB ± 0%    1.83MB ± 0%   -1.54%  (p=0.029 n=4+4)
SiteNew/Regular_Tags_and_categories-10      11.8MB ± 0%    11.1MB ± 0%   -6.11%  (p=0.029 n=4+4)
SiteNew/Regular_Canonify_URLs-10            95.8MB ± 0%    95.2MB ± 0%   -0.63%  (p=0.029 n=4+4)
SiteNew/Regular_Deep_content_tree-10        27.4MB ± 0%    26.9MB ± 0%   -1.68%  (p=0.029 n=4+4)
SiteNew/Regular_TOML_front_matter-10        15.2MB ± 0%    14.4MB ± 0%   -4.93%  (p=0.029 n=4+4)
SiteNew/Regular_Many_HTML_templates-10      8.45MB ± 0%    8.24MB ± 0%   -2.43%  (p=0.029 n=4+4)
SiteNew/Regular_Page_collections-10         16.5MB ± 0%    16.2MB ± 0%   -1.78%  (p=0.029 n=4+4)
SiteNew/Regular_List_terms-10               3.73MB ± 0%    3.64MB ± 0%   -2.30%  (p=0.029 n=4+4)

name                                      old allocs/op  new allocs/op  delta
SiteNew/Regular_Bundle_with_image-10         25.0k ± 0%     24.1k ± 0%   -3.60%  (p=0.029 n=4+4)
SiteNew/Regular_Bundle_with_JSON_file-10     25.1k ± 0%     24.1k ± 0%   -3.60%  (p=0.029 n=4+4)
SiteNew/Regular_Tags_and_categories-10        237k ± 0%      234k ± 0%   -1.29%  (p=0.029 n=4+4)
SiteNew/Regular_Canonify_URLs-10              365k ± 0%      363k ± 0%   -0.47%  (p=0.029 n=4+4)
SiteNew/Regular_Deep_content_tree-10          284k ± 0%      279k ± 0%   -1.98%  (p=0.029 n=4+4)
SiteNew/Regular_TOML_front_matter-10          252k ± 0%      249k ± 0%   -1.48%  (p=0.029 n=4+4)
SiteNew/Regular_Many_HTML_templates-10        117k ± 0%      115k ± 0%   -1.68%  (p=0.029 n=4+4)
SiteNew/Regular_Page_collections-10           184k ± 0%      181k ± 0%   -1.74%  (p=0.029 n=4+4)
SiteNew/Regular_List_terms-10                49.9k ± 0%     48.5k ± 0%   -2.79%  (p=0.029 n=4+4)

@kaushalmodi
Copy link
Contributor

The go command now embeds version control information in binaries. New debug/buildinfo package

Will that take away the need to do this in the build script?

go build .. -ldflags "-s -w -X github.com/gohugoio/hugo/common/hugo.commitHash=5930173cd -X github.com/gohugoio/hugo/common/hugo.buildDate=2022-03-16T08:54:06-0400" ..

I just tried rebuilding with go 1.18. It works, but those -ldflags .. -X switches are still needed.

@bep
Copy link
Member Author

bep commented Mar 16, 2022

Will that take away the need to do this in the build script?

I don't know. That will be a task for another day.

@bep bep closed this as completed Mar 16, 2022
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants