aboutsummaryrefslogtreecommitdiff
path: root/src/sync
AgeCommit message (Collapse)Author
4 daysall: document legacy //go:linkname for modules with ≥100 dependentsRuss Cox
For #67401. Change-Id: I015408a3f437c1733d97160ef2fb5da6d4efcc5c Reviewed-on: https://go-review.googlesource.com/c/go/+/587598 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
10 daysall: document legacy //go:linkname for modules with ≥500 dependentsRuss Cox
For #67401. Change-Id: I7dd28c3b01a1a647f84929d15412aa43ab0089ee Reviewed-on: https://go-review.googlesource.com/c/go/+/587575 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
10 daysall: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-17sync/atomic: public And/Or ops and race instrumentationMauri de Souza Meneguzzo
This CL implements the new sync/atomic AND and OR apis as well as their race counterparts. Fixes #61395 Change-Id: I294eefe4b3ac27bc4ed237edcbfa88a8c646d86f GitHub-Last-Rev: f174297007c7b81b1ff4a687ef23d955a3ffd4db GitHub-Pull-Request: golang/go#64331 Reviewed-on: https://go-review.googlesource.com/c/go/+/544455 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2024-05-17all: add push linknames to allow legacy pull linknamesCherry Mui
CL 585358 adds restrictions to disallow pull-only linknames (currently off by default). Currently, there are quite some pull- only linknames in user code in the wild. In order not to break those, we add push linknames to allow them to be pulled. This CL includes linknames found in a large code corpus (thanks Matthew Dempsky and Michael Pratt for the analysis!), that are not currently linknamed. Updates #67401. Change-Id: I32f5fc0c7a6abbd7a11359a025cfa2bf458fe767 Reviewed-on: https://go-review.googlesource.com/c/go/+/586137 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-23sync: add examples for OnceValue and OnceValuesAustin Clements
Updates #56102. Change-Id: I2ee2dbc43b4333511d9d23752fdc574dfbf5f5bd Reviewed-on: https://go-review.googlesource.com/c/go/+/481062 Reviewed-by: Andrew Gerrand <adg@golang.org> Auto-Submit: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joedian Reid <joedian@google.com>
2024-03-25runtime: migrate internal/atomic to internal/runtimeAndy Pan
For #65355 Change-Id: I65dd090fb99de9b231af2112c5ccb0eb635db2be Reviewed-on: https://go-review.googlesource.com/c/go/+/560155 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ibrahim Bazoka <ibrahimbazoka729@gmail.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-21sync: name the Map.CompareAndSwap return valuePeter Collingbourne
The godoc for sync.Map.CompareAndSwap does not document the meaning of its return value. Document it by giving it a name. Change-Id: I50ad9c078a7885f5ce83489d66d138d491c35861 Reviewed-on: https://go-review.googlesource.com/c/go/+/572657 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-28all: run go fmtsivchari
I ran go fmt to fix format on the entire repository. Change-Id: I2f09166b6b8ba0ffb0ba27f6500efb0ea4cf21ff Reviewed-on: https://go-review.googlesource.com/c/go/+/566835 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-02-26sync: add available godoc linkcui fliter
Change-Id: I9bc5fd29b0eec8ceadcfee2116de5e7524ef92c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/539617 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26sync: simplify the code with atomic.Pointerapocelipes
Change-Id: I79797be6b385c9927d68350334d7f7387007085f GitHub-Last-Rev: 3daa3b144f55f527d183d4ff35475ca4af3ee143 GitHub-Pull-Request: golang/go#65937 Reviewed-on: https://go-review.googlesource.com/c/go/+/566815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-01sync: update doc for Map.ClearJes Cok
Change-Id: I9bcc5c82321cbc93f1c7aafd1dadf4f6b862ccbd GitHub-Last-Rev: 818b95528f6beb6178b385953b49fbfbaeb31a82 GitHub-Pull-Request: golang/go#65429 Reviewed-on: https://go-review.googlesource.com/c/go/+/560396 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-01sync: add Map.ClearHiro
Fixes #61696 Change-Id: I0a31afd3bc433fc84280d56f2798bda10da61eba GitHub-Last-Rev: 17bedc864f1685178a42b59f7083677a6124f831 GitHub-Pull-Request: golang/go#61702 Reviewed-on: https://go-review.googlesource.com/c/go/+/515015 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-08sync: use map[any]any instead of map[interface{}]interface{} in the godocsivchari
It's shorter and clearer. Change-Id: Ibfbe5a7f8d70fa884691ba9858a2c9b2122d9c50 Reviewed-on: https://go-review.googlesource.com/c/go/+/531475 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-12-05math/rand, math/rand/v2: use ChaCha8 for global randRuss Cox
Move ChaCha8 code into internal/chacha8rand and use it to implement runtime.rand, which is used for the unseeded global source for both math/rand and math/rand/v2. This also affects the calculation of the start point for iteration over very very large maps (when the 32-bit fastrand is not big enough). The benefit is that misuse of the global random number generators in math/rand and math/rand/v2 in contexts where non-predictable randomness is important for security reasons is no longer a security problem, removing a common mistake among programmers who are unaware of the different kinds of randomness. The cost is an extra 304 bytes per thread stored in the m struct plus 2-3ns more per random uint64 due to the more sophisticated algorithm. Using PCG looks like it would cost about the same, although I haven't benchmarked that. Before this, the math/rand and math/rand/v2 global generator was wyrand (https://github.com/wangyi-fudan/wyhash). For math/rand, using wyrand instead of the Mitchell/Reeds/Thompson ALFG was justifiable, since the latter was not any better. But for math/rand/v2, the global generator really should be at least as good as one of the well-studied, specific algorithms provided directly by the package, and it's not. (Wyrand is still reasonable for scheduling and cache decisions.) Good randomness does have a cost: about twice wyrand. Also rationalize the various runtime rand references. goos: linux goarch: amd64 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ bbb48afeb7.amd64 │ 5cf807d1ea.amd64 │ │ sec/op │ sec/op vs base │ ChaCha8-32 1.862n ± 2% 1.861n ± 2% ~ (p=0.825 n=20) PCG_DXSM-32 1.471n ± 1% 1.460n ± 2% ~ (p=0.153 n=20) SourceUint64-32 1.636n ± 2% 1.582n ± 1% -3.30% (p=0.000 n=20) GlobalInt64-32 2.087n ± 1% 3.663n ± 1% +75.54% (p=0.000 n=20) GlobalInt64Parallel-32 0.1042n ± 1% 0.2026n ± 1% +94.48% (p=0.000 n=20) GlobalUint64-32 2.263n ± 2% 3.724n ± 1% +64.57% (p=0.000 n=20) GlobalUint64Parallel-32 0.1019n ± 1% 0.1973n ± 1% +93.67% (p=0.000 n=20) Int64-32 1.771n ± 1% 1.774n ± 1% ~ (p=0.449 n=20) Uint64-32 1.863n ± 2% 1.866n ± 1% ~ (p=0.364 n=20) GlobalIntN1000-32 3.134n ± 3% 4.730n ± 2% +50.95% (p=0.000 n=20) IntN1000-32 2.489n ± 1% 2.489n ± 1% ~ (p=0.683 n=20) Int64N1000-32 2.521n ± 1% 2.516n ± 1% ~ (p=0.394 n=20) Int64N1e8-32 2.479n ± 1% 2.478n ± 2% ~ (p=0.743 n=20) Int64N1e9-32 2.530n ± 2% 2.514n ± 2% ~ (p=0.193 n=20) Int64N2e9-32 2.501n ± 1% 2.494n ± 1% ~ (p=0.616 n=20) Int64N1e18-32 3.227n ± 1% 3.205n ± 1% ~ (p=0.101 n=20) Int64N2e18-32 3.647n ± 1% 3.599n ± 1% ~ (p=0.019 n=20) Int64N4e18-32 5.135n ± 1% 5.069n ± 2% ~ (p=0.034 n=20) Int32N1000-32 2.657n ± 1% 2.637n ± 1% ~ (p=0.180 n=20) Int32N1e8-32 2.636n ± 1% 2.636n ± 1% ~ (p=0.763 n=20) Int32N1e9-32 2.660n ± 2% 2.638n ± 1% ~ (p=0.358 n=20) Int32N2e9-32 2.662n ± 2% 2.618n ± 2% ~ (p=0.064 n=20) Float32-32 2.272n ± 2% 2.239n ± 2% ~ (p=0.194 n=20) Float64-32 2.272n ± 1% 2.286n ± 2% ~ (p=0.763 n=20) ExpFloat64-32 3.762n ± 1% 3.744n ± 1% ~ (p=0.171 n=20) NormFloat64-32 3.706n ± 1% 3.655n ± 2% ~ (p=0.066 n=20) Perm3-32 32.93n ± 3% 34.62n ± 1% +5.13% (p=0.000 n=20) Perm30-32 202.9n ± 1% 204.0n ± 1% ~ (p=0.482 n=20) Perm30ViaShuffle-32 115.0n ± 1% 114.9n ± 1% ~ (p=0.358 n=20) ShuffleOverhead-32 112.8n ± 1% 112.7n ± 1% ~ (p=0.692 n=20) Concurrent-32 2.107n ± 0% 3.725n ± 1% +76.75% (p=0.000 n=20) goos: darwin goarch: arm64 pkg: math/rand/v2 │ bbb48afeb7.arm64 │ 5cf807d1ea.arm64 │ │ sec/op │ sec/op vs base │ ChaCha8-8 2.480n ± 0% 2.429n ± 0% -2.04% (p=0.000 n=20) PCG_DXSM-8 2.531n ± 0% 2.530n ± 0% ~ (p=0.877 n=20) SourceUint64-8 2.534n ± 0% 2.533n ± 0% ~ (p=0.732 n=20) GlobalInt64-8 2.172n ± 1% 4.794n ± 0% +120.67% (p=0.000 n=20) GlobalInt64Parallel-8 0.4320n ± 0% 0.9605n ± 0% +122.32% (p=0.000 n=20) GlobalUint64-8 2.182n ± 0% 4.770n ± 0% +118.58% (p=0.000 n=20) GlobalUint64Parallel-8 0.4307n ± 0% 0.9583n ± 0% +122.51% (p=0.000 n=20) Int64-8 4.107n ± 0% 4.104n ± 0% ~ (p=0.416 n=20) Uint64-8 4.080n ± 0% 4.080n ± 0% ~ (p=0.052 n=20) GlobalIntN1000-8 2.814n ± 2% 5.643n ± 0% +100.50% (p=0.000 n=20) IntN1000-8 4.141n ± 0% 4.139n ± 0% ~ (p=0.140 n=20) Int64N1000-8 4.140n ± 0% 4.140n ± 0% ~ (p=0.313 n=20) Int64N1e8-8 4.140n ± 0% 4.139n ± 0% ~ (p=0.103 n=20) Int64N1e9-8 4.139n ± 0% 4.140n ± 0% ~ (p=0.761 n=20) Int64N2e9-8 4.140n ± 0% 4.140n ± 0% ~ (p=0.636 n=20) Int64N1e18-8 5.266n ± 0% 5.326n ± 1% +1.14% (p=0.001 n=20) Int64N2e18-8 6.052n ± 0% 6.167n ± 0% +1.90% (p=0.000 n=20) Int64N4e18-8 8.826n ± 0% 9.051n ± 0% +2.55% (p=0.000 n=20) Int32N1000-8 4.127n ± 0% 4.132n ± 0% +0.12% (p=0.000 n=20) Int32N1e8-8 4.126n ± 0% 4.131n ± 0% +0.12% (p=0.000 n=20) Int32N1e9-8 4.127n ± 0% 4.132n ± 0% +0.12% (p=0.000 n=20) Int32N2e9-8 4.132n ± 0% 4.131n ± 0% ~ (p=0.017 n=20) Float32-8 4.109n ± 0% 4.105n ± 0% ~ (p=0.379 n=20) Float64-8 4.107n ± 0% 4.106n ± 0% ~ (p=0.867 n=20) ExpFloat64-8 5.339n ± 0% 5.383n ± 0% +0.82% (p=0.000 n=20) NormFloat64-8 5.735n ± 0% 5.737n ± 1% ~ (p=0.856 n=20) Perm3-8 26.65n ± 0% 26.80n ± 1% +0.58% (p=0.000 n=20) Perm30-8 194.8n ± 1% 197.0n ± 0% +1.18% (p=0.000 n=20) Perm30ViaShuffle-8 156.6n ± 0% 157.6n ± 1% +0.61% (p=0.000 n=20) ShuffleOverhead-8 124.9n ± 0% 125.5n ± 0% +0.52% (p=0.000 n=20) Concurrent-8 2.434n ± 3% 5.066n ± 0% +108.09% (p=0.000 n=20) goos: linux goarch: 386 pkg: math/rand/v2 cpu: AMD Ryzen 9 7950X 16-Core Processor │ bbb48afeb7.386 │ 5cf807d1ea.386 │ │ sec/op │ sec/op vs base │ ChaCha8-32 11.295n ± 1% 4.748n ± 2% -57.96% (p=0.000 n=20) PCG_DXSM-32 7.693n ± 1% 7.738n ± 2% ~ (p=0.542 n=20) SourceUint64-32 7.658n ± 2% 7.622n ± 2% ~ (p=0.344 n=20) GlobalInt64-32 3.473n ± 2% 7.526n ± 2% +116.73% (p=0.000 n=20) GlobalInt64Parallel-32 0.3198n ± 0% 0.5444n ± 0% +70.22% (p=0.000 n=20) GlobalUint64-32 3.612n ± 0% 7.575n ± 1% +109.69% (p=0.000 n=20) GlobalUint64Parallel-32 0.3168n ± 0% 0.5403n ± 0% +70.51% (p=0.000 n=20) Int64-32 7.673n ± 2% 7.789n ± 1% ~ (p=0.122 n=20) Uint64-32 7.773n ± 1% 7.827n ± 2% ~ (p=0.920 n=20) GlobalIntN1000-32 6.268n ± 1% 9.581n ± 1% +52.87% (p=0.000 n=20) IntN1000-32 10.33n ± 2% 10.45n ± 1% ~ (p=0.233 n=20) Int64N1000-32 10.98n ± 2% 11.01n ± 1% ~ (p=0.401 n=20) Int64N1e8-32 11.19n ± 2% 10.97n ± 1% ~ (p=0.033 n=20) Int64N1e9-32 11.06n ± 1% 11.08n ± 1% ~ (p=0.498 n=20) Int64N2e9-32 11.10n ± 1% 11.01n ± 2% ~ (p=0.995 n=20) Int64N1e18-32 15.23n ± 2% 15.04n ± 1% ~ (p=0.973 n=20) Int64N2e18-32 15.89n ± 1% 15.85n ± 1% ~ (p=0.409 n=20) Int64N4e18-32 18.96n ± 2% 19.34n ± 2% ~ (p=0.048 n=20) Int32N1000-32 10.46n ± 2% 10.44n ± 2% ~ (p=0.480 n=20) Int32N1e8-32 10.46n ± 2% 10.49n ± 2% ~ (p=0.951 n=20) Int32N1e9-32 10.28n ± 2% 10.26n ± 1% ~ (p=0.431 n=20) Int32N2e9-32 10.50n ± 2% 10.44n ± 2% ~ (p=0.249 n=20) Float32-32 13.80n ± 2% 13.80n ± 2% ~ (p=0.751 n=20) Float64-32 23.55n ± 2% 23.87n ± 0% ~ (p=0.408 n=20) ExpFloat64-32 15.36n ± 1% 15.29n ± 2% ~ (p=0.316 n=20) NormFloat64-32 13.57n ± 1% 13.79n ± 1% +1.66% (p=0.005 n=20) Perm3-32 45.70n ± 2% 46.99n ± 2% +2.81% (p=0.001 n=20) Perm30-32 399.0n ± 1% 403.8n ± 1% +1.19% (p=0.006 n=20) Perm30ViaShuffle-32 349.0n ± 1% 350.4n ± 1% ~ (p=0.909 n=20) ShuffleOverhead-32 322.3n ± 1% 323.8n ± 1% ~ (p=0.410 n=20) Concurrent-32 3.331n ± 1% 7.312n ± 1% +119.50% (p=0.000 n=20) For #61716. Change-Id: Ibdddeed85c34d9ae397289dc899e04d4845f9ed2 Reviewed-on: https://go-review.googlesource.com/c/go/+/516860 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21sync: do not unnecessarily keep alive functions wrapped by ↵Carlo Alberto Ferraris
Once(Func|Value|Values) The function passed to OnceFunc/OnceValue/OnceValues may transitively keep more allocations alive. As the passed function is guaranteed to be called at most once, it is safe to drop it after the first call is complete. This avoids keeping the passed function (and anything it transitively references) alive until the returned function is GCed. Change-Id: I2faf397b481d2f693ab3aea8e2981b02adbc7a21 Reviewed-on: https://go-review.googlesource.com/c/go/+/481515 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: qiulaidongfeng <2645477756@qq.com>
2023-11-20src: a/an grammar fixesVille Skyttä
Change-Id: I179b50ae8e73677d4d408b83424afbbfe6aa17a1 GitHub-Last-Rev: 2e2d9c1e45556155d02db4df381b99f2d1bc5c0e GitHub-Pull-Request: golang/go#63478 Reviewed-on: https://go-review.googlesource.com/c/go/+/534015 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-11-17all: make more use of the new atomic integer typesDaniel Martí
Slightly simplifies the code and avoids human error. Change-Id: Ib76575e8bc5b3a699ba6cc3870d63cd7a55e6416 Reviewed-on: https://go-review.googlesource.com/c/go/+/541476 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-10-06sync: use atomic.Uint32 in Oncemstmdev
Change-Id: If9089f8afd78de3e62cd575f642ff96ab69e2099 GitHub-Last-Rev: 14165018d67e84685dcf84be0320623ccb3afc0e GitHub-Pull-Request: golang/go#63386 Reviewed-on: https://go-review.googlesource.com/c/go/+/532895 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2023-09-07sync: deemphasize goroutines in RWMutex documentationqiulaidongfeng
Fixes #41555 Change-Id: I46b9535b1687d481d2ac76296e8ba7de26d6e2e2 Change-Id: I46b9535b1687d481d2ac76296e8ba7de26d6e2e2 GitHub-Last-Rev: 38af46c18922eea80e05c8ed9f5e10002ab7244d GitHub-Pull-Request: golang/go#61977 Reviewed-on: https://go-review.googlesource.com/c/go/+/518859 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
2023-09-01sync: prevent (*Map).Range from always escapingMauri de Souza Meneguzzo
After the change from CL 426074 the Range method on Map always escape the read variable, leading to an allocation. Since the compiler doesn't do live-range splitting for local variables we need to use some hints to only escape in that particular branch. Fixes #62404 Change-Id: I938a5e593647455fa827e3dd3ed8ea22c7365df1 GitHub-Last-Rev: fcbedb467c7b4e6f1d49e299d243cad70deb34e9 GitHub-Pull-Request: golang/go#62408 Reviewed-on: https://go-review.googlesource.com/c/go/+/524976 Auto-Submit: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-16sync: document why copyChecker checks the condition twiceqiulaidongfeng
Fixes #40924 Change-Id: I249a278be1ec3c67088819af4456e6c393431724 Change-Id: I249a278be1ec3c67088819af4456e6c393431724 GitHub-Last-Rev: 772c7ae7e140ebd3896fc7786aae8b43ab3128c3 GitHub-Pull-Request: golang/go#61978 Reviewed-on: https://go-review.googlesource.com/c/go/+/518961 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com>
2023-07-31sync: panic rather than throw on nil *PoolIan Lance Taylor
Fixes #61651 Change-Id: I27d581719e6bf38910f9d47dcf023bbff74ddf72 Reviewed-on: https://go-review.googlesource.com/c/go/+/514037 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-05-23syscall: avoid serializing forks on ForkLockIan Lance Taylor
Fixes #23558 Fixes #54162 Change-Id: I3cf6efe466080cdb17e171218e9385ccb272c301 Reviewed-on: https://go-review.googlesource.com/c/go/+/421441 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-05-10all: fix a lot of commentscui fliter
Fix comments, including duplicate is, wrong phrases and articles, misspellings, etc. Change-Id: I8bfea53b9b275e649757cc4bee6a8a026ed9c7a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/493035 Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-03-31sync: implement OnceFunc, OnceValue, and OnceValuesAustin Clements
This adds the three functions from #56102 to the sync package. These provide a convenient API for the most common uses of sync.Once. The performance of these is comparable to direct use of sync.Once: $ go test -run ^$ -bench OnceFunc\|OnceVal -count 20 | benchstat -row .name -col /v goos: linux goarch: amd64 pkg: sync cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz │ Once │ Global │ Local │ │ sec/op │ sec/op vs base │ sec/op vs base │ OnceFunc 1.3500n ± 6% 2.7030n ± 1% +100.22% (p=0.000 n=20) 0.3935n ± 0% -70.86% (p=0.000 n=20) OnceValue 1.3155n ± 0% 2.7460n ± 1% +108.74% (p=0.000 n=20) 0.5478n ± 1% -58.35% (p=0.000 n=20) The "Once" column represents the baseline of how code would typically express these patterns using sync.Once. "Global" binds the closure returned by OnceFunc/OnceValue to global, which is how I expect these to be used most of the time. Currently, this defeats some inlining opportunities, which roughly doubles the cost over sync.Once; however, it's still *extremely* fast. Finally, "Local" binds the returned closure to a local variable. This unlocks several levels of inlining and represents pretty much the best possible case for these APIs, but is also unlikely to happen in practice. In principle the compiler could recognize that the global in the "Global" case is initialized in place and never mutated and do the same optimizations it does in the "Local" case, but it currently does not. Fixes #56102 Change-Id: If7355eccd7c8de7288d89a4282ff15ab1469e420 Reviewed-on: https://go-review.googlesource.com/c/go/+/451356 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Caleb Spare <cespare@gmail.com> Auto-Submit: Austin Clements <austin@google.com>
2023-03-25all: add a few links in package godocsDaniel Martí
I noticed the one in path/filepath while reading the docs, and the other ones were found via some quick grepping. Change-Id: I386f2f74ef816a6d18aa2f58ee6b64dbd0147c9e Reviewed-on: https://go-review.googlesource.com/c/go/+/478795 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-22sync: fix TestCondSignalStealing flakeCollin Wright
Fixes: #59043 Change-Id: I8215948a772566641dab1079a9837128450deb1b GitHub-Last-Rev: 0fa6f08a70658e1272da0c82812de752350d394d GitHub-Pull-Request: golang/go#59160 Reviewed-on: https://go-review.googlesource.com/c/go/+/477955 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2023-02-09runtime: fix signature for linked functionsAdin Scannell
These functions are linked using go:linkname, but do not match the original declarations. This change brings these in sync. Change-Id: I16651304c3dba2f9897c2c42e30555d2f7805c2a Reviewed-on: https://go-review.googlesource.com/c/go/+/466615 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com>
2023-01-20sync: document memory model for Swap/CompareAnd{Swap,Delete} in MapChangkun Ou
CL 381316 documented the memory model of Map's APIs. However, the newly introduced Swap, CompareAndSwap, and CompareAndDelete are missing from this documentation as CL 399094 did not add this info. This CL specifies the defined read/write operations of the new Map APIs. For #51972 Change-Id: I519a04040a0b429a3f978823a183cd62e42c90ae Reviewed-on: https://go-review.googlesource.com/c/go/+/459715 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Changkun Ou <mail@changkun.de> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-09sync/atomic: fix the note of atomic.Storecsuzhang
Change-Id: Id485d0f1e06febe97d1a770bc26c138d9613a7dd GitHub-Last-Rev: e57dd3e1abb58031b3d8bec8beace1560faad397 GitHub-Pull-Request: golang/go#57679 Reviewed-on: https://go-review.googlesource.com/c/go/+/461076 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org>
2022-12-12sync: remove unused constChangkun Ou
Change-Id: I4382b5317cf7f39a48005516ff6d437883c6fd07 Reviewed-on: https://go-review.googlesource.com/c/go/+/456495 Reviewed-by: Dominik Honnef <dominik@honnef.co> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Changkun Ou <mail@changkun.de>
2022-11-17sync/atomic: hint users of old API to use new type-based API insteadKeith Randall
Fixes #56495 Change-Id: Ib2f39273da68e3056688306aa0d5e274b5507bf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/449237 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-15sync/atomic: allow linked list of atomic pointers againRuss Cox
For #56603, CL 448275 added a _ [0]T field to atomic.Pointer, so that different kinds of atomic.Pointer are not convertible. Unfortunately, that breaks code like: type List struct { Next atomic.Pointer[List] } which should be valid, just as using Next *List is valid. Instead, we get: ./atomic_test.go:2533:6: invalid recursive type List ./atomic_test.go:2533:6: List refers to ./atomic_test.go:2534:13: "sync/atomic".Pointer refers to ./atomic_test.go:2533:6: List Fix by using _[0]*T instead. Change-Id: Icc4c83c691d35961d20cb14b824223d6c779ac5e Reviewed-on: https://go-review.googlesource.com/c/go/+/450655 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-11-15sync: add new Map method Swap, CompareAndSwap, CompareAndDeleteChangkun Ou
name time/op SwapCollision/*sync_test.DeepCopyMap-8 235ns ± 0% SwapCollision/*sync_test.RWMutexMap-8 145ns ± 0% SwapCollision/*sync.Map-8 153ns ± 0% SwapMostlyHits/*sync_test.DeepCopyMap-8 48.2µs ± 0% SwapMostlyHits/*sync_test.RWMutexMap-8 190ns ± 0% SwapMostlyHits/*sync.Map-8 28.3ns ± 0% SwapMostlyMisses/*sync_test.DeepCopyMap-8 681ns ± 0% SwapMostlyMisses/*sync_test.RWMutexMap-8 336ns ± 0% SwapMostlyMisses/*sync.Map-8 523ns ± 0% CompareAndSwapCollision/*sync_test.DeepCopyMap-8 3.99ns ± 0% CompareAndSwapCollision/*sync_test.RWMutexMap-8 151ns ± 0% CompareAndSwapCollision/*sync.Map-8 21.6ns ± 0% CompareAndSwapNoExistingKey/*sync_test.DeepCopyMap-8 3.95ns ± 0% CompareAndSwapNoExistingKey/*sync_test.RWMutexMap-8 126ns ± 0% CompareAndSwapNoExistingKey/*sync.Map-8 6.11ns ± 0% CompareAndSwapValueNotEqual/*sync_test.DeepCopyMap-8 2.15ns ± 0% CompareAndSwapValueNotEqual/*sync_test.RWMutexMap-8 132ns ± 0% CompareAndSwapValueNotEqual/*sync.Map-8 5.32ns ± 0% CompareAndSwapMostlyHits/*sync_test.RWMutexMap-8 219ns ± 0% CompareAndSwapMostlyHits/*sync.Map-8 27.1ns ± 0% CompareAndSwapMostlyMisses/*sync_test.DeepCopyMap-8 13.0ns ± 0% CompareAndSwapMostlyMisses/*sync_test.RWMutexMap-8 147ns ± 0% CompareAndSwapMostlyMisses/*sync.Map-8 19.6ns ± 0% CompareAndDeleteCollision/*sync_test.DeepCopyMap-8 2.23ns ± 0% CompareAndDeleteCollision/*sync_test.RWMutexMap-8 131ns ± 0% CompareAndDeleteCollision/*sync.Map-8 16.2ns ± 0% CompareAndDeleteMostlyHits/*sync_test.RWMutexMap-8 367ns ± 0% CompareAndDeleteMostlyHits/*sync.Map-8 33.1ns ± 0% CompareAndDeleteMostlyMisses/*sync_test.DeepCopyMap-8 8.75ns ± 0% CompareAndDeleteMostlyMisses/*sync_test.RWMutexMap-8 134ns ± 0% CompareAndDeleteMostlyMisses/*sync.Map-8 10.9ns ± 0% name alloc/op SwapCollision/*sync_test.DeepCopyMap-8 336B ± 0% SwapCollision/*sync_test.RWMutexMap-8 0.00B SwapCollision/*sync.Map-8 16.0B ± 0% SwapMostlyHits/*sync_test.DeepCopyMap-8 82.1kB ± 0% SwapMostlyHits/*sync_test.RWMutexMap-8 12.0B ± 0% SwapMostlyHits/*sync.Map-8 28.0B ± 0% SwapMostlyMisses/*sync_test.DeepCopyMap-8 713B ± 0% SwapMostlyMisses/*sync_test.RWMutexMap-8 23.0B ± 0% SwapMostlyMisses/*sync.Map-8 129B ± 0% CompareAndSwapCollision/*sync_test.DeepCopyMap-8 0.00B CompareAndSwapCollision/*sync_test.RWMutexMap-8 0.00B CompareAndSwapCollision/*sync.Map-8 3.00B ± 0% CompareAndSwapNoExistingKey/*sync_test.DeepCopyMap-8 8.00B ± 0% CompareAndSwapNoExistingKey/*sync_test.RWMutexMap-8 8.00B ± 0% CompareAndSwapNoExistingKey/*sync.Map-8 8.00B ± 0% CompareAndSwapValueNotEqual/*sync_test.DeepCopyMap-8 0.00B CompareAndSwapValueNotEqual/*sync_test.RWMutexMap-8 0.00B CompareAndSwapValueNotEqual/*sync.Map-8 0.00B CompareAndSwapMostlyHits/*sync_test.RWMutexMap-8 18.0B ± 0% CompareAndSwapMostlyHits/*sync.Map-8 33.0B ± 0% CompareAndSwapMostlyMisses/*sync_test.DeepCopyMap-8 24.0B ± 0% CompareAndSwapMostlyMisses/*sync_test.RWMutexMap-8 23.0B ± 0% CompareAndSwapMostlyMisses/*sync.Map-8 23.0B ± 0% CompareAndDeleteCollision/*sync_test.DeepCopyMap-8 0.00B CompareAndDeleteCollision/*sync_test.RWMutexMap-8 0.00B CompareAndDeleteCollision/*sync.Map-8 0.00B CompareAndDeleteMostlyHits/*sync_test.RWMutexMap-8 23.0B ± 0% CompareAndDeleteMostlyHits/*sync.Map-8 39.0B ± 0% CompareAndDeleteMostlyMisses/*sync_test.DeepCopyMap-8 16.0B ± 0% CompareAndDeleteMostlyMisses/*sync_test.RWMutexMap-8 15.0B ± 0% CompareAndDeleteMostlyMisses/*sync.Map-8 15.0B ± 0% name allocs/op SwapCollision/*sync_test.DeepCopyMap-8 2.00 ± 0% SwapCollision/*sync_test.RWMutexMap-8 0.00 SwapCollision/*sync.Map-8 1.00 ± 0% SwapMostlyHits/*sync_test.DeepCopyMap-8 4.00 ± 0% SwapMostlyHits/*sync_test.RWMutexMap-8 1.00 ± 0% SwapMostlyHits/*sync.Map-8 2.00 ± 0% SwapMostlyMisses/*sync_test.DeepCopyMap-8 6.00 ± 0% SwapMostlyMisses/*sync_test.RWMutexMap-8 2.00 ± 0% SwapMostlyMisses/*sync.Map-8 6.00 ± 0% CompareAndSwapCollision/*sync_test.DeepCopyMap-8 0.00 CompareAndSwapCollision/*sync_test.RWMutexMap-8 0.00 CompareAndSwapCollision/*sync.Map-8 0.00 CompareAndSwapNoExistingKey/*sync_test.DeepCopyMap-8 1.00 ± 0% CompareAndSwapNoExistingKey/*sync_test.RWMutexMap-8 0.00 CompareAndSwapNoExistingKey/*sync.Map-8 1.00 ± 0% CompareAndSwapValueNotEqual/*sync_test.DeepCopyMap-8 0.00 CompareAndSwapValueNotEqual/*sync_test.RWMutexMap-8 0.00 CompareAndSwapValueNotEqual/*sync.Map-8 0.00 CompareAndSwapMostlyHits/*sync_test.RWMutexMap-8 2.00 ± 0% CompareAndSwapMostlyHits/*sync.Map-8 3.00 ± 0% CompareAndSwapMostlyMisses/*sync_test.DeepCopyMap-8 2.00 ± 0% CompareAndSwapMostlyMisses/*sync_test.RWMutexMap-8 2.00 ± 0% CompareAndSwapMostlyMisses/*sync.Map-8 2.00 ± 0% CompareAndDeleteCollision/*sync_test.DeepCopyMap-8 0.00 CompareAndDeleteCollision/*sync_test.RWMutexMap-8 0.00 CompareAndDeleteCollision/*sync.Map-8 0.00 CompareAndDeleteMostlyHits/*sync_test.RWMutexMap-8 2.00 ± 0% CompareAndDeleteMostlyHits/*sync.Map-8 3.00 ± 0% CompareAndDeleteMostlyMisses/*sync_test.DeepCopyMap-8 2.00 ± 0% CompareAndDeleteMostlyMisses/*sync_test.RWMutexMap-8 1.00 ± 0% CompareAndDeleteMostlyMisses/*sync.Map-8 1.00 ± 0% Fixes #51972 Change-Id: I469e71033592997832c3e8ebdad1b8950a70c99c Reviewed-on: https://go-review.googlesource.com/c/go/+/399094 Run-TryBot: Changkun Ou <mail@changkun.de> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-07sync/atomic: disallow type conversions of atomic.Pointer[T]Mateusz Poliwczak
Fixes #56603 Change-Id: I6af9d80201025ae4028bfaa4a62e5de9ac0c501d GitHub-Last-Rev: e6ed5e14512e1221a3c6cb181406cf00eec07e99 GitHub-Pull-Request: golang/go#56604 Reviewed-on: https://go-review.googlesource.com/c/go/+/448275 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-31sync: use atomic.Pointer for entryChangkun Ou
Change-Id: Ie3b4bfe483d7ef43da29ea1dd73d423dac36cf39 Reviewed-on: https://go-review.googlesource.com/c/go/+/432055 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Changkun Ou <mail@changkun.de>
2022-09-29sync/atomic: rename "ifaceWords" to "efaceWords"hopehook
Rename "ifaceWords" to "efaceWords", since we are defining an empty interface. Change-Id: I7151fb730a081a800e6dd28bcba831787ee9d6a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/432815 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-26sync: clarify Cond.Wait documentationIsaiah Becker-Mayer
The previous wording was unclear and seemingly contradictory. Change-Id: I0781dc4525948f4e8e5698271362a82387688f81 GitHub-Last-Rev: c1e032fa9451dd50a69cf572cd80dcdbe6591d2e GitHub-Pull-Request: golang/go#53516 Reviewed-on: https://go-review.googlesource.com/c/go/+/413774 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-19cmd/compile,sync: make accessing address of zero offset struct field inline ↵Cuong Manh Le
cost 0 Accessing the address of something often needs the same (or even less) number of instructions as accessing the content of the thing. That would help us rolling back the hack of CL 429766 to lower sync atomic types inline cost. Compiled objects size increase a bit: file before after Δ % addr2line 3729827 3733958 +4131 +0.111% api 5457224 5456267 -957 -0.018% asm 4806486 4808993 +2507 +0.052% buildid 2480271 2480562 +291 +0.012% cgo 4593496 4593947 +451 +0.010% compile 23906958 23910086 +3128 +0.013% cover 4680870 4681461 +591 +0.013% dist 3341333 3341692 +359 +0.011% doc 3879927 3880409 +482 +0.012% fix 3298081 3298979 +898 +0.027% link 6500098 6499873 -225 -0.003% nm 3654362 3656997 +2635 +0.072% objdump 4108300 4108671 +371 +0.009% pack 2255445 2256391 +946 +0.042% pprof 14364561 14379475 +14914 +0.104% test2json 2550942 2555333 +4391 +0.172% trace 13573199 13578409 +5210 +0.038% vet 7430923 7430094 -829 -0.011% total 114612303 114651597 +39294 +0.034% file before after Δ % archive/tar.a 905032 905560 +528 +0.058% archive/zip.a 853464 853916 +452 +0.053% cmd/asm/internal/lex.a 359388 367418 +8030 +2.234% cmd/compile/internal/importer.a 947206 947734 +528 +0.056% cmd/compile/internal/inline.a 563390 566828 +3438 +0.610% cmd/compile/internal/types2.a 5761990 5764274 +2284 +0.040% cmd/go/internal/cfg.a 234892 235342 +450 +0.192% cmd/go/internal/envcmd.a 257166 257694 +528 +0.205% cmd/go/internal/fix.a 93522 94052 +530 +0.567% cmd/go/internal/generate.a 201308 201838 +530 +0.263% cmd/go/internal/get.a 207862 208390 +528 +0.254% cmd/go/internal/imports.a 230266 230794 +528 +0.229% cmd/go/internal/list.a 385044 386632 +1588 +0.412% cmd/go/internal/load.a 1164508 1165566 +1058 +0.091% cmd/go/internal/modcmd.a 627582 629168 +1586 +0.253% cmd/go/internal/modfetch/codehost.a 1031962 1032490 +528 +0.051% cmd/go/internal/modfetch.a 1289294 1289822 +528 +0.041% cmd/go/internal/modget.a 674566 675624 +1058 +0.157% cmd/go/internal/modindex.a 935598 936576 +978 +0.105% cmd/go/internal/modload.a 2640784 2642058 +1274 +0.048% cmd/go/internal/par.a 135858 136476 +618 +0.455% cmd/go/internal/run.a 127158 127688 +530 +0.417% cmd/go/internal/search.a 242918 243446 +528 +0.217% cmd/go/internal/trace.a 113216 113188 -28 -0.025% cmd/go/internal/vcs.a 517280 517810 +530 +0.102% cmd/go/internal/work.a 2389522 2390580 +1058 +0.044% cmd/go/internal/workcmd.a 311118 311452 +334 +0.107% cmd/vendor/github.com/google/pprof/internal/driver.a 1714950 1715478 +528 +0.031% cmd/vendor/golang.org/x/mod/sumdb.a 453840 454290 +450 +0.099% cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags.a 326162 326610 +448 +0.137% cmd/vendor/golang.org/x/tools/go/analysis/internal/facts.a 302476 303006 +530 +0.175% cmd/vendor/golang.org/x/tools/go/analysis/passes/asmdecl.a 366580 367030 +450 +0.123% cmd/vendor/golang.org/x/tools/go/analysis/passes/assign.a 129556 130006 +450 +0.347% cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic.a 133466 133916 +450 +0.337% cmd/vendor/golang.org/x/tools/go/analysis/passes/bools.a 193558 194006 +448 +0.231% cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag.a 177984 178434 +450 +0.253% cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall.a 221226 221674 +448 +0.203% cmd/vendor/golang.org/x/tools/go/analysis/passes/composite.a 168572 169022 +450 +0.267% cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock.a 227040 227490 +450 +0.198% cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow.a 204650 205098 +448 +0.219% cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas.a 138020 138468 +448 +0.325% cmd/vendor/golang.org/x/tools/go/analysis/passes/framepointer.a 119030 119480 +450 +0.378% cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse.a 165006 165454 +448 +0.272% cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert.a 180850 181300 +450 +0.249% cmd/vendor/golang.org/x/tools/go/analysis/passes/inspect.a 103876 104326 +450 +0.433% cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil.a 116070 116516 +446 +0.384% cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure.a 153068 153518 +450 +0.294% cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel.a 244936 245384 +448 +0.183% cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc.a 135720 136168 +448 +0.330% cmd/vendor/golang.org/x/tools/go/analysis/passes/printf.a 527134 527584 +450 +0.085% cmd/vendor/golang.org/x/tools/go/analysis/passes/shift.a 172026 172476 +450 +0.262% cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer.a 151690 152138 +448 +0.295% cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods.a 187494 187944 +450 +0.240% cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv.a 164752 165200 +448 +0.272% cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag.a 200144 200594 +450 +0.225% cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine.a 161146 161596 +450 +0.279% cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.a 270252 270702 +450 +0.167% cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal.a 130646 131094 +448 +0.343% cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable.a 182130 182580 +450 +0.247% cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr.a 153646 154094 +448 +0.292% cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult.a 179800 180248 +448 +0.249% cmd/vendor/golang.org/x/tools/go/analysis/unitchecker.a 303838 304286 +448 +0.147% cmd/vendor/golang.org/x/tools/go/analysis.a 217930 218380 +450 +0.206% cmd/vendor/golang.org/x/tools/go/ast/astutil.a 539428 539874 +446 +0.083% cmd/vendor/golang.org/x/tools/go/cfg.a 286820 287270 +450 +0.157% cmd/vendor/golang.org/x/tools/go/types/objectpath.a 236144 236674 +530 +0.224% cmd/vendor/golang.org/x/tools/go/types/typeutil.a 412728 413176 +448 +0.109% cmd/vendor/golang.org/x/tools/internal/analysisinternal.a 223256 223704 +448 +0.201% cmd/vendor/golang.org/x/tools/internal/typeparams.a 419498 419946 +448 +0.107% context.a 210000 209972 -28 -0.013% crypto/internal/boring/bcache.a 8652 8568 -84 -0.971% crypto/tls.a 3295282 3295202 -80 -0.002% database/sql.a 1365892 1365762 -130 -0.010% encoding/base64.a 131572 136228 +4656 +3.539% encoding/binary.a 452546 453076 +530 +0.117% encoding/gob.a 1690728 1691672 +944 +0.056% encoding/json.a 1198834 1199276 +442 +0.037% encoding/xml.a 1035784 1036314 +530 +0.051% expvar.a 285282 285678 +396 +0.139% go/ast.a 1175212 1175662 +450 +0.038% go/build.a 657802 658252 +450 +0.068% go/doc.a 808002 808452 +450 +0.056% go/format.a 101378 101824 +446 +0.440% go/importer.a 101816 102266 +450 +0.442% go/internal/gccgoimporter.a 593828 594358 +530 +0.089% go/internal/gcimporter.a 974178 974626 +448 +0.046% go/internal/srcimporter.a 196600 197050 +450 +0.229% go/parser.a 1152502 1152946 +444 +0.039% go/printer.a 910744 911194 +450 +0.049% go/token.a 299624 299768 +144 +0.048% go/types.a 5763222 5766118 +2896 +0.050% hash/crc32.a 128130 128098 -32 -0.025% internal/fuzz.a 1058644 1059174 +530 +0.050% internal/poll.a 660412 660382 -30 -0.005% internal/testenv.a 212792 213320 +528 +0.248% log/syslog.a 128718 128654 -64 -0.050% log.a 157330 157274 -56 -0.036% mime.a 383058 383588 +530 +0.138% net/http/httptest.a 430550 431000 +450 +0.105% net/http/pprof.a 306918 307448 +530 +0.173% net/http.a 7413852 7414074 +222 +0.003% net/internal/socktest.a 258934 258900 -34 -0.013% net/rpc/jsonrpc.a 173158 172962 -196 -0.113% net/rpc.a 634464 634914 +450 +0.071% net.a 3539574 3541348 +1774 +0.050% os.a 891416 891390 -26 -0.003% reflect.a 3956224 3956666 +442 +0.011% runtime/cgo.a 187406 187852 +446 +0.238% runtime/trace.a 85720 85616 -104 -0.121% runtime.a 9357520 9371302 +13782 +0.147% sync/atomic.a 232512 232376 -136 -0.058% sync.a 353112 355068 +1956 +0.554% syscall.a 1660308 1660222 -86 -0.005% testing.a 1399348 1399198 -150 -0.011% text/template.a 1384750 1384726 -24 -0.002% total 265209524 265294628 +85104 +0.032% Change-Id: I21114dcddeb4fc2c56e781ea2f6e732fe3da2b01 Reviewed-on: https://go-review.googlesource.com/c/go/+/431095 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-16runtime: make the wait reason for a g blocked on a mutex more specificMichael Anthony Knyszek
This change adds 3 new waitReasons that correspond to sync.Mutex.Lock, sync.RWMutex.RLock, and sync.RWMutex.Lock that are plumbed down into semacquire1 by exporting new functions to the sync package from the runtime. Currently these three functions show up as "semacquire" in backtraces which isn't very clear, though the stack trace itself should reveal what's really going on. This represents a minor improvement to backtrace readability, though blocking on an RWMutex.w.Lock will still show up as blocking on a regular mutex (I suppose technically it is). This is a step toward helping the runtime identify when a goroutine is blocked on a mutex of some kind. For #49881. Change-Id: Ia409b4d27e117fe4bfdc25fa541e9c58d6d587b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/427616 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com>
2022-09-09sync: convert RWMutex.{readerCount,readerWait} to atomic typeCuong Manh Le
Change-Id: I7fd9c0636cd00891f5cdf36c0f68f897772042f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/429767 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-09sync/atomic: reduce inlining cost for atomic types methodsCuong Manh Le
The "&x.v" cost us 2 inline cost budget, causing extra inline cost for the caller. By taking the fact that "v" is laid out in memory as the first field of all atomic types, we can accessing it without addressing. Discovering why attempting to convert sync.RWMutex.readerCount to atomic type. RWMutex.RUnlock have the inline cost 75, with extra 7 inline cost from Int32.Add causing it not inlinable anymore. With this change, Int32.Add only has 5 inline cost budget, RWMutex can use it while still be inlinable. Change-Id: Iabe1d1bf53389b0b8b5f56b4611231b732fd9df5 Reviewed-on: https://go-review.googlesource.com/c/go/+/429766 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-07Revert "sync: convert Once.done to atomic type"Ian Lance Taylor
This reverts commit CL 427140. Reason for revert: Comments say that done should be the first field. Change-Id: Id131da064146b44e1182289546aeb877867e63cc Reviewed-on: https://go-review.googlesource.com/c/go/+/428638 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-06all: make sure *Pointer[T]'s methods are inlined as intendedCuong Manh Le
Updates #50860 Change-Id: I65bced707e50364b16edf4b087c541cf19bb1778 Reviewed-on: https://go-review.googlesource.com/c/go/+/428362 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-06sync: convert Once.done to atomic typecuiweixie
Change-Id: I49f8c764d49cabaad4d6859c219ba7220a389c1f Reviewed-on: https://go-review.googlesource.com/c/go/+/427140 Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-29sync: switch Map to use atomic.PointerJoe Tsai
There was no noticeable change in performance. Change-Id: I9c57bf836c8b6066e0620afb3d536ce99e4b9d87 Reviewed-on: https://go-review.googlesource.com/c/go/+/426074 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-19sync: use atomic.Uint64 for WaitGroup stateCuong Manh Le
So it's guaranteed to have 64-bit alignment, simplify the code without losing any performance: name old time/op new time/op delta WaitGroupUncontended-8 3.84ns ± 2% 3.82ns ± 1% ~ (p=0.159 n=10+10) WaitGroupAddDone-8 33.2ns ± 3% 33.0ns ± 3% ~ (p=0.564 n=9+10) WaitGroupAddDoneWork-8 39.3ns ± 1% 39.3ns ± 1% ~ (p=1.000 n=8+9) WaitGroupWait-8 0.70ns ± 3% 0.70ns ± 2% ~ (p=0.720 n=9+10) WaitGroupWaitWork-8 7.93ns ± 1% 7.99ns ± 3% ~ (p=0.271 n=10+10) WaitGroupActuallyWait-8 135ns ± 2% 135ns ± 1% ~ (p=0.897 n=10+10) Change-Id: I446b53fa92873419aadd592f45e51398f8ad8652 Reviewed-on: https://go-review.googlesource.com/c/go/+/424835 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-08-05sync/atomic: remove test64err in testRuss Cox
This check was for very old QEMU, added in 2011 in https://codereview.appspot.com/4313051/. It may be safe to delete now. Let's find out. In a separate CL for easy rollback. Change-Id: Ic99f8cf27ee348b8ffb1ef0ee36cc1c537dde722 Reviewed-on: https://go-review.googlesource.com/c/go/+/403978 Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-17sync: add more notes about Cond behaviorKevin Burke
Cond is difficult to use correctly (I was just bitten by it in a production app that I inherited). While several proposals have come up to improve or remove sync.Cond, no action has so far been taken. Update the documentation to discourage use of sync.Cond, and point people in the direction of preferred alternatives. I believe this will help encourage behavior we want (less use of sync.Cond and more use of channels), while also paving the way for, potentially, removing Cond in a future version of the language. Thanks very much to Bryan Mills and Sean Liao for discussion and recommendations. Updates #20491. Updates #21165. Change-Id: Ib4d0631c79d4c4d0a30027255cd43bc47cddebd3 Reviewed-on: https://go-review.googlesource.com/c/go/+/412237 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>