The nlistmin/size thresholds are copied from tcmalloc,
but are unnecesary for Go malloc. We do not do explicit
frees into MCache. For sparse cases when we do (mainly hashmap),
simpler logic will do.
R=rsc, dave, iant
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/9373043
A bufio.Writer.Flush marks the usual end of a Writer's
life. Recycle its internal buffer on those explicit flushes,
but not on normal, as-needed internal flushes.
benchmark old ns/op new ns/op delta
BenchmarkWriterEmpty 1959 727 -62.89%
benchmark old allocs new allocs delta
BenchmarkWriterEmpty 2 1 -50.00%
benchmark old bytes new bytes delta
BenchmarkWriterEmpty 4215 83 -98.03%
R=gri, iant
CC=gobot, golang-dev, voidlogic7
https://golang.org/cl/9459044
This should have been removed in 45c12efb4635. Not a correctness
issue, but unnecessary work.
This CL also adds paranoia checks in removeDep so this doesn't
happen again.
Fixes#5502
R=adg
CC=gobot, golang-dev, google
https://golang.org/cl/9543043
undo CL 8478044 / 0d28fd55e721
Lack of consensus.
««« original CL description
time: add Time.FormatAppend
This is a version of Time.Format that doesn't require allocation.
Fixes#5192
Update #5195
R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
»»»
R=r
CC=golang-dev
https://golang.org/cl/9462049
This isn't clearly a bug on Go's part, but it triggers a bug in Firefox
which means that crypto/tls and net/http cannot be wired up together
unless NextProtos includes "http/1.1". When net/http sets up the
tls.Config, it does this and so works fine. But anyone setting up the
tls.Config themselves will hit the Firefox bug.
Fixes#5445.
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9539045
as OpenBSD lacks 4 errno constants, api/go1.txt is updated so that
api check won't fail.
R=golang-dev, iant, bradfitz, r
CC=golang-dev
https://golang.org/cl/9149045
Several places used io.WriteString unnecessarily when the
static type already implemented WriteString. No need to
check for it at runtime.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9608043
It contains the LHS of the range clause and gets
instrumented by racewalk, but it doesn't have any meaning.
Fixes#5446.
R=golang-dev, dvyukov, daniel.morsing, r
CC=golang-dev
https://golang.org/cl/9560044
Failures caused by errors like invalid signatures or missing hash
functions cause rather generic, unhelpful error messages because no
trust chain can be constructed: "x509: certificate signed by unknown
authority."
With this change, authority errors may contain the reason why an
arbitary candidate step in the chain was rejected. For example, in the
event of a missing hash function the error looks like:
x509: certificate signed by unknown authority (possibly because of
"crypto/x509: cannot verify signature: algorithm unimplemented" while
trying to verify candidate authority certificate 'Thawte SGC CA')
Fixes 5058.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9104051
Share garbage between different bufio Readers. When a Reader
has zero buffered data, put its buffer into a pool.
This acknowledges that most bufio.Readers eventually get
read to completion, and their buffers are then no longer
needed.
benchmark old ns/op new ns/op delta
BenchmarkReaderEmpty 2993 1058 -64.65%
benchmark old allocs new allocs delta
BenchmarkReaderEmpty 3 2 -33.33%
benchmark old bytes new bytes delta
BenchmarkReaderEmpty 4278 133 -96.89%
Update #5100
R=r
CC=adg, dvyukov, gobot, golang-dev, rogpeppe
https://golang.org/cl/8819049
The stack scanner for not started goroutines ignored the arguments
area when its size was unknown. With this change, the distance
between the stack pointer and the stack base will be used instead.
Fixes#5486
R=golang-dev, bradfitz, iant, dvyukov
CC=golang-dev
https://golang.org/cl/9440043
A test added in b37d2fdcc4d9 didn't work with some values of GOMAXPROCS
because the defer statements were in the wrong order: the Pipe could be
closed before the TLS Client was.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9187047
If a slice points to an array embedded in a struct,
the whole struct can be incorrectly scanned as the slice buffer.
Fixes#5443.
R=cshapiro, iant, r, cshapiro, minux.ma
CC=bradfitz, gobot, golang-dev
https://golang.org/cl/9372044
Allocs of size 16 can bypass atomic set of the allocated bit, while allocs of size 8 can not.
Allocs with and w/o type info hit different paths inside of malloc.
Current results on linux/amd64:
BenchmarkMalloc8 50000000 43.6 ns/op
BenchmarkMalloc16 50000000 46.7 ns/op
BenchmarkMallocTypeInfo8 50000000 61.3 ns/op
BenchmarkMallocTypeInfo16 50000000 63.5 ns/op
R=golang-dev, remyoudompheng, minux.ma, bradfitz, iant
CC=golang-dev
https://golang.org/cl/9090045
for checking for page boundary. Also avoid boundary check
when >=16 bytes are hashed.
benchmark old ns/op new ns/op delta
BenchmarkHashStringSpeed 23 22 -0.43%
BenchmarkHashBytesSpeed 44 42 -3.61%
BenchmarkHashStringArraySpeed 71 68 -4.05%
R=iant, khr
CC=gobot, golang-dev, google
https://golang.org/cl/9123046
Finer-grained transfers were relevant with per-M caches,
with per-P caches they are not relevant and harmful for performance.
For few small size classes where it makes difference,
it's fine to grab the whole span (4K).
benchmark old ns/op new ns/op delta
BenchmarkMalloc 42 40 -4.45%
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9374043
The PKCS#1 spec requires that the PS padding in an RSA message be at
least 8 bytes long. We were not previously checking this. This isn't
important in the most common situation (session key encryption), but
the impact is unclear in other cases.
This change enforces the specified minimum size.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/9222045
OpenSSL can be configured to send empty records in order to randomise
the CBC IV. This is an early version of 1/n-1 record splitting (that Go
does) and is quite reasonable, but it results in tls.Conn.Read
returning (0, nil).
This change ignores up to 100 consecutive, empty records to avoid
returning (0, nil) to callers.
Fixes 5309.
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/8852044
This patch resulted from a bit of quick optimisation in response to a
golang-nuts post. It looks like one could save a couple other copies in
this function, but this addresses the inner loop and is fairly simple.
benchmark old ns/op new ns/op delta
BenchmarkGCD10x10 1964 1711 -12.88%
BenchmarkGCD10x100 2019 1736 -14.02%
BenchmarkGCD10x1000 2471 2171 -12.14%
BenchmarkGCD10x10000 6040 5778 -4.34%
BenchmarkGCD10x100000 43204 43025 -0.41%
BenchmarkGCD100x100 11004 8520 -22.57%
BenchmarkGCD100x1000 11820 9446 -20.08%
BenchmarkGCD100x10000 23846 21382 -10.33%
BenchmarkGCD100x100000 133691 131505 -1.64%
BenchmarkGCD1000x1000 120041 95591 -20.37%
BenchmarkGCD1000x10000 136887 113600 -17.01%
BenchmarkGCD1000x100000 295370 273912 -7.26%
BenchmarkGCD10000x10000 2556126 2205198 -13.73%
BenchmarkGCD10000x100000 3159512 2808038 -11.12%
BenchmarkGCD100000x100000 150543094 139986045 -7.01%
R=gri, remyoudompheng
CC=bradfitz, gobot, golang-dev, gri
https://golang.org/cl/9424043
This is needed for preemptive scheduler,
it will preempt only when m->locks==0,
and we do not want to be preempted while
we have not completely unlocked the lock.
R=golang-dev, khr, iant
CC=golang-dev
https://golang.org/cl/9196047
Also change table type from int32[] to int8[] to save space in L1$.
benchmark old ns/op new ns/op delta
BenchmarkMalloc 42 40 -4.68%
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9199044
Trying to lookup user's display name with directory services can
take several seconds when user's computer is not in a domain.
As a workaround, check if computer is joined in a domain first,
and don't use directory services if it is not.
Additionally, don't leak tokens in user.Current().
Fixes#5298.
R=golang-dev, bradfitz, alex.brainman, lucio.dere
CC=golang-dev
https://golang.org/cl/8541047
The *Encoder is almost always garbage. It doesn't need an
encodeState inside of it (and its bytes.Buffer), since it's
only needed locally inside of Encode.
benchmark old ns/op new ns/op delta
BenchmarkEncoderEncode 2562 2553 -0.35%
benchmark old bytes new bytes delta
BenchmarkEncoderEncode 283 102 -63.96%
R=r
CC=gobot, golang-dev
https://golang.org/cl/9365044
Move the documentation from race.go to doc.go, because
race.go uses +build race, so it's not normally parsed by go doc.
Rephrase the documentation for end users, provide link to race
detector manual.
Fixes#5444.
R=golang-dev, minux.ma, adg, r
CC=golang-dev
https://golang.org/cl/9144050
runtime.park() can access freed select descriptor
due to a racing free in another thread.
See the comment for details.
Slightly modified version of dvyukov's CL 9259045.
No test yet. Before this CL, the test described in issue 5422
would fail about every 40 times for me. With this CL, I ran
the test 5900 times with no failures.
Fixes#5422.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9311043
The linker can generate split stack prolog when a textflag 7 function
makes an indirect function call. If it happens, badsignal() crashes
trying to dereference g.
Fixes#5337.
R=bradfitz, dave, adg, iant, r, minux.ma
CC=adonovan, golang-dev
https://golang.org/cl/9226043
This must have been from when "error" was a good variable
name for an "os.Error". But we use "err" these days.
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/9132045
Include libc.h before bio.h in 8.c, because bio.h uses
the UTFmax enum, which is declared in libc.h, since
the recent switch to 21-bit runes in Plan 9.
The 5.c and 6.c files already includes libc.h.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9040047
This is needed for SWIG when linking in internal mode. In
internal mode if a symbol was cgo_import_static we used to
forget that it was also cgo_import_dynamic.
R=rsc, r
CC=golang-dev
https://golang.org/cl/9080043
Manual undo due to later changes in doc/go1.1.html; cmd/go/test.bash still passes.
Rationale, from CL 8119049 review log:
This makes the 'go run' command different from every other command.
For example, 'go test' does not mean 'go test *.go'.
If we were going to handle the no arguments case in 'go run', I would hope that
it would scan the current directory to find a package just like 'go build' or
'go test' would, and then it would require that package to be 'package main',
and then it would run that package. This would make it match 'go test' and 'go
build' and 'go install' and so on. It would mean that if you are working on a
command in a directory that is 'go install'able, then 'go run' will run the
binary for you. The current CL does not accomplish that when build constraints
or file name constraints are involved.
For example, if I am working on a program like:
$ ls
main.go
main_386.s
main_arm.s
main_amd64.s
$
Then 'go run' will fail here because the .s files are ignored.
If instead I am working on a program like:
$ ls
main.go
main_386.go
main_arm.go
main_amd64.go
$
then 'go run' will fail because too many files are included.
I would like to see this command implemented so that it is compatible with the
other go subcommands. Since it is too late to do that for Go 1.1, I would like
to see this CL reverted, to preserve the option to do it better later.
R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/8797049
I would like opinions on whether this is a good idea for 1.1.
On the one hand it's a moderately important issue. On the
other hand this introduces at least the possibility of
external linker errors due to the additional relocations and
it may be better to wait.
I'm fairly confident that the behaviour is unchanged when not
using an external linker.
Update #5221
This CL is tested lightly on 386 and amd64 and fixes the cases
I tested. I have not tested it on Darwin or Windows.
R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/8858047
PC-relative needs a signed offset; others need unsigned.
Also fix signedness of 32-bit relocation on Windows.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9039045