No changes in the actual generated compiler code.
Change-Id: I206a7bf7b60f70a73640119fc92974f79ed95a6b
Reviewed-on: https://go-review.googlesource.com/102416
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
CL 102457 added TestDevNullFile. However, this
test is failing on Plan 9, because it checks
that /dev/null is a character device while there
are no special files on Plan 9.
We fix this issue by changing Stat to consider
all files served by the console device (#c)
as character devices.
Fixes#24534.
Change-Id: I1c60cdf25770358b908790b3fb71910fa914dec0
Reviewed-on: https://go-review.googlesource.com/102424
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Fixes#24546
Change-Id: I99ebd5bc18e5c5e42eee4689644a7a8b02405f31
Reviewed-on: https://go-review.googlesource.com/102616
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
I grepped for "bytes.Buffer" and "buf.String" and mostly ignored test
files. I skipped a few on purpose and probably missed a few others,
but otherwise I think this should be most of them.
Updates #18990
Change-Id: I5a6ae4296b87b416d8da02d7bfaf981d8cc14774
Reviewed-on: https://go-review.googlesource.com/102479
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The documentation was unclear here and I misremembered the behaviour and
changed it in 1.10: it used to be that matching any EKU was enough but
1.10 requires that all EKUs match.
Restore 1.9 behaviour and clarify the documentation to make it official.
Fixes#24162.
Change-Id: Ic9466cd0799cb27ec3a3a7e6c96f10c2aacc7020
Reviewed-on: https://go-review.googlesource.com/97720
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
The way Value.AuxInt represents unsigned numbers is currently
documented in genericOps.go, which is not the most obvious place for
it. Move that documentation to Value.AuxInt. Furthermore, to make it
harder to use incorrectly, introduce a Value.AuxUnsigned accessor that
returns the zero-extended value of Value.AuxInt.
Change-Id: I85030c3c68761404058a430e0b1c7464591b2f42
Reviewed-on: https://go-review.googlesource.com/102597
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Even though GOARCH=sparc64 is not supported by gc (yet), it is easy to
make cgo already support it.
This e.g. allows to generate Go type definitions for linux/sparc64 in
the golang.org/x/sys/unix package without using gccgo.
Change-Id: I8886c81e7c895a0d93e350d81ed653fb59d95dd8
Reviewed-on: https://go-review.googlesource.com/102555
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Gdb can be sensitive to contents of .gdbinit, and to run
this test properly needs to have runtime/runtime-gdb.py
on the auto load safe path. Therefore, turn off .gdbinit
loading and explicitly add $GOROOT/runtime to the safe
load path.
This should make ssa/debug_test.go run more consistently.
Updates #24464.
Change-Id: I63ed17c032cb3773048713ce51fca3a3f86e79b6
Reviewed-on: https://go-review.googlesource.com/102598
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
We already replaced most loops with PutOpBytesLit where possible,
do this in a last few places.
Change-Id: I8c90de017810145a12394fa6b887755e9111b22a
Reviewed-on: https://go-review.googlesource.com/102276
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
A newish check for branch-likely on single-successor blocks
caught a case where the preemption-check inserter was
setting "likely" on an unconditional branch.
Fixed by checking for that case before setting likely.
Also removed an overconservative restriction on parallel
compilation for GOEXPERIMENT=preemptibleloops; it works
fine, it is just another control-flow transformation.
Change-Id: I8e786e6281e0631cac8d80cff67bfb6402b4d225
Reviewed-on: https://go-review.googlesource.com/102317
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
We use 32-bit operations for 8- and 16-bit arithmetic, so use them
for comparisons too. This won't change performance but it is more
consistent and makes testing 8- and 16-bit comparison codegen
slightly more straightforward (for follow up CL).
Also fix a typo and add some additional double sign and zero
extension rules to remove the operations inserted by the comparison
rules.
Change-Id: I89ec1b0e09cb8be8090cf007be283ad88bba75a4
Reviewed-on: https://go-review.googlesource.com/102556
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This was a typo mistake according to if cond and runtime/mheap.go:323
Change-Id: Id046d4afbfe0ea43cb29e1a9f400e1f130de221d
Reviewed-on: https://go-review.googlesource.com/102575
Reviewed-by: Austin Clements <austin@google.com>
This change makes errors in the example code a bit better, as it's no use to show the root dir when an error occurs walking a subdirectory or file.
Change-Id: I546276e9b151fabba5357258f03bfbd47a508201
GitHub-Last-Rev: 398c1eeb61
GitHub-Pull-Request: golang/go#24536
Reviewed-on: https://go-review.googlesource.com/102535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Add a note that if an error is returned after having read
at least the minimum no. of bytes, the error is set to nil.
Fixes#20477
Change-Id: I75ba5ee967be3ff80249e40d459da4afeeb53463
Reviewed-on: https://go-review.googlesource.com/102459
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Move part of UserSpan event processing from cmd/trace.analyzeAnnotations
to internal/trace.GoroutineStats that returns analyzed per-goroutine
execution information. Now the execution information includes list of
spans and their execution information.
cmd/trace.analyzeAnnotations utilizes the span execution information
from internal/trace.GoroutineStats and connects them with task
information.
Change-Id: Ib7f79a3ba652a4ae55cd81ea17565bcc7e241c5c
Reviewed-on: https://go-review.googlesource.com/101917
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
- Summary: also includes links to pprof data.
- Sortable table: sorting is done on server-side. The intention is
that later, I want to add pagination feature and limit the page
size the browser has to handle.
- Stacked horizontal bar graph to present total time breakdown.
- Human-friendly time representation.
- No dependency on external fancy javascript libraries to allow
it to function without an internet connection.
Change-Id: I91e5c26746e59ad0329dfb61e096e11f768c7b73
Reviewed-on: https://go-review.googlesource.com/102156
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
CL 102456 added Lstat check to TestDevNullFile.
But some systems have /dev/null as a symlink,
so Lstat test is wrong. Remove the test.
Fixes#24521
Change-Id: I149110b08dd05db6495ec4eccbcf943e444332f9
Reviewed-on: https://go-review.googlesource.com/102461
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
RFC 8081 declares a top level font media type for all types of fonts.
Updating the mime types in sniffer to reflect the new changes.
Fixes#24524
Change-Id: Iba6cef4c5974e9930e14705720d42550ee87ba56
Reviewed-on: https://go-review.googlesource.com/102458
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Also add more tests to test both nul and NUL on windows.
Fixes#24482
Change-Id: I3dfe68ec8de7f90ca869c1096dde0054df3c5cf6
Reviewed-on: https://go-review.googlesource.com/102457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The build dashboard is dotted with net test failures.
We cannot declare all builders to have flaky networks,
although all fundamentally do.
Instead, add a simple retry/backoff loop to the ones that
show up most commonly on the dashboard at this moment.
If this approach works well in practice, we can
incrementally apply it to other flaky net tests.
Change-Id: I69c1ca6ce5b347ad549c7eb18d0438373f6e2489
Reviewed-on: https://go-review.googlesource.com/102397
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This aims to expand the coverage of examples showing how the sql
package works, as well as to address a number of issues I've observed
while explaining how the database package works:
- The best way to issue UPDATE or INSERT queries, that don't need
to scan anything in return. (Previously, we had no examples for any
Execute statement).
- How to use prepared statements and transactions.
- How to aggregate arguments from a Query/QueryContext query into
a slice.
Furthermore just having examples in more places should help, as users
click on e.g. the "Rows" return parameter and are treated with the
lack of any example about how Rows is used.
Switch package examples to use QueryContext/QueryRowContext; I think
it is a good practice to prepare users to issue queries with a timeout
attached, even if they are not using it immediately.
Change-Id: I4e63af91c7e4fff88b25f820906104ecefde4cc3
Reviewed-on: https://go-review.googlesource.com/91015
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
DevNull is documented on darwin, dragonfly, freebsd, linux,
nacl, netbsd, openbsd, solaris and plan9, but not on windows.
Add missing documentation.
Change-Id: Icdbded0dd5e322ed4360cbce6bee4cdca5cfbe72
Reviewed-on: https://go-review.googlesource.com/102456
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
As found by unparam. Picked the low-hanging fruit, consisting only of
errors that were always nil and results that were never used. Left out
those that were useful for consistency with other func signatures.
Change-Id: I06b52bbd3541f8a5d66659c909bd93cb3e172018
Reviewed-on: https://go-review.googlesource.com/102418
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Remove a couple of unnecessary var declarations, an unused sort.Sort
type, and simplify a range by using the two-name variant.
Change-Id: Ia251f634db0bfbe8b1d553b8659272ddbd13b2c3
Reviewed-on: https://go-review.googlesource.com/102336
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
And delete them from asm_test.
Change-Id: I34fcf85ae8ce09cd146fe4ce6a0ae7616bd97e2d
Reviewed-on: https://go-review.googlesource.com/102296
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
As pointed out by Josh Bleecher Snyder in CL 99780.
The check is for GOARM > 6, so suggest to recompile with either GOARM=5
or GOARM=6.
Change-Id: I6a97e87bdc17aa3932f5c8cb598bba85c3cf4be9
Reviewed-on: https://go-review.googlesource.com/101936
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Sometimes, we can end up calling update with a self-relation
about a variable (x REL x). In this case, there is no need
to record anything: the relation is unsatisfiable if and only
if it doesn't contain eq.
This also helps avoiding infinite loop in next CL that will
introduce transitive closure of relations.
Passes toolstash -cmp.
Change-Id: Ic408452ec1c13653f22ada35466ec98bc14aaa8e
Reviewed-on: https://go-review.googlesource.com/100276
Reviewed-by: Austin Clements <austin@google.com>
When an unsatisfiable relation is recorded in the facts table,
there is no need to compute further relations or updates
additional data structures.
Since we're about to transitively propagate relations, make
sure to fail as fast as possible to avoid doing useless work
in dead branches.
Passes toolstash -cmp.
Change-Id: I23eed376d62776824c33088163c7ac9620abce85
Reviewed-on: https://go-review.googlesource.com/100275
Reviewed-by: Austin Clements <austin@google.com>
The ssa.Func has Type field that is described as
function signature type.
It never gets any value and remains nil.
This leads to "<T>" signature printed representation.
Given this function declaration:
func foo(x int, f func() string) (int, error)
GOSSAFUNC printed it as below:
compiling foo
foo <T>
After this change:
compiling foo
foo func(int, func() string) (int, error)
Change-Id: Iec5eec8aac5c76ff184659e30f41b2f5fe86d329
Reviewed-on: https://go-review.googlesource.com/102375
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
By always writing out pack files, the object file format can be
simplified somewhat. In particular, the export data format will no
longer require escaping, because the pack file provides appropriate
framing.
This CL does not affect build systems that use -pack, which includes
all major Go build systems (cmd/go, gb, bazel).
Also, existing package import logic already distinguishes pack/object
files based on file contents rather than file extension.
The only exception is cmd/pack, which specially handled object files
created by cmd/compile when used with the 'c' mode. This mode is
extended to now recognize the pack files produced by cmd/compile and
handle them as before.
Passes toolstash-check.
Updates #21705.
Updates #24512.
Change-Id: Idf131013bfebd73a5cde7e087eb19964503a9422
Reviewed-on: https://go-review.googlesource.com/102236
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The __.PKGDEF file is a compiler object file only intended for other
compilers. Also, for build systems that use -linkobj, all of the
information it contains is present within the linker object files
already, so look for it there instead.
This requires a little bit of code reorganization. Significantly,
previously when loading an archive file, the __.PKGDEF file was
authoritative on whether the package was "main" and/or "safe". Now
that we're using the Go object files instead, there's the issue that
there can be multiple Go object files in an archive (because when
using assembly, each assembly file becomes its own additional object
file).
The solution taken here is to check if any object file within the
package declares itself as "main" and/or "safe".
Updates #24512.
Change-Id: I70243a293bdf34b8555c0bf1833f8933b2809449
Reviewed-on: https://go-review.googlesource.com/102281
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This is currently always the case because loadobjfile complains if
it's not, but that will be changed soon.
Updates #24512.
Change-Id: I262daca765932a0f4cea3fcc1cc80ca90de07a59
Reviewed-on: https://go-review.googlesource.com/102280
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
AT_HWCAP is not available on FreeBSD-11.1-RELEASE or earlier and the wrong const was used.
Use the correct value, and initialize hwcap with ^uint32(0) inorder not to fail the VFP tests.
Fixes#24507.
Change-Id: I5c3eed57bb53bf992b7de0eec88ea959806306b9
Reviewed-on: https://go-review.googlesource.com/102355
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The compiler can't currently figure out that it can eliminate both c.s
loads (using store to load forwarding) in the second line of the
following code:
...
c.s[i], c.s[j] = c.s[j], c.s[i]
x := c.s[j] + c.s[i]
...
The compiler eliminates the second load of c.s[j] (using the original
value of c.s[i]), however the load of c.s[i] remains because the compiler
doesn't know that c.s[i] and c.s[j] either overlap completely or not at
all.
Introducing temporaries to make this explicit improves the performance
of the generic code slightly, the goal being to remove the assembly in
this package in the future. This change also hoists a bounds check out
of the main loop which gives a slight performance boost and also makes
the behaviour identical to the assembly implementation when len(dst) <
len(src).
name old speed new speed delta
RC4_128-4 491MB/s ± 3% 596MB/s ± 5% +21.51% (p=0.000 n=9+9)
RC4_1K-4 504MB/s ± 2% 616MB/s ± 1% +22.33% (p=0.000 n=10+10)
RC4_8K-4 509MB/s ± 1% 630MB/s ± 2% +23.85% (p=0.000 n=8+9)
Change-Id: I27adc775713b2e74a1a94e0c1de0909fb4379463
Reviewed-on: https://go-review.googlesource.com/102335
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This reverts commit c6e69ec7f9.
Reason for revert: Broke builders. #24508
Change-Id: I66abff0dd14ec6e1f8d8d982ccfb0438633b639d
Reviewed-on: https://go-review.googlesource.com/102316
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
I don't know if I got lost in the old PKCS documents, or whether this is
a case where reality diverges from the spec, but OpenSSL clearly stuffs
PKIX Extension objects in CSR attributues directly[1].
In either case, doing what OpenSSL does seems valid here and allows the
critical flag in extensions to be serialised.
Fixes#13739.
[1] e3713c365c/crypto/x509/x509_req.c (L173)
Change-Id: Ic1e73ba9bd383a357a2aa8fc4f6bd76811bbefcc
Reviewed-on: https://go-review.googlesource.com/70851
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
This change implement keying material export as described in:
https://tools.ietf.org/html/rfc5705
I verified the implementation against openssl s_client and openssl
s_server.
Change-Id: I4dcdd2fb929c63ab4e92054616beab6dae7b1c55
Signed-off-by: Mike Danese <mikedanese@google.com>
Reviewed-on: https://go-review.googlesource.com/85115
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Slightly simplifies the code. Made sure to exclude the cases that would
change behavior, such as when the iterated value is a string, when the
index is modified within the body, or when the slice is modified.
Also checked that all the elements are of pointer type, to avoid the
corner case where non-pointer types could be copied by mistake.
Change-Id: Iea64feb2a9a6a4c94ada9ff3ace40ee173505849
Reviewed-on: https://go-review.googlesource.com/100557
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This experiment has gone stale. It causes a type-checking failure
because the condition of the OIF produced by range loop lowering has
type "untyped bool". Fix this by typechecking the whole OIF statement,
not just its condition.
This doesn't quite fix the whole experiment, but it gets further.
Something about preemption point insertion is causing failures like
"internal compiler error: likeliness prediction 1 for block b10 with 1
successors" in cmd/compile/internal/gc.
Change-Id: I7d80d618d7c91c338bf5f2a8dc174d582a479df3
Reviewed-on: https://go-review.googlesource.com/102157
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Move currently uses mov instructions directly up to 31 bytes and then
switches to duffcopy. Moving 31 bytes is 4 instructions corresponding to
two loads and two stores, (or 6 if !useSSE) depending on the usage,
duffcopy is five (one or two mov, two or three lea, one call).
This adds direct mov instructions for Move's of size 32, 48, and 64 with
sse and for only size 32 without.
With useSSE:
- 32 is 4 instructions (byte +/- comparison below)
- 33 thru 48 is 6
- 49 thru 64 is 8
Without:
- 32 is 8
Note that the only platform with useSSE set to false is plan 9. I have
built three projects based off tip and tip with this patch and the
project's byte size is equal to or less than they were prior.
The basis of this change is that copying data with instructions directly
is nearly free, whereas calling into duffcopy adds a bit of overhead.
This is most noticeable in range statements where elements are 32+
bytes. For code with the following pattern:
func Benchmark32Range(b *testing.B) {
var f s32
for _, count := range []int{10, 100, 1000, 10000} {
name := strconv.Itoa(count)
b.Run(name, func(b *testing.B) {
base := make([]s32, count)
for i := 0; i < b.N; i++ {
for _, v := range base {
f = v
}
}
})
}
_ = f
}
These are the resulting benchmarks:
Benchmark16Range/10-4 19.1 19.1 +0.00%
Benchmark16Range/100-4 169 170 +0.59%
Benchmark16Range/1000-4 1684 1691 +0.42%
Benchmark16Range/10000-4 18147 18124 -0.13%
Benchmark31Range/10-4 141 142 +0.71%
Benchmark31Range/100-4 1407 1410 +0.21%
Benchmark31Range/1000-4 14070 14074 +0.03%
Benchmark31Range/10000-4 141781 141759 -0.02%
Benchmark32Range/10-4 71.4 32.2 -54.90%
Benchmark32Range/100-4 695 326 -53.09%
Benchmark32Range/1000-4 7166 3313 -53.77%
Benchmark32Range/10000-4 72571 35425 -51.19%
Benchmark64Range/10-4 87.8 64.9 -26.08%
Benchmark64Range/100-4 868 629 -27.53%
Benchmark64Range/1000-4 9355 6907 -26.17%
Benchmark64Range/10000-4 94463 70385 -25.49%
Benchmark79Range/10-4 177 152 -14.12%
Benchmark79Range/100-4 1769 1531 -13.45%
Benchmark79Range/1000-4 17893 15532 -13.20%
Benchmark79Range/10000-4 178947 155551 -13.07%
Benchmark80Range/10-4 99.6 99.7 +0.10%
Benchmark80Range/100-4 987 985 -0.20%
Benchmark80Range/1000-4 10573 10560 -0.12%
Benchmark80Range/10000-4 106792 106639 -0.14%
For runtime's BenchCopyFat* benchmarks:
CopyFat8-4 0.40ns ± 0% 0.40ns ± 0% ~ (all equal)
CopyFat12-4 0.40ns ± 0% 0.80ns ± 0% +100.00% (p=0.000 n=9+9)
CopyFat16-4 0.40ns ± 0% 0.80ns ± 0% +100.00% (p=0.000 n=10+8)
CopyFat24-4 0.80ns ± 0% 0.40ns ± 0% -50.00% (p=0.001 n=8+9)
CopyFat32-4 2.01ns ± 0% 0.40ns ± 0% -80.10% (p=0.000 n=8+8)
CopyFat64-4 2.87ns ± 0% 0.40ns ± 0% -86.07% (p=0.000 n=8+10)
CopyFat128-4 4.82ns ± 0% 4.82ns ± 0% ~ (p=1.000 n=8+8)
CopyFat256-4 8.83ns ± 0% 8.83ns ± 0% ~ (p=1.000 n=8+8)
CopyFat512-4 16.9ns ± 0% 16.9ns ± 0% ~ (all equal)
CopyFat520-4 14.6ns ± 0% 14.6ns ± 1% ~ (p=0.529 n=8+9)
CopyFat1024-4 32.9ns ± 0% 33.0ns ± 0% +0.20% (p=0.041 n=8+9)
Function calls are not benefitted as much due how they are compiled, but
other benchmarks I ran show that calling function with 64 byte elements
is marginally improved.
The main downside with this change is that it may increase binary sizes
depending on the size of the copy, but this change also decreases
binaries for moves of 48 bytes or less.
For the following code:
package main
type size [32]byte
//go:noinline
func use(t size) {
}
//go:noinline
func get() size {
var z size
return z
}
func main() {
var a size
use(a)
}
Changing size around gives the following assembly leading up to the call
(the initialization and actual call are removed):
tip func call with 32B arg: 27B
48 89 e7 mov %rsp,%rdi
48 8d 74 24 20 lea 0x20(%rsp),%rsi
48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
48 8d 6c 24 f0 lea -0x10(%rsp),%rbp
e8 53 ab ff ff callq 448964 <runtime.duffcopy+0x364>
48 8b 6d 00 mov 0x0(%rbp),%rbp
modified: 19B (-8B)
0f 10 44 24 20 movups 0x20(%rsp),%xmm0
0f 11 04 24 movups %xmm0,(%rsp)
0f 10 44 24 30 movups 0x30(%rsp),%xmm0
0f 11 44 24 10 movups %xmm0,0x10(%rsp)
-
tip with 47B arg: 29B
48 8d 7c 24 0f lea 0xf(%rsp),%rdi
48 8d 74 24 40 lea 0x40(%rsp),%rsi
48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
48 8d 6c 24 f0 lea -0x10(%rsp),%rbp
e8 43 ab ff ff callq 448964 <runtime.duffcopy+0x364>
48 8b 6d 00 mov 0x0(%rbp),%rbp
modified: 20B (-9B)
0f 10 44 24 40 movups 0x40(%rsp),%xmm0
0f 11 44 24 0f movups %xmm0,0xf(%rsp)
0f 10 44 24 50 movups 0x50(%rsp),%xmm0
0f 11 44 24 1f movups %xmm0,0x1f(%rsp)
-
tip with 64B arg: 27B
48 89 e7 mov %rsp,%rdi
48 8d 74 24 40 lea 0x40(%rsp),%rsi
48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
48 8d 6c 24 f0 lea -0x10(%rsp),%rbp
e8 1f ab ff ff callq 448948 <runtime.duffcopy+0x348>
48 8b 6d 00 mov 0x0(%rbp),%rbp
modified: 39B [+12B]
0f 10 44 24 40 movups 0x40(%rsp),%xmm0
0f 11 04 24 movups %xmm0,(%rsp)
0f 10 44 24 50 movups 0x50(%rsp),%xmm0
0f 11 44 24 10 movups %xmm0,0x10(%rsp)
0f 10 44 24 60 movups 0x60(%rsp),%xmm0
0f 11 44 24 20 movups %xmm0,0x20(%rsp)
0f 10 44 24 70 movups 0x70(%rsp),%xmm0
0f 11 44 24 30 movups %xmm0,0x30(%rsp)
-
tip with 79B arg: 29B
48 8d 7c 24 0f lea 0xf(%rsp),%rdi
48 8d 74 24 60 lea 0x60(%rsp),%rsi
48 89 6c 24 f0 mov %rbp,-0x10(%rsp)
48 8d 6c 24 f0 lea -0x10(%rsp),%rbp
e8 09 ab ff ff callq 448948 <runtime.duffcopy+0x348>
48 8b 6d 00 mov 0x0(%rbp),%rbp
modified: 46B [+17B]
0f 10 44 24 60 movups 0x60(%rsp),%xmm0
0f 11 44 24 0f movups %xmm0,0xf(%rsp)
0f 10 44 24 70 movups 0x70(%rsp),%xmm0
0f 11 44 24 1f movups %xmm0,0x1f(%rsp)
0f 10 84 24 80 00 00 movups 0x80(%rsp),%xmm0
00
0f 11 44 24 2f movups %xmm0,0x2f(%rsp)
0f 10 84 24 90 00 00 movups 0x90(%rsp),%xmm0
00
0f 11 44 24 3f movups %xmm0,0x3f(%rsp)
So, at best we save 9B, at worst we gain 17. I do not think that copying
around 65+B sized types is common enough to bloat program sizes. Using
bincmp on the go binary itself shows a zero byte difference; there are
gains and losses all over. One of the largest gains in binary size comes
from cmd/go/internal/cache.(*Cache).Get, which passes around a 64 byte
sized type -- this is one of the cases I would expect to be benefitted
by this change.
I think that this marginal improvement in struct copying for 64 byte
structs is worth it: most data structs / work items I use in my programs
are small, but few are smaller than 32 bytes: with one slice, the budget
is up. The 32 rule alone would allow another 16 bytes, the 48 and 64
rules allow another 32 and 48.
Change-Id: I19a8f9190d5d41825091f17f268f4763bfc12a62
Reviewed-on: https://go-review.googlesource.com/100718
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>