From the beginning of Go, the time package has had a gotcha: if you use a select on <-time.After(1*time.Minute), even if the select finishes immediately because some other case is ready, the underlying timer from time.After keeps running until the minute is over. This pins the timer in the timer heap, which keeps it from being garbage collected and in extreme cases also slows down timer operations. The lack of garbage collection is the more important problem. The docs for After warn against this scenario and suggest using NewTimer with a call to Stop after the select instead, purely to work around this garbage collection problem. Oddly, the docs for NewTimer and NewTicker do not mention this problem, but they have the same issue: they cannot be collected until either they are Stopped or, in the case of Timer, the timer expires. (Tickers repeat, so they never expire.) People have built up a shared knowledge that timers and tickers need to defer t.Stop even though the docs do not mention this (it is somewhat implied by the After docs). This CL fixes the garbage collection problem, so that a timer that is unreferenced can be GC'ed immediately, even if it is still running. The approach is to only insert the timer into the heap when some channel operation is blocked on it; the last channel operation to stop using the timer takes it back out of the heap. When a timer's channel is no longer referenced, there are no channel operations blocked on it, so it's not in the heap, so it can be GC'ed immediately. This CL adds an undocumented GODEBUG asynctimerchan=1 that will disable the change. The documentation happens in the CL 568341. Fixes #8898. Fixes #61542. Change-Id: Ieb303b6de1fb3527d3256135151a9e983f3c27e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/512355 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org> |
||
|---|---|---|
| .. | ||
| initial | ||
| next | ||
| README.md | ||
| asm.html | ||
| go1.17_spec.html | ||
| go_mem.html | ||
| go_spec.html | ||
| godebug.md | ||
README.md
Release Notes
The initial and next subdirectories of this directory are for release notes.
For developers
Release notes should be added to next by editing existing files or creating new files.
At the end of the development cycle, the files will be merged by being concatenated in sorted order by pathname. Files in the directory matching the glob "*stdlib/*minor" are treated specially. They should be in subdirectories corresponding to standard library package paths, and headings for those package paths will be generated automatically.
Files in this repo's api/next directory must have corresponding files in
doc/next/*stdlib/*minor.
The files should be in the subdirectory for the package with the new
API, and should be named after the issue number of the API proposal.
For example, if the directory 6-stdlib/99-minor is present,
then an api/next file with the line
pkg net/http, function F #12345
should have a corresponding file named doc/next/6-stdlib/99-minor/net/http/12345.md.
At a minimum, that file should contain either a full sentence or a TODO,
ideally referring to a person with the responsibility to complete the note.
Use the following forms in your markdown:
[`http.Request`](/pkg/net/http#Request) # symbol documentation
[#12345](/issue/12345) # GitHub issues
[CL 6789](/cl/6789) # Gerrit changelists
For the release team
At the start of a release development cycle, the contents of next should be deleted
and replaced with those of initial. From the repo root:
> cd doc
> rm -r next/*
> cp -r initial/* next
Then edit next/1-intro.md to refer to the next version.
To prepare the release notes for a release, run golang.org/x/build/cmd/relnote generate.
That will merge the .md files in next into a single file.