Commit graph

3787 commits

Author SHA1 Message Date
syumai 0fa53e41f1 spec: fix link for instantiations
This change corrects the link `Instantiantions` to `Instantiations` in the spec.

Change-Id: Ib0ed03420ae401d20af1ea723c5487018b2f462d
GitHub-Last-Rev: b84316c818
GitHub-Pull-Request: golang/go#49816
Reviewed-on: https://go-review.googlesource.com/c/go/+/367274
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-11-27 23:29:50 +00:00
Carlo Alberto Ferraris a142d6587c doc: go1.18 release notes for CLs 323318/332771
Updates #47694

Change-Id: Ib76737996a701906117e096eb6d05b388576a874
GitHub-Last-Rev: 05b9649965
GitHub-Pull-Request: golang/go#49588
Reviewed-on: https://go-review.googlesource.com/c/go/+/363840
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
2021-11-27 19:49:32 +00:00
Jason A. Donenfeld 77038044ca doc/go1.18: document non-cooperative preemption on windows/arm{,64}
For #47694.
Updates #49759.

Change-Id: I7accd81b8ea6c31e4a2b5e155cf93fe9c447813b
Reviewed-on: https://go-review.googlesource.com/c/go/+/367095
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-11-26 13:18:11 +00:00
jiahua wang 5527d7ff79 doc/go1.18: add Clone doc
For #47694

Change-Id: I3b135f6ff199d7a9746726b131fbe7dd97a8e95e
Reviewed-on: https://go-review.googlesource.com/c/go/+/364254
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Heschi Kreinick <heschi@google.com>
2021-11-24 21:08:29 +00:00
Robert Griesemer 696515ee39 spec: type assertions and switches don't operate on type parameters
Change-Id: I11111b3617673be94508128489aed6488d518537
Reviewed-on: https://go-review.googlesource.com/c/go/+/366834
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:54:12 +00:00
Robert Griesemer 6ea17aa52c spec: adjust type identity rules for type parameters
Change-Id: I5ffc7f26236487070447eaa0f6b14d1fab44c3c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/366794
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:54:07 +00:00
Robert Griesemer a3b8f627c2 spec: add section on instantiation
Change-Id: I2770da87b4c977b51dfa046f2f08283917675e1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/365916
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-11-24 20:53:54 +00:00
Robert Griesemer ce2a20af46 spec: adjust conversion rules for type parameters
Change-Id: I7bfddf4be0d1d95419f312bb349ae2e16b74b795
Reviewed-on: https://go-review.googlesource.com/c/go/+/365915
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:53:51 +00:00
Robert Griesemer 939480033a spec: adjust assignability rules for type parameters
Change-Id: I3c4d8bdb5e92ee7fdca9593fb043f94f467755e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/365434
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:53:45 +00:00
Robert Griesemer 003e7faf53 spec: adjust representability rules for type parameters
Change-Id: I4423a059527066c4418c195911f8184dfd3f5a15
Reviewed-on: https://go-review.googlesource.com/c/go/+/365914
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:53:29 +00:00
Robert Griesemer 5d8c49a5a1 spec: add definition of "specific types" of an interface
The notion of specific types will be used to define rules for
assignability, convertability, etc. when type parameters are
involved.

Change-Id: Ic5c134261e2a9fe05cdf25efd342f052458ab5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/366754
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-24 20:51:25 +00:00
Dmitri Shuralyov e883005d2a doc/go1.18: document that iOS 12 or newer is required
For #47694.
Updates #49616.
Updates #48076.

Change-Id: I570564c3a54d3cd9cfc9b8267df9fbee3363b650
Reviewed-on: https://go-review.googlesource.com/c/go/+/366914
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-24 18:59:20 +00:00
Robert Griesemer 0244343088 spec: fix Swap example (correctly swap type arguments and parameters)
Thanks to @danscales for noticing the mistake.

Change-Id: I547ee80a78419765b82d39d7b34dc8d3bf962c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/366215
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-11-22 23:00:32 +00:00
Robert Griesemer 7456b94853 doc/go1.18: document new overflow error for some untyped arguments to print/ln
Fixes #49216.
For #47694.

Change-Id: Ib129d790c382ddcc9677d87db4ca827b7159856a
Reviewed-on: https://go-review.googlesource.com/c/go/+/366275
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-22 22:36:03 +00:00
Robert Griesemer 7fbe2f4cc8 doc/go1.18: document compiler change for "declared but not used" errors
Fixes #49214.
For #47694.

Change-Id: Iba68ed17bfd81890309b6a6732087f87a03e1350
Reviewed-on: https://go-review.googlesource.com/c/go/+/366274
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-22 22:35:57 +00:00
Robert Griesemer e30ebaab0b spec: add section on the structure of interfaces
This change introduces the notion of a structural interface
and its corresponding structural type.

Change-Id: Ib5442dfd04cb5950b4467428cae51849f8922272
Reviewed-on: https://go-review.googlesource.com/c/go/+/365474
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-22 04:27:29 +00:00
Robert Griesemer a287c4aa38 spec: add type parameter types
- add section on type parameters
- added two sections on the scope of type parameters
- expanded general section on types accordingly
- introduced the notion of a named type which will
  help in simplifying various rules (subsequent CLs)

Change-Id: I49c1ed7d6d4f951d751f0a3ca5dfb637e49829f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/365414
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-22 03:24:07 +00:00
Robert Griesemer 0c3b4a358a spec: add type parameter lists
Change-Id: I29e9188a0fa1326c2755a9b86aeb47feaa8019be
Reviewed-on: https://go-review.googlesource.com/c/go/+/365274
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-22 03:24:01 +00:00
Cherry Mui ba9f0f6665 doc/go1.18: mention register ABI on ARM64 and PPC64
For #47694.

Change-Id: Ide378f4a34587027c3d84fed2126c5b9bd8f7287
Reviewed-on: https://go-review.googlesource.com/c/go/+/363694
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-11-19 21:41:33 +00:00
Jeremy Faller aec5c2eed6 [go] doc: document speedups to Trim[|Left|Right]
CL: #332771

Updates: #47694
Change-Id: I8c729084b7a8745ec73f87ef3c469edbd596ddb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/365318
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-11-19 21:36:24 +00:00
Jeremy Faller 0f75a9ecdf [go] doc: add new bufio functionality
cl/345570
cl/345569

Updates: #47694
Change-Id: I170af16d5fc9f022d3d29ed0772cfc3d02b8bbcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/365317
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-11-19 21:36:17 +00:00
Robert Griesemer 24898d6948 spec: various clarifications/fixes for method sets and interfaces
- fixed a typo in the method set section
- express in the syntax that ~T denotes an underlying type
- be more precise when talking about types vs type terms
- refer to "unions" rather than "union expressions"
- make it clear in the spec title that this is WIP

Change-Id: I9b2c4b1f77bc50dd574ed6893bedd40529c320fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/365154
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-18 20:11:45 +00:00
Robert Griesemer f6647f2e3b spec: generalize method sets and interface types to type sets
This is the first of several CLs that update the existing
Go 1.17 spec for type parameters.

This CL updates the section on method sets and interface types.
It also adds "any", "comparable" to the list of predeclared
identifiers.

Change-Id: I0ce25dc02791c33150c0d949528512610faf3eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/362999
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-18 06:05:29 +00:00
Keith Randall febbef593e doc: mention generics in release notes
Also mention local types restriction.

We probably want to say more at some point, this is just a
placeholder to start.

Update #47631

Change-Id: I828e451e1e8504d21cb55c7132e9cb330b160a54
Reviewed-on: https://go-review.googlesource.com/c/go/+/364134
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-16 06:31:54 +00:00
jiahua wang 865689571d doc/go1.18: add AppendRune doc
For #47694

Change-Id: I39594c273aeb038702457587ee1c46e4b3920bb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/363359
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Jeremy Faller <jeremy@golang.org>
2021-11-16 05:36:07 +00:00
Keith Randall dfa62c79de doc: document GOAMD64 environment variable
Update #47694

Change-Id: I9c90bd251616cd4d10434bd3b6e6c30c5c819e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/363661
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-14 16:54:11 +00:00
Robert Griesemer d60a4e69f1 spec: fix a broken link
Thanks for jtagcat@ for finding this.

Change-Id: If7324808edbae19ec8bf503b04e0426f3fb3b47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363394
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 19:44:13 +00:00
Neil Alexander 666fc173c0 doc/go1.18: document http.Transport.Dial* being used in js/wasm
This PR adds a note into the Go 1.18 changelog for CL 330852.

Updates #46923.

Change-Id: I99150e9275ce23fcf3697d6a22ac216818223c74
GitHub-Last-Rev: b2772ce68b
GitHub-Pull-Request: golang/go#49258
Reviewed-on: https://go-review.googlesource.com/c/go/+/360297
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-11 16:17:21 +00:00
Bryan C. Mills 47b3ab5ede doc/go1.18: add a release note for 'go mod vendor -o'
For #47327

Change-Id: I50418c0d017c4e90a2c13d26945ee639079e4e33
Reviewed-on: https://go-review.googlesource.com/c/go/+/363174
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paschalis Tsilias <paschalistsilias@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 14:57:18 +00:00
Robert Griesemer 17980dff36 doc: make a copy of the latest Go 1.17 spec
This will allow us to compare the changes made for Go 1.18.

Change-Id: I1456270b201967f5cb05e66cec556939e6e33265
Reviewed-on: https://go-review.googlesource.com/c/go/+/362894
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-10 05:08:25 +00:00
smasher164 ab31dbc05b doc/go1.18: strings,bytes: deprecate Title
Updates #48367.

Change-Id: Ib8fc6d9dd7c3c6a70fefe077615f51a71d9c42ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/361899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-08 14:49:56 +00:00
Dmitri Shuralyov ba79c1e241 doc/go1.18: split bytes and strings packages
A small touchup after CL 361894.

For #47694.

Change-Id: Ifc161516f897f727195d21351a3c8eda7b6e327e
Reviewed-on: https://go-review.googlesource.com/c/go/+/361895
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Carlos Amedee <carlos@golang.org>
2021-11-05 22:54:47 +00:00
Dmitri Shuralyov f00b43f28c doc/go1.18: fill in Go 1.18 release note TODOs using relnote
For #47694.

Change-Id: Ia80a1859bd0fc6f08d27293f519c22fd9a804fd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/361894
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2021-11-05 22:00:37 +00:00
Bryan C. Mills 1f9dce749d cmd/go: download fewer dependencies in 'go mod download'
In modules that specify 'go 1.17' or higher, the go.mod file
explicitly requires modules for all packages transitively imported by
the main module. Users tend to use 'go mod download' to prepare for
testing the main module itself, so we should only download those
relevant modules.

In 'go 1.16' and earlier modules, we continue to download all modules
in the module graph (because we cannot in general tell which ones are
relevant without loading the full package import graph).

'go mod download all' continues to download every module in
'go list all', as it did before.

Fixes #44435

Change-Id: I3f286c0e2549d6688b3832ff116e6cd77a19401c
Reviewed-on: https://go-review.googlesource.com/c/go/+/357310
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-11-04 20:42:35 +00:00
Brad Fitzpatrick 2157498dfe doc/go1.18: remove some redundancy from netip docs
Change-Id: I593862331add3366f6b337844588568301746b80
Reviewed-on: https://go-review.googlesource.com/c/go/+/360608
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 22:20:40 +00:00
Brad Fitzpatrick c1ea3395a6 doc/go1.18: add net/netip
Updates #46518

Change-Id: Iefc2fec93becc7b36ba2b933ae79f7c9424317fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/360634
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 06:20:21 +00:00
Bryan C. Mills a88575d662 Revert "cmd/go: remove support for -buildmode=shared"
This reverts CL 359096.

Updates #47788.

Reason for revert: -buildmode=shared may have actually been working in a few very specific cases. We should not remove -buildmode=shared until we have implemented an alternative to support those few cases.

Change-Id: Ia962b06abacc11f6f29fc29d092773be175e32f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/359575
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-10-29 17:32:24 +00:00
Mark Pulford 749f6e9eb6 doc/go1.18: document Fossil/Bazaar and commit time build tag support
Change-Id: I032791a3cda1916099b0fd2955dcca4e69763660
Reviewed-on: https://go-review.googlesource.com/c/go/+/357958
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-27 21:37:54 +00:00
Bryan C. Mills 68bd5121ee cmd/go: remove support for -buildmode=shared
It never worked in module mode (or with a read-only GOROOT).
A proposal to drop it was filed (and approved) in
https://golang.org/issue/47788.

Fixes #47788

Change-Id: I0c12f38eb0c5dfe9384fbdb49ed202301fa4273d
Reviewed-on: https://go-review.googlesource.com/c/go/+/359096
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-27 20:03:17 +00:00
gosoon 0ec1b62ee2 doc/go1.18.html: fix a typo
gofmt -> <code>gofmt</code>

Change-Id: Idc01b01d8eb185f5e378000d11d622935b14db6e
GitHub-Last-Rev: 8d55dc7b86
GitHub-Pull-Request: golang/go#49084
Reviewed-on: https://go-review.googlesource.com/c/go/+/357251
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
2021-10-26 00:38:52 +00:00
Cuong Manh Le 6c200017bf doc: document new reflect.UnsafePointer function
Updates #40592

Change-Id: If66629e47ca9859128ee3ad8fb584e022d7a6982
Reviewed-on: https://go-review.googlesource.com/c/go/+/356255
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-23 06:31:02 +00:00
Jay Conrod 85cbdda5a6 doc/go1.18: add release notes for build and VCS info
Fixes #37475
For #39301

Change-Id: I765bc667004931ff8973b947f2e95624a4a0375d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356013
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
2021-10-15 20:29:48 +00:00
Keith Randall 22951fbc89 cmd/compile: make for loops with range statements not terminating
Fixes #49003

Change-Id: If09c6f028dce5440b1be238612653ffdd626113a
Reviewed-on: https://go-review.googlesource.com/c/go/+/356189
Trust: Keith Randall <khr@golang.org>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-10-15 19:54:44 +00:00
Keith Randall 81484cf626 doc: document new reflect.SetIter{Key,Value} functions
Update #48294
Update #47694

Change-Id: I4d4c01be74a9736d89a4ec92318ce29ff7289a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356050
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-10-15 05:20:52 +00:00
Yuval Pavel Zholkover f2141a71c6 doc/go1.18: document FreeBSD 11.x will no longer be supported
Mention future versions will require the COMPAT_FREEBSD12 kernel option
set in the kernel.

For #47694.

Change-Id: Ia94c4f9dbb38c68025d3c1d12dd2e241a5480a6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/354971
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-11 15:43:15 +00:00
Jay Conrod 3a555977fc cmd/go: add release note for 'go get' changes
For #43684

Change-Id: I9ce47de82203ec87e7d3683f56e6c6d61ae255f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/352151
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-09-28 17:19:19 +00:00
Daniel Martí 1ce6fd03b8 cmd/gofmt: format files in parallel
gofmt is pretty heavily CPU-bound, since parsing and formatting 1MiB
of Go code takes much longer than reading that amount of bytes from
disk. However, parsing and manipulating a large Go source file is very
difficult to parallelize, so we continue to process each file in its
own goroutine.

A Go module may contain a large number of Go source files, so we need
to bound the amount of work in flight. However, because the
distribution of sizes for Go source files varies widely — from tiny
doc.go files containing a single package comment all the way up to
massive API wrappers generated by automated tools — the amount of
time, work, and memory overhead needed to process each file also
varies. To account for this variability, we limit the in-flight work
by bytes of input rather than by number of files. That allows us to
make progress on many small files while we wait for work on a handful
of large files to complete.

The gofmt tool has a well-defined output format on stdout, which was
previously deterministic. We keep it deterministic by printing the
results of each file in order, using a lazily-synchronized io.Writer
(loosly inspired by Haskell's IO monad). After a file has been
formatted in memory, we keep it in memory (again, limited by the
corresponding number of input bytes) until the output for all previous
files has been flushed. This adds a bit of latency compared to
emitting the output in nondeterministic order, but a little extra
latency seems worth the cost to preserve output stability.

This change is based on Daniel Martí's work in CL 284139, but using a
weighted semaphore and ephemeral goroutines instead of a worker pool
and batches. Benchmark results are similar, and I find the concurrency
in this approach a bit easier to reason about.

In the batching-based approach, the batch size allows us to "look
ahead" to find large files and start processing them early. To keep
the CPUs saturated and prevent stragglers, we would need to tune the
batch size to be about the same as the largest input files. If the
batch size is set too high, a large batch of small files could turn
into a straggler, but if the batch size is set too low, the largest
files in the data set won't be started early enough and we'll end up
with a large-file straggler.

One possible alternative would be to sort by file size instead of
batching: identify all of the files to be processed, sort from largest
to smallest, and then process the largest files first so that the
"tail" of processing covers the smallest files. However, that approach
would still fail to saturate available CPU when disk latency is high,
would require buffering an arbitrary amount of metadata in order to
sort by size, and (perhaps most importantly!) would not allow the
`gofmt` binary to preserve the same (deterministic) output order that
it has today.

In contrast, with a semaphore we can produce the same deterministic
output as ever using only one tuning parameter: the memory footprint,
expressed as a rough lower bound on the amount of RAM available per
thread. While we're below the memory limit, we can run arbitrarily
many disk operations arbitrarily far ahead, and process the results of
those operations whenever they become avaliable. Then it's up to the
kernel (not us) to schedule the disk operations for throughput and
latency, and it's up to the runtime (not us) to schedule the
goroutines so that they complete quickly.

In practice, even a modest assumption of a few megabytes per thread
seems to provide a nice speedup, and it should scale reasonably even
to machines with vastly different ratios of CPU to disk. (In practice,
I expect that most 'gofmt' invocations will work with files on at most
one physical disk, so the CPU:disk ratio should vary more-or-less
directly with the thread count, whereas the CPU:memory ratio is
more-or-less independent of thread count.)

name \ time/op         baseline.txt  284139.txt    simplified.txt
GofmtGorootCmd           11.9s ± 2%     2.7s ± 3%       2.8s ± 5%

name \ user-time/op    baseline.txt  284139.txt    simplified.txt
GofmtGorootCmd           13.5s ± 2%    14.4s ± 1%      14.7s ± 1%

name \ sys-time/op     baseline.txt  284139.txt    simplified.txt
GofmtGorootCmd           465ms ± 8%    229ms ±28%      232ms ±31%

name \ peak-RSS-bytes  baseline.txt  284139.txt    simplified.txt
GofmtGorootCmd          77.7MB ± 4%  162.2MB ±10%    192.9MB ±15%

For #43566

Change-Id: I4ba251eb4d188a3bd1901039086be57f0b341910
Reviewed-on: https://go-review.googlesource.com/c/go/+/317975
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2021-09-24 21:38:56 +00:00
Robert Griesemer 5402b4376c spec: fix incorrect type in a shift example
Thanks to @bodar (Github) for finding this.

Fixes #48422.

Change-Id: I031c3d82a02db1d204e2b86b494d89784d37f073
Reviewed-on: https://go-review.googlesource.com/c/go/+/350409
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-16 23:13:48 +00:00
Robert Griesemer 9a58aa267e spec: fix prose about terminating statements
CL 85215 added prose to provide some minimal intuition for the
definition of a "terminating statement". While the original definition
was perfectly fine, the added prose was actually incorrect: If the
terminating statement is a goto, it might jump to a labeled statement
following that goto in the same block (it could be the very next
statement), and thus a terminating statement does not in fact
"prevent execution of all statements that lexically appear after
it in the same block".

Rather than explaining the special case for gotos with targets that
are lexically following the goto in the same block, this CL opts for
a simpler approach.

Thanks to @3bodar (Github) for finding this.

Fixes #48323.

Change-Id: I8031346250341d038938a1ce6a75d3e687d32c37
Reviewed-on: https://go-review.googlesource.com/c/go/+/349172
Trust: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-13 22:57:34 +00:00
WANG Xuerui cf2fe5d6f1 doc/asm: fix HTML markup
Change-Id: I33bde4835d3b83fafd55beea483f6236c4c62840
Reviewed-on: https://go-review.googlesource.com/c/go/+/338990
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
2021-09-10 17:15:37 +00:00