aboutsummaryrefslogtreecommitdiff
path: root/src/hash
AgeCommit message (Collapse)Author
6 daysall: make function comments match function namescuishuang
Change-Id: Ideb9ef00e7bc660b005fc080973fd9f3d36c5a1f Reviewed-on: https://go-review.googlesource.com/c/go/+/589536 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-18hash: use more internal/byteorder functions to simplify the codeapocelipes
A follow-up for the CL 585015. Change-Id: I412f33f1d75abe1446cb3fd742d44d3cb4350380 GitHub-Last-Rev: 554ace757cc75389e7a3c441d3a60cfa85c815a5 GitHub-Pull-Request: golang/go#67476 Reviewed-on: https://go-review.googlesource.com/c/go/+/586240 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-05-12hash: use internal/byteorderMateusz Poliwczak
Change-Id: I58c24a58a7b32d3f8d544509db04baac1ea1b56e GitHub-Last-Rev: 7a648fda00ad30aa00d72013d9c6e22e207c31b2 GitHub-Pull-Request: golang/go#67318 Reviewed-on: https://go-review.googlesource.com/c/go/+/585015 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> 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> Reviewed-by: Keith Randall <khr@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-05-06 hash/crc32: improve asm for ppc64SlicingUpdateBy8Jayanth Krishnamurthy
Improvements are made in the assembler code which improves time and space by 9-10%. 1. ANDCC, followed by SLD is combined and replaced by CLRLSLDI. 2. MOVWZ can use an indexed load and eliminate an ADD instruction in some cases. Example: ADD R7,R10,R7 followed by MOVWZ 0(R7),R5 can be replaced with just MOVWZ (R7)(R10),R5. 3. Optimizations for the block after the "short" label includes the same MOVWZ use of indexed load, as well as other improvements. The gain from code changes can be seen as follows, generated by benchstat: goos: linux goarch: ppc64le pkg: hash/crc32 cpu: POWER10 | oldCrc.out | newCrc.out | | sec/op | sec/op vs base | CRC32/poly=IEEE/size=15/align=0-12 50.19n ± 1% 39.85n ± 0% -20.59% (p=0.002 n=6) CRC32/poly=IEEE/size=15/align=1-12 50.18n ± 1% 39.87n ± 0% -20.54% (p=0.002 n=6) CRC32/poly=IEEE/size=40/align=0-12 40.25n ± 0% 36.95n ± 0% -8.19% (p=0.002 n=6) CRC32/poly=IEEE/size=40/align=1-12 40.31n ± 0% 36.95n ± 0% -8.36% (p=0.002 n=6) CRC32/poly=IEEE/size=512/align=0-12 38.03n ± 0% 38.17n ± 0% +0.37% (p=0.002 n=6) CRC32/poly=IEEE/size=512/align=1-12 89.19n ± 1% 73.65n ± 0% -17.43% (p=0.002 n=6) CRC32/poly=IEEE/size=1kB/align=0-12 50.73n ± 7% 50.14n ± 0% -1.18% (p=0.002 n=6) CRC32/poly=IEEE/size=1kB/align=1-12 101.00n ± 37% 81.58n ± 0% -19.23% (p=0.002 n=6) CRC32/poly=IEEE/size=4kB/align=0-12 98.30n ± 45% 93.05n ± 0% -5.34% (p=0.043 n=6) CRC32/poly=IEEE/size=4kB/align=1-12 140.8n ± 0% 125.8n ± 0% -10.65% (p=0.002 n=6) CRC32/poly=IEEE/size=32kB/align=0-12 525.8n ± 0% 528.5n ± 0% +0.52% (p=0.011 n=6) CRC32/poly=IEEE/size=32kB/align=1-12 584.4n ± 1% 576.3n ± 0% -1.39% (p=0.002 n=6) geomean 90.51n 81.74n -9.69% | oldCrc.out | newCrc.out | | B/s | B/s vs base | CRC32/poly=IEEE/size=15/align=0-12 285.0Mi ± 1% 359.0Mi ± 0% +25.94% (p=0.002 n=6) CRC32/poly=IEEE/size=15/align=1-12 285.1Mi ± 1% 358.8Mi ± 0% +25.86% (p=0.002 n=6) CRC32/poly=IEEE/size=40/align=0-12 947.8Mi ± 0% 1032.3Mi ± 0% +8.91% (p=0.002 n=6) CRC32/poly=IEEE/size=40/align=1-12 946.2Mi ± 0% 1032.5Mi ± 0% +9.12% (p=0.002 n=6) CRC32/poly=IEEE/size=512/align=0-12 12.54Gi ± 0% 12.49Gi ± 0% -0.37% (p=0.002 n=6) CRC32/poly=IEEE/size=512/align=1-12 5.346Gi ± 1% 6.475Gi ± 0% +21.12% (p=0.002 n=6) CRC32/poly=IEEE/size=1kB/align=0-12 18.80Gi ± 7% 19.02Gi ± 0% +1.20% (p=0.002 n=6) CRC32/poly=IEEE/size=1kB/align=1-12 9.454Gi ± 27% 11.690Gi ± 0% +23.66% (p=0.002 n=6) CRC32/poly=IEEE/size=4kB/align=0-12 38.86Gi ± 31% 41.00Gi ± 0% +5.49% (p=0.041 n=6) CRC32/poly=IEEE/size=4kB/align=1-12 27.10Gi ± 0% 30.32Gi ± 0% +11.89% (p=0.002 n=6) CRC32/poly=IEEE/size=32kB/align=0-12 58.05Gi ± 0% 57.74Gi ± 0% -0.53% (p=0.009 n=6) CRC32/poly=IEEE/size=32kB/align=1-12 52.22Gi ± 1% 52.95Gi ± 0% +1.41% (p=0.002 n=6) geomean 6.074Gi 6.724Gi +10.70% Change-Id: I378c0e84e798656384a8009f4ac48b51614489b2 Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10 Reviewed-on: https://go-review.googlesource.com/c/go/+/582395 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Eli Bendersky <eliben@google.com>
2024-05-03hash/maphash: parallel run testqiulaidongfeng
This is a reapplication of CL 564576. This reduces the go test hash/maphash time by more than half. After investigation it was confirmed that the original CL would cause OOM when 32-bit machine. This CL add testenv.ParallelOn64Bit for tests that can be parallel on 64-bit machines, it is not parallel on 32-bit machines, because CL 564995 require the same API. Change-Id: I1b7feaa07716cb3f55db4671653348fabf2396b0 GitHub-Last-Rev: 28277255587f6a1b92b9bf1848e1f53adaca64dc GitHub-Pull-Request: golang/go#66359 Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/572195 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-27all: make use of builtin clearJes Cok
Change-Id: I1df0685c75fc1044ba46003a69ecc7dfc53bbc2b Reviewed-on: https://go-review.googlesource.com/c/go/+/574675 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-26runtime,hash/maphash: reuse hashSets to save memory pressureKeith Randall
Might help with OOMs on 32-bit platforms Change-Id: Idd5129c61ecdfeedd5a9a18fce85dbba27cab946 Reviewed-on: https://go-review.googlesource.com/c/go/+/574475 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-26runtime,hash/maphash: make tests use less memoryKeith Randall
Use a list + sorting instead of a map to keep track of collisions. Should save a fair amount of memory. Change-Id: I7b48cdb5f7060d12ebbb950d56b5c479f131c027 Reviewed-on: https://go-review.googlesource.com/c/go/+/574275 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Keith Randall <khr@google.com>
2024-02-20Revert "hash/maphash: parallel run test"Michael Pratt
This reverts CL 564576. Reason for revert: flaky on linux-386-longtest Fixes #65823. Change-Id: I20e11f15af050eae9a6c15e756a52ffad327c458 Reviewed-on: https://go-review.googlesource.com/c/go/+/565536 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-02-20hash/maphash: parallel run testqiulaidongfeng
This reduces the go test hash/maphash time by more than half. Change-Id: If184ca99544809c86b4c1baeb45d3afede91b41a GitHub-Last-Rev: 440c35f8b544a16cc733e3291f963f738dd59a47 GitHub-Pull-Request: golang/go#65739 Reviewed-on: https://go-review.googlesource.com/c/go/+/564576 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2024-02-19hash/crc32: fix code generator to use the Go standardOlivier Mengué
Apply the Go standard for code generation (https://go.dev/s/generatedcode) to generated crc32_table_ppc64le.s despites this is not generated Go but Assembly. This is to help prevent changes like CL 478976 that changed the generated output without fixing the generator. Add gen.go to allow to launch code generation with "go generate". Change-Id: I8671284265425826c8620dbec055519b992fa04e Reviewed-on: https://go-review.googlesource.com/c/go/+/556335 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-01-23hash/crc32: fix codegen to align with manual changesOlivier Mengué
Update gen_const_ppc64le.go to match the manual changes applied in CL 478976. Change-Id: I79a0d014a2a151750f898517b2771b312f3437bc Reviewed-on: https://go-review.googlesource.com/c/go/+/555996 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2023-12-14all: remove newline characters after return statementsDanil Timerbulatov
This commit is aimed at improving the readability and consistency of the code base. Extraneous newline characters were present after some return statements, creating unnecessary separation in the code. Fixes #64610 Change-Id: Ic1b05bf11761c4dff22691c2f1c3755f66d341f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/548316 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: 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-19hash: simplify binary operationsapocelipes
We can not use encoding/binary in hash packages because of import cycles. So just keep the appendUint and readUint helper functions same as that in the encoding/binary standard package. There is no notable performance impacts. Updates #63719 Change-Id: If47a7faaf9d422d772f32bbe1fa2f2c8a16485f4 GitHub-Last-Rev: f334fee408eff6869a7cc5f306df525d4d55d2cf GitHub-Pull-Request: golang/go#63746 Reviewed-on: https://go-review.googlesource.com/c/go/+/537796 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2023-10-31hash/maphash: weaken avalanche test a bit moreCuong Manh Le
CL 495415 weaken avalanche, making allowed range from 43% to 57%. Since then, we only see a failure with 58% on linux-386-longtest builder, so let give the test a bit more wiggle room: 40% to 59%. Fixes #60170 Change-Id: I9528ebc8601975b733c3d9fd464ce41429654273 Reviewed-on: https://go-review.googlesource.com/c/go/+/538655 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-10-13hash: add available godoc linkcui fliter
Change-Id: Ieb43f28400e9ded3dc7e57f27f6d7514b14cc66d Reviewed-on: https://go-review.googlesource.com/c/go/+/535083 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-14all: fix spelling errorsAlexander Yastrebov
Fix spelling errors discovered using https://github.com/codespell-project/codespell. Errors in data files and vendored packages are ignored. Change-Id: I83c7818222f2eea69afbd270c15b7897678131dc GitHub-Last-Rev: 3491615b1b82832cc0064f535786546e89aa6184 GitHub-Pull-Request: golang/go#60758 Reviewed-on: https://go-review.googlesource.com/c/go/+/502576 Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-05-17hash/maphash: weaken avalanche test a bitKeith Randall
Give the test a bit more wiggle room. Previously the allowed range was about 46.5% to 53.5%. Now it is about 43% TO 57%. Fixes #60170 Change-Id: Ieda471e0986c52edb9f6d31beb8e41917876d6c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/495415 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2023-03-23all: replace leading spaces with tabs in assemblyMichael Pratt
Most of these are one-off mistakes. Only one file was all spaces. Change-Id: I277c3ce4a4811aa4248c90676f66bc775ae8d062 Reviewed-on: https://go-review.googlesource.com/c/go/+/478976 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-28hash/maphash: add purego implementationCuong Manh Le
Fixes #47342 Change-Id: I9c3b36de3e7c85d3e7aff2f84abc78a1b382008c Reviewed-on: https://go-review.googlesource.com/c/go/+/468795 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-12-01runtime,hash/maphash: eliminate maphash torture test for -raceThan McIntosh
Disable the "torture" portion of the maphash tests if -race is in effect (these tests can cause timeouts on the longtest -race builder). Fixes #57030. Change-Id: I23d7561dac3e81d979cad9e0efa6f5b7154aadd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/454455 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-27hash/crc64: use slicing by 8 when the size is greater or equal than 2kruinan
In the previous, we will only use the slicing by 8 look up table when the data size is greater than 16k, but the threshold seems to be too large. We may lose some performance for the small data size. In this CL, we change the threshold to 2k, it shows that the performance is improved greatly when the data size is 2k ~ 16k. We did some tests for the Random2K ~ Random16K between various cores(mostly on x86 and arm architecture). Here are the benchmark and some results: 1. The benchmark for testing: func BenchmarkRandom(b *testing.B) { poly := 0x58993511 b.Run("Random256", func(b *testing.B) { bench(b, uint64(poly), 256) }) b.Run("Random512", func(b *testing.B) { bench(b, uint64(poly), 512) }) b.Run("Random1KB", func(b *testing.B) { bench(b, uint64(poly), 1<<10) }) b.Run("Random2KB", func(b *testing.B) { bench(b, uint64(poly), 2<<10) }) b.Run("Random4KB", func(b *testing.B) { bench(b, uint64(poly), 4<<10) }) b.Run("Random8KB", func(b *testing.B) { bench(b, uint64(poly), 8<<10) }) b.Run("Random16KB", func(b *testing.B) { bench(b, uint64(poly), 16<<10) }) } 2. Some results: Apple silicon M1: Benchmark old new delta Random/Random2KB-10 362MB/s 801MB/s +121.41% Random/Random4KB-10 360MB/s 1083MB/s +200.93% Random/Random8KB-10 359MB/s 1309MB/s +264.88% Random/Random16KB-10 358MB/s 1466MB/s +309.79% Neoverse N1: Benchmark old new delta Random/Random2KB-160 397MB/s 493MB/s +24.23% Random/Random4KB-160 397MB/s 742MB/s +86.86% Random/Random8KB-160 398MB/s 995MB/s +150.12% Random/Random16KB-160 398MB/s 1196MB/s +200.58% Silver 4116: Benchmark old new delta Random/Random2KB-48 252MB/s 418MB/s +65.79% Random/Random4KB-48 253MB/s 621MB/s +145.72% Random/Random8KB-48 254MB/s 796MB/s +213.07% Random/Random16KB-48 258MB/s 929MB/s +260.46% EPYC 7251: Benchmark old new delta Random/Random2KB-32 255MB/s 380MB/s +48.88% Random/Random4KB-32 255MB/s 561MB/s +119.73% Random/Random8KB-32 255MB/s 738MB/s +189.18% Random/Random16KB-32 255MB/s 877MB/s +243.80% Change-Id: Ib7b4f6826c3edd6f315cac8057d52b6da252a652 Reviewed-on: https://go-review.googlesource.com/c/go/+/445475 Run-TryBot: Eric Fang <eric.fang@arm.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
2022-09-15hash/crc32: remove redundant codeErik Pellizzon
Merge the CRC32 Update and Write functions using an unexported function, to avoid duplication of code and make it more readable. The only difference between them is the check of the initialization of the IEEE table, and a boolean value specifies that. Throughout the crc32.go file, in the switches the default value is inserted inside the switch statement, this change uniforms the style of the MakeTable function, making it like the other pieces of code. Change-Id: I3889f6c6671210c82f0d7250cea67907bccf3ce7 GitHub-Last-Rev: b8777ee213f2ebad0bb4a5dcdb812fd356d6d086 GitHub-Pull-Request: golang/go#55044 Reviewed-on: https://go-review.googlesource.com/c/go/+/430456 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Jenny Rakoczy <jenny@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Jenny Rakoczy <jenny@golang.org> Auto-Submit: Jenny Rakoczy <jenny@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-08all: use unsafe.{Slice, SliceData, String, StringData} to simplify codehopehook
Because most of these APIs are recently supported, we can only do some advancement work as much as possible under the premise of compatibility. For #54854. Change-Id: Id15d11288bf23902570d54eaf2704a5264210b2e Reviewed-on: https://go-review.googlesource.com/c/go/+/429115 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> 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-09-02hash: convert haveCastagnoli to atomic typecuiweixie
Change-Id: I313fff5684d89ee737572d11b1b697c5575866a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/426083 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-08-18hash/crc32: remove single-use {castagnoli,ieee}ArchImpl boolsTobias Klauser
These are only used once right after being set in castagnoliInit and ieeeInit, respectively. Change-Id: Ifc5df1fe3040b97b1d252cc6d6d28d8fbc132fa5 Reviewed-on: https://go-review.googlesource.com/c/go/+/423854 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2022-08-10hash/crc32: use LDP instead of LDR in crc32 computationruinan
Since recent ARM CPUs support CRC late forwarding of results from a producer to a consumer, the second CRC instruction can be executed before the first CRC instruction complete. By loading 16 bytes once with LDP and ordering two CRC instructions here we can make the data forwarding happen to get better performance. Benchmarks old ThisRun delta CRC32/poly=IEEE/size=15/align=0-160 1.24GB/s 1.26GB/s +1.92% CRC32/poly=IEEE/size=15/align=1-160 1.24GB/s 1.26GB/s +1.92% CRC32/poly=IEEE/size=40/align=0-160 2.89GB/s 2.87GB/s -0.72% CRC32/poly=IEEE/size=40/align=1-160 2.86GB/s 2.87GB/s ~ CRC32/poly=IEEE/size=512/align=0-160 9.29GB/s 14.47GB/s +55.69% CRC32/poly=IEEE/size=512/align=1-160 9.26GB/s 13.88GB/s +49.89% CRC32/poly=IEEE/size=1kB/align=0-160 10.2GB/s 17.6GB/s +72.97% CRC32/poly=IEEE/size=1kB/align=1-160 10.1GB/s 17.2GB/s +69.29% CRC32/poly=IEEE/size=4kB/align=0-160 10.5GB/s 20.9GB/s +99.01% CRC32/poly=IEEE/size=4kB/align=1-160 10.5GB/s 20.5GB/s +95.02% CRC32/poly=IEEE/size=32kB/align=0-160 11.1GB/s 22.0GB/s +98.40% CRC32/poly=IEEE/size=32kB/align=1-160 11.1GB/s 21.6GB/s +94.80% CRC32/poly=Castagnoli/size=15/align=0-160 1.26GB/s 1.26GB/s ~ CRC32/poly=Castagnoli/size=15/align=1-160 1.25GB/s 1.26GB/s ~ CRC32/poly=Castagnoli/size=40/align=0-160 2.88GB/s 3.02GB/s +5.18% CRC32/poly=Castagnoli/size=40/align=1-160 2.85GB/s 3.01GB/s +5.57% CRC32/poly=Castagnoli/size=512/align=0-160 9.24GB/s 14.71GB/s +59.29% CRC32/poly=Castagnoli/size=512/align=1-160 9.21GB/s 13.45GB/s +45.92% CRC32/poly=Castagnoli/size=1kB/align=0-160 10.1GB/s 17.8GB/s +75.81% CRC32/poly=Castagnoli/size=1kB/align=1-160 10.1GB/s 17.0GB/s +67.80% CRC32/poly=Castagnoli/size=4kB/align=0-160 10.5GB/s 21.0GB/s +99.67% CRC32/poly=Castagnoli/size=4kB/align=1-160 10.5GB/s 20.5GB/s +94.26% CRC32/poly=Castagnoli/size=32kB/align=0-160 11.1GB/s 22.0GB/s +98.39% CRC32/poly=Castagnoli/size=32kB/align=1-160 11.1GB/s 21.7GB/s +95.63% Change-Id: Ifc7be5048cafac242e7b75f652e4aafa9aeae844 Reviewed-on: https://go-review.googlesource.com/c/go/+/407854 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Eric Fang <eric.fang@arm.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-05-25hash/crc32: fix typo in arm64 archInitCastagnoli panic messageTobias Klauser
Change-Id: I5291216d5416eccd5a67b45b2f32cf2932b3747f Reviewed-on: https://go-review.googlesource.com/c/go/+/407974 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-21hash/maphash: use fastrand64 in MakeSeedzhangyunhao
Change-Id: I5ccbcea4c53658136b25ca608faec19eeec2e908 Reviewed-on: https://go-review.googlesource.com/c/go/+/400915 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-07hash/maphash: use correct method name in commentj178
Change-Id: I01a3a5232525683c987b52ab8ece3fc18b6f431b GitHub-Last-Rev: d2ec8fe536c7a1cdbd23017185447a86bee5a82a GitHub-Pull-Request: golang/go#52194 Reviewed-on: https://go-review.googlesource.com/c/go/+/398714 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc>
2022-04-05hash/maphash: add Bytes and StringRuss Cox
For very small inputs, h.Reset+h.Write+h.Sum64 is fundamentally slower than a single operation, by about a factor of two, because Write must copy the data into h's buffer, just in case there is another Write before the Sum64. A single function doing the whole sequence knows there is no extra write that will happen, so it doesn't need the buffer, so it avoids the copy. Fixes #42710. Change-Id: Icc79c68ccb10827f6640071d026df86b4940fcc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/392494 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05all: separate doc comment from //go: directivesRuss Cox
A future change to gofmt will rewrite // Doc comment. //go:foo to // Doc comment. // //go:foo Apply that change preemptively to all comments (not necessarily just doc comments). For #51082. Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/384260 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-10-28all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox
When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-09-22hash/crc32: improve performance of ppc64SlicingUpdateBy8 on ppc64leArchana R
Reduce the number of instructions in the short loop of ppc64SlicingUpdateBy8 function by combining MOVWZ and SRD into a SRD with appropriate parameters performing the same operation and remove MOVWZ R7,R7 from the loop This change produces the following improvements on POWER9. None of the other tests regress. Improvments on other POWERPC platforms similar. name old time/op new time/op delta CRC32/poly=IEEE/size=15/align=0 80.5ns ± 0% 70.6ns ± 0% -12% CRC32/poly=IEEE/size=15/align=1 80.5ns ± 0% 70.6ns ± 0% -12% CRC32/poly=IEEE/size=512/align=1 151ns ± 0% 139ns ± 0% -7% CRC32/poly=IEEE/size=1kB/align=1 167ns ± 0% 155ns ± 0% -7% CRC32/poly=Castagnoli/size=15/align=0 80.2ns ± 0% 70.5ns ± 0% -12% CRC32/poly=Castagnoli/size=15/align=1 80.2ns ± 0% 70.5ns ± 0% -12% CRC32/poly=Castagnoli/size=512/align=1 150ns ± 0% 139ns ± 0% -7% CRC32/poly=Castagnoli/size=1kB/align=1 166ns ± 0% 155ns ± 0% -6% Change-Id: I424709041c30d1c637b595d0845e3ae78dc3e0a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/350989 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20all: remove redundant spaces before . and ,Yury Smolsky
Change-Id: I6a4bd2544276d0638bddf07ebcf2ee636db30fea Reviewed-on: https://go-review.googlesource.com/c/go/+/311009 Run-TryBot: Yury Smolsky <yury@smolsky.by> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-03-11hash/maphash: increase the buffer sizeJosh Bleecher Snyder
This helps a lot for larger writes. name old time/op new time/op delta Hash8Bytes-8 16.5ns ± 4% 16.8ns ± 2% +1.76% (p=0.000 n=29+30) Hash320Bytes-8 55.0ns ± 2% 41.4ns ± 2% -24.64% (p=0.000 n=28+28) Hash1K-8 190ns ± 2% 130ns ± 3% -31.65% (p=0.000 n=30+30) Hash8K-8 1.57µs ± 2% 1.05µs ± 3% -33.01% (p=0.000 n=30+29) name old speed new speed delta Hash8Bytes-8 485MB/s ± 4% 476MB/s ± 2% -1.73% (p=0.000 n=29+30) Hash320Bytes-8 5.82GB/s ± 2% 7.72GB/s ± 3% +32.55% (p=0.000 n=28+29) Hash1K-8 5.39GB/s ± 2% 7.88GB/s ± 3% +46.32% (p=0.000 n=30+30) Hash8K-8 5.21GB/s ± 2% 7.77GB/s ± 3% +49.28% (p=0.000 n=30+29) Updates #42710 Change-Id: Idaf4b2a8a41fc62fc16b54c9358cf2cc7009cf29 Reviewed-on: https://go-review.googlesource.com/c/go/+/278760 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-03-11hash/maphash: optimize Write and WriteStringJosh Bleecher Snyder
The existing code makes copies of every byte it hashes. When passed a large chunk of memory, Write and WriteString can skip the copying and initSeed for most of it. To ensure that Write, WriteByte, and WriteString continue to generate output that depends only on the sequence of bytes, expand the grouping test to include WriteString and interleaved calls. Also, make the test process a lot more data, to ensure that Write* handled full buffers correctly. name old time/op new time/op delta Hash8Bytes-8 17.1ns ± 3% 16.5ns ± 2% -3.26% (p=0.000 n=29+27) Hash320Bytes-8 74.9ns ± 2% 58.5ns ± 2% -21.86% (p=0.000 n=30+29) Hash1K-8 246ns ± 3% 195ns ± 1% -20.82% (p=0.000 n=29+30) Hash8K-8 1.87µs ± 2% 1.59µs ± 2% -15.04% (p=0.000 n=26+30) name old speed new speed delta Hash8Bytes-8 468MB/s ± 3% 484MB/s ± 2% +3.36% (p=0.000 n=29+27) Hash320Bytes-8 4.28GB/s ± 2% 5.47GB/s ± 2% +27.97% (p=0.000 n=30+29) Hash1K-8 4.17GB/s ± 3% 5.26GB/s ± 1% +26.28% (p=0.000 n=29+30) Hash8K-8 4.38GB/s ± 2% 5.16GB/s ± 2% +17.70% (p=0.000 n=26+30) Updates #42710 Change-Id: If3cdec1580ffb3e36fab9865e5a9d089c0a34bec Reviewed-on: https://go-review.googlesource.com/c/go/+/278758 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-03-11hash/maphash: manually inline setSeedJosh Bleecher Snyder
Provides a minor performance win. name old time/op new time/op delta Hash8Bytes-8 16.5ns ± 2% 16.5ns ± 4% ~ (p=0.407 n=27+29) Hash320Bytes-8 58.5ns ± 2% 55.0ns ± 2% -6.01% (p=0.000 n=29+28) Hash1K-8 195ns ± 1% 190ns ± 2% -2.23% (p=0.000 n=30+30) Hash8K-8 1.59µs ± 2% 1.57µs ± 2% -0.88% (p=0.002 n=30+30) name old speed new speed delta Hash8Bytes-8 484MB/s ± 2% 485MB/s ± 4% ~ (p=0.417 n=27+29) Hash320Bytes-8 5.47GB/s ± 2% 5.82GB/s ± 2% +6.39% (p=0.000 n=29+28) Hash1K-8 5.26GB/s ± 1% 5.39GB/s ± 2% +2.29% (p=0.000 n=30+30) Hash8K-8 5.16GB/s ± 2% 5.21GB/s ± 2% +0.89% (p=0.002 n=30+30) Updates #42710 Change-Id: Ia0d7264b648f96099202de21c6b69a9c1776f6c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/278759 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24hash/maphash: remove duplicate from Hash documentationAlberto Donizetti
Fixes #44255 Change-Id: I14d2edbee0a0c39e04111414a57d70ee2fdfb6af Reviewed-on: https://go-review.googlesource.com/c/go/+/291631 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-13hash/crc32: fix race between lazy Castagnoli init and Update/WriteRuss Cox
The switch on tab is checking tab == castagnoliTable, but castagnoliTable can change value during a concurrent call to MakeTable. Fixes #41911. Change-Id: I6124dcdbf33e17fe302baa3e1aa03202dec61b4c Reviewed-on: https://go-review.googlesource.com/c/go/+/261639 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-12hash/maphash: adjust package commentRuss Cox
Add note about using per-use seeds. Delete "collision-resistant but" in: > The hash functions are collision-resistant but not cryptographically secure. "Collision-resistant" has a precise cryptographic meaning that is incompatible with "not cryptographically secure". All that is really meant by it here here is "it's a good hash function", which should be established already. Also delete: > The hash value of a given byte sequence is consistent within a > single process, but will be different in different processes. This was added for its final clause in response to #37040, but "The hash value of a given byte sequence" is by design not a concept in this package. Only "... of a given seed and byte sequence". And seeds cannot be shared between processes, so again by design you can't even set up the appropriate first half of the sentence to say the second half. Change-Id: I2c02bee0e804ef3b120cb4752bf89e60f3f5ff5d Reviewed-on: https://go-review.googlesource.com/c/go/+/255968 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-21hash/maphash: adding benchmarks for maphashMeng Zhuo
goos: linux goarch: arm64 pkg: hash/maphash BenchmarkHash8Bytes BenchmarkHash8Bytes 22568919 46.0 ns/op 173.80 MB/s BenchmarkHash320Bytes BenchmarkHash320Bytes 5243858 230 ns/op 1393.30 MB/s BenchmarkHash1K BenchmarkHash1K 1755870 660 ns/op 1550.60 MB/s BenchmarkHash8K BenchmarkHash8K 225688 5313 ns/op 1541.90 MB/s PASS ok hash/maphash 6.465s Change-Id: I5a909042a542135ebc47d639fea02dc46c900c1c Reviewed-on: https://go-review.googlesource.com/c/go/+/249079 Run-TryBot: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2020-04-27hash/crc32: simplify hasVX checking on s390xRuixin(Peter) Bao
Originally, we use an assembly function that returns a boolean result to tell whether the machine has vector facility or not. It is now no longer needed when we can directly use cpu.S390X.HasVX variable. This CL also removes the last occurence of hasVectorFacility function on s390x. Change-Id: Id20cb746c21eacac5e13344b362e2d87adfe4317 Reviewed-on: https://go-review.googlesource.com/c/go/+/230337 Reviewed-by: Michael Munday <mike.munday@ibm.com> Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-02hash/maphash: add more tests for seed generationKeith Randall
Test all the paths by which a Hash picks its seed. Make sure they all behave identically to a preset seed. Change-Id: I2f7950857697f2f07226b96655574c36931b2aae Reviewed-on: https://go-review.googlesource.com/c/go/+/220686 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Vladimir Evgrafov <evgrafov.vladimir@gmail.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2020-02-24hash/maphash: add package-level exampleAlberto Donizetti
Change-Id: I05c7ca644410822a527e94a7a8b883a0f8b0a4ad Reviewed-on: https://go-review.googlesource.com/c/go/+/220420 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>