]> Cypherpunks repositories - gostls13.git/log
gostls13.git
11 years agoA+C: Case Nelson (individual CLA)
Brad Fitzpatrick [Sun, 2 Feb 2014 11:51:22 +0000 (12:51 +0100)]
A+C: Case Nelson (individual CLA)

Generated by addca.

TBR=iant
R=gobot
CC=golang-codereviews
https://golang.org/cl/59430043

11 years agoA+C: Adrien Bustany (individual CLA)
Brad Fitzpatrick [Sun, 2 Feb 2014 11:49:59 +0000 (12:49 +0100)]
A+C: Adrien Bustany (individual CLA)

Generated by addca.

TBR=iant
R=gobot
CC=golang-codereviews
https://golang.org/cl/59420043

11 years agotime: use an alternative method of yielding during Overflow timer test
Dave Cheney [Sun, 2 Feb 2014 05:05:07 +0000 (16:05 +1100)]
time: use an alternative method of yielding during Overflow timer test

Fixes #6874.

Use runtime.GC() as a stronger version of runtime.Gosched() which tends to bias the running goroutine in an otherwise idle system. This appears to reduce the worst case number of spins from 600 down to 30 on my 2 core system under high load.

LGTM=iant
R=golang-codereviews, lucio.dere, iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/56540046

11 years agotime: use names for beginning and end of zone transition times
Ian Lance Taylor [Sat, 1 Feb 2014 01:22:10 +0000 (17:22 -0800)]
time: use names for beginning and end of zone transition times

No functional changes, just more readable code.

LGTM=r
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/59240043

11 years agounicode: delete appearance of unused LowerUpper term from comment
Rob Pike [Fri, 31 Jan 2014 23:10:18 +0000 (15:10 -0800)]
unicode: delete appearance of unused LowerUpper term from comment
If a LowerUpper ever happens, maketables will complain.

Fixes #7002.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/59210044

11 years agotime: correctly handle timezone before first transition time
Ian Lance Taylor [Fri, 31 Jan 2014 22:40:13 +0000 (14:40 -0800)]
time: correctly handle timezone before first transition time

LGTM=r
R=golang-codereviews, r, arnehormann, bradfitz
CC=golang-codereviews
https://golang.org/cl/58450043

11 years agoruntime: fix typos in test
Dmitriy Vyukov [Fri, 31 Jan 2014 14:09:53 +0000 (18:09 +0400)]
runtime: fix typos in test
I don't know what is n, but it exists somewhere there.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/58710043

11 years agosyscall: add ERROR_MORE_DATA to Windows for os/fsnotify
Nathan John Youngman [Fri, 31 Jan 2014 06:43:46 +0000 (17:43 +1100)]
syscall: add ERROR_MORE_DATA to Windows for os/fsnotify

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=dave, golang-codereviews
https://golang.org/cl/58900044

11 years agocrypto/rand: add tests for Int, Prime
Shawn Smith [Fri, 31 Jan 2014 00:43:48 +0000 (11:43 +1100)]
crypto/rand: add tests for Int, Prime

LGTM=rsc, dave
R=golang-codereviews, dave, josharian, rsc
CC=golang-codereviews
https://golang.org/cl/46490043

11 years agocmd/gc: do not consider length zero arrays as comparable.
Rémy Oudompheng [Thu, 30 Jan 2014 23:30:56 +0000 (00:30 +0100)]
cmd/gc: do not consider length zero arrays as comparable.

Array values are comparable if values of the array element type
are comparable.

Fixes #6526.

LGTM=khr
R=rsc, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/58580043

11 years agocmd/ld: fix bug with "runtime/cgo" in external link mode
Ian Lance Taylor [Thu, 30 Jan 2014 17:25:47 +0000 (09:25 -0800)]
cmd/ld: fix bug with "runtime/cgo" in external link mode

In external link mode the linker explicitly adds the string
constant "runtime/cgo".  It adds the string constant using the
same symbol name as the compiler, but a different format.  The
compiler assumes that the string data immediately follows the
string header, but the linker puts the two in different
sections.  The result is bad string data when the compiler
sees "runtime/cgo" used as a string constant.

The compiler assumption is in datastring in [568]g/gobj.c.
The linker layout is in addstrdata in ld/data.c.  The compiler
assumption is valid for string literals.  The linker is not
creating a string literal, so its assumption is also valid.

There are a few ways to avoid this problem.  This patch fixes
it by only doing the fake import of runtime/cgo if necessary,
and by only creating the string symbol if necessary.

Fixes #7234.

LGTM=dvyukov
R=golang-codereviews, dvyukov, bradfitz
CC=golang-codereviews
https://golang.org/cl/58410043

11 years agonet/http: temporarily disable the failing tests on Plan 9
David du Colombier [Thu, 30 Jan 2014 10:12:08 +0000 (11:12 +0100)]
net/http: temporarily disable the failing tests on Plan 9

Update #7237

LGTM=bradfitz
R=jas, bradfitz
CC=golang-codereviews
https://golang.org/cl/57190045

11 years agoruntime: increase page size to 8K
Dmitriy Vyukov [Thu, 30 Jan 2014 09:28:19 +0000 (13:28 +0400)]
runtime: increase page size to 8K
Tcmalloc uses 8K, 32K and 64K pages, and in custom setups 256K pages.
Only Chromium uses 4K pages today (in "slow but small" configuration).
The general tendency is to increase page size, because it reduces
metadata size and DTLB pressure.
This change reduces GC pause by ~10% and slightly improves other metrics.

json-1
allocated                 8037492      8038689      +0.01%
allocs                     105762       105573      -0.18%
cputime                 158400000    155800000      -1.64%
gc-pause-one              4412234      4135702      -6.27%
gc-pause-total            2647340      2398707      -9.39%
rss                      54923264     54525952      -0.72%
sys-gc                    3952624      3928048      -0.62%
sys-heap                 46399488     46006272      -0.85%
sys-other                 5597504      5290304      -5.49%
sys-stack                  393216       393216      +0.00%
sys-total                56342832     55617840      -1.29%
time                    158478890    156046916      -1.53%
virtual-mem             256548864    256593920      +0.02%

garbage-1
allocated                 2991113      2986259      -0.16%
allocs                      62844        62652      -0.31%
cputime                  16330000     15860000      -2.88%
gc-pause-one            789108229    725555211      -8.05%
gc-pause-total            3945541      3627776      -8.05%
rss                    1143660544   1132253184      -1.00%
sys-gc                   65609600     65806208      +0.30%
sys-heap               1032388608   1035599872      +0.31%
sys-other                37501632     22777664     -39.26%
sys-stack                 8650752      8781824      +1.52%
sys-total              1144150592   1132965568      -0.98%
time                     16364602     15891994      -2.89%
virtual-mem            1327296512   1313746944      -1.02%

This is the exact reincarnation of already LGTMed:
https://golang.org/cl/45770044
which must not break darwin/freebsd after:
https://golang.org/cl/56630043
TBR=iant

LGTM=khr, iant
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/58230043

11 years agonet/http: use a struct instead of a string in transport conn cache key
Brad Fitzpatrick [Thu, 30 Jan 2014 08:57:04 +0000 (09:57 +0100)]
net/http: use a struct instead of a string in transport conn cache key

The Transport's idle connection cache is keyed by a string,
for pre-Go 1.0 reasons.  Ever since Go has been able to use
structs as map keys, there's been a TODO in the code to use
structs instead of allocating strings. This change does that.

Saves 3 allocatins and ~100 bytes of garbage per client
request. But because string hashing is so fast these days
(thanks, Keith), the performance is a wash: what we gain
on GC and not allocating, we lose in slower hashing. (hashing
structs of strings is slower than 1 string)

This seems a bit faster usually, but I've also seen it be a
bit slower. But at least it's how I've wanted it now, and it
the allocation improvements are consistent.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/58260043

11 years agoencoding/gob: fix two crashes on corrupted data.
Rémy Oudompheng [Thu, 30 Jan 2014 06:54:57 +0000 (07:54 +0100)]
encoding/gob: fix two crashes on corrupted data.

Fixes #6323.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/56870043

11 years agonet: net: better IPv4 stack probe on Plan 9
Jeff Sickel [Thu, 30 Jan 2014 00:49:32 +0000 (09:49 +0900)]
net: net: better IPv4 stack probe on Plan 9

LGTM=mischief, mikioh.mikioh
R=golang-codereviews, 0intro, mischief, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/53960044

11 years agocmd/8g: don't crash if Prog->u.branch is nil
Rob Pike [Thu, 30 Jan 2014 00:14:45 +0000 (16:14 -0800)]
cmd/8g: don't crash if Prog->u.branch is nil
The code is copied from cmd/6g.
Empirically, all branch targets are nil in this code so
something is still wrong, but at least this stops 8g -S
from crashing.

Update #7178

LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/58400043

11 years agoruntime: prepare for 8K pages
Dmitriy Vyukov [Wed, 29 Jan 2014 14:18:46 +0000 (18:18 +0400)]
runtime: prepare for 8K pages
Ensure than heap is PageSize aligned.

LGTM=iant
R=iant, dave, gobot
CC=golang-codereviews
https://golang.org/cl/56630043

11 years agonet/http: read as much as possible (including EOF) during chunked reads
Brad Fitzpatrick [Wed, 29 Jan 2014 12:44:21 +0000 (13:44 +0100)]
net/http: read as much as possible (including EOF) during chunked reads

This is the chunked half of https://golang.org/cl/49570044 .

We want full reads to return EOF as early as possible, when we
know we're at the end, so http.Transport client connections are eagerly
re-used in the common case, even if no Read or Close follows.

To do this, make the chunkedReader.Read fill up its argument p []byte
buffer as much as possible, as long as that doesn't involve doing
any more blocking reads to read chunk headers. That means if we
have a chunk EOF ("0\r\n") sitting in the incoming bufio.Reader,
we see it and set EOF on our final Read.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/58240043

11 years agonet/http: reuse client connections earlier when Content-Length is set
Brad Fitzpatrick [Wed, 29 Jan 2014 10:23:45 +0000 (11:23 +0100)]
net/http: reuse client connections earlier when Content-Length is set

Set EOF on the final Read of a body with a Content-Length, which
will cause clients to recycle their connection immediately upon
the final Read, rather than waiting for another Read or Close
(neither of which might come).  This happens often when client
code is simply something like:

  err := json.NewDecoder(resp.Body).Decode(&dest)
  ...

Then there's usually no subsequent Read. Even if the client
calls Close (which they should): in Go 1.1, the body was
slurped to EOF, but in Go 1.2, that was then treated as a
Close-before-EOF and the underlying connection was closed.
But that's assuming the user even calls Close. Many don't.
Reading to EOF also causes a connection be reused. Now the EOF
arrives earlier.

This CL only addresses the Content-Length case. A future CL
will address the chunked case.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/49570044

11 years agotest: skip SIGCHLD test on Plan 9
David du Colombier [Wed, 29 Jan 2014 08:28:23 +0000 (09:28 +0100)]
test: skip SIGCHLD test on Plan 9

LGTM=bradfitz
R=jas, mikioh.mikioh, bradfitz
CC=golang-codereviews
https://golang.org/cl/51200045

11 years agonet: fix incoming connection's network name handling on unix networks
Mikio Hara [Wed, 29 Jan 2014 00:51:31 +0000 (09:51 +0900)]
net: fix incoming connection's network name handling on unix networks

Fixes #7183.

LGTM=iant
R=golang-codereviews, gobot, iant
CC=golang-codereviews
https://golang.org/cl/57520043

11 years agoencoding/asn1: support set tag when unmarshaling.
Adam Langley [Tue, 28 Jan 2014 19:12:25 +0000 (14:12 -0500)]
encoding/asn1: support set tag when unmarshaling.

This change also addresses some places where the comments were lacking.

Fixes #7087.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/56700043

11 years agoruntime: more chan tests
Dmitriy Vyukov [Tue, 28 Jan 2014 18:45:14 +0000 (22:45 +0400)]
runtime: more chan tests

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/57390043

11 years agoruntime: prefetch next block in mallocgc
Dmitriy Vyukov [Tue, 28 Jan 2014 18:38:39 +0000 (22:38 +0400)]
runtime: prefetch next block in mallocgc

json-1
cputime                  99600000     98600000      -1.00%
time                    100005493     98859693      -1.15%

garbage-1
cputime                  15760000     15440000      -2.03%
time                     15791759     15471701      -2.03%

LGTM=khr
R=golang-codereviews, gobot, khr, dave
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/57310043

11 years agoruntime: fix buffer overflow in make(chan)
Dmitriy Vyukov [Tue, 28 Jan 2014 18:37:35 +0000 (22:37 +0400)]
runtime: fix buffer overflow in make(chan)
On 32-bits one can arrange make(chan) params so that
the chan buffer gives you access to whole memory.

LGTM=r
R=golang-codereviews, r
CC=bradfitz, golang-codereviews, iant, khr
https://golang.org/cl/50250045

11 years agoruntime: adjust malloc race instrumentation for tiny allocs
Dmitriy Vyukov [Tue, 28 Jan 2014 18:34:32 +0000 (22:34 +0400)]
runtime: adjust malloc race instrumentation for tiny allocs
Tiny alloc memory block is shared by different goroutines running on the same thread.
We call racemalloc after enabling preemption in mallocgc,
as the result another goroutine can act on not yet race-cleared tiny block.
Call racemalloc before enabling preemption.
Fixes #7224.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/57730043

11 years agonet: make it possible to use FilePacketConn with IPConn
Mikio Hara [Tue, 28 Jan 2014 11:18:27 +0000 (03:18 -0800)]
net: make it possible to use FilePacketConn with IPConn

Fixes #6803.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/57560043

11 years agoio: clarify MultiReader documentation
Andrew Gerrand [Tue, 28 Jan 2014 08:49:29 +0000 (19:49 +1100)]
io: clarify MultiReader documentation

Fixes #7216.

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/54740044

11 years agocmd/go: When linking with gccgo pass .a files in the order they are discovered
Michael Hudson-Doyle [Tue, 28 Jan 2014 05:47:09 +0000 (16:47 +1100)]
cmd/go: When linking with gccgo pass .a files in the order they are discovered

Under some circumstances linking a test binary with gccgo can fail, because
the installed version of the library ends up before the version built for the
test on the linker command line.

This admittedly slightly hackish fix fixes this by putting the library archives
on the linker command line in the order that a pre-order depth first traversal
of the dependencies gives them, which has the side effect of always putting the
version of the library built for the test first.

Fixes #6768

LGTM=rsc
R=golang-codereviews, minux.ma, gobot, rsc, dave
CC=golang-codereviews
https://golang.org/cl/28050043

11 years agobuild: fix typos in run.rc
David du Colombier [Tue, 28 Jan 2014 05:17:38 +0000 (06:17 +0100)]
build: fix typos in run.rc

LGTM=bradfitz
R=jas, bradfitz
CC=golang-codereviews
https://golang.org/cl/52940044

11 years agocmd/gc: liveness: don't add fallthough edge after panic
Keith Randall [Tue, 28 Jan 2014 02:04:34 +0000 (18:04 -0800)]
cmd/gc: liveness: don't add fallthough edge after panic

update #7205

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/50730044

11 years agohttputil: in ReverseProxy, strip hop-by-hop headers from the backend response
Fredrik Enestad [Mon, 27 Jan 2014 23:24:58 +0000 (15:24 -0800)]
httputil: in ReverseProxy, strip hop-by-hop headers from the backend response

Fixes #5967.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/57370043

11 years agoA+C: Fredrik Enestad (individual CLA)
Brad Fitzpatrick [Mon, 27 Jan 2014 23:24:40 +0000 (15:24 -0800)]
A+C: Fredrik Enestad (individual CLA)

Generated by addca.

TBR=gobot
R=gobot
CC=golang-codereviews
https://golang.org/cl/57420043

11 years agoruntime/debug: fix incorrect Stack output if package path contains a dot
Vincent Vanackere [Mon, 27 Jan 2014 22:00:00 +0000 (14:00 -0800)]
runtime/debug: fix incorrect Stack output if package path contains a dot

Although debug.Stack is deprecated, it should still return the correct result.
Output before this CL (using a trivial library in $GOPATH/test.com/a):
/home/vince/src/test.com/a/lib.go:9 (0x42311e)
        com/a.ShowStack: os.Stdout.Write(debug.Stack())

Output with this CL applied:
/home/vince/src/test.com/a/lib.go:9 (0x42311e)
        ShowStack: os.Stdout.Write(debug.Stack())

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/57330043

11 years agoruntime: fix windows build
Dmitriy Vyukov [Mon, 27 Jan 2014 20:26:56 +0000 (00:26 +0400)]
runtime: fix windows build
Currently windows crashes because early allocs in schedinit
try to allocate tiny memory blocks, but m->p is not yet setup.
I've considered calling procresize(1) earlier in schedinit,
but this refactoring is better and must fix the issue as well.
Fixes #7218.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/54570045

11 years agoruntime: tune P retake logic
Dmitriy Vyukov [Mon, 27 Jan 2014 19:17:46 +0000 (23:17 +0400)]
runtime: tune P retake logic
When GOMAXPROCS>1 the last P in syscall is never retaken
(because there are already idle P's -- npidle>0).
This prevents sysmon thread from sleeping.
On a darwin machine the program from issue 6673 constantly
consumes ~0.2% CPU. With this change it stably consumes 0.0% CPU.
Fixes #6673.

R=golang-codereviews, r
CC=bradfitz, golang-codereviews, iant, khr
https://golang.org/cl/56990045

11 years agocmd/6a: include MOVQL opcode.
Keith Randall [Mon, 27 Jan 2014 19:17:12 +0000 (11:17 -0800)]
cmd/6a: include MOVQL opcode.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/54660046

11 years agoall: use {bytes,strings}.NewReader instead of bytes.Buffers
Brad Fitzpatrick [Mon, 27 Jan 2014 19:05:01 +0000 (11:05 -0800)]
all: use {bytes,strings}.NewReader instead of bytes.Buffers

Use the smaller read-only bytes.NewReader/strings.NewReader instead
of a bytes.Buffer when possible.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/54660045

11 years agodebug/dwarf, debug/elf: add support for reading DWARF 4 type info
Ian Lance Taylor [Mon, 27 Jan 2014 18:18:22 +0000 (10:18 -0800)]
debug/dwarf, debug/elf: add support for reading DWARF 4 type info

In DWARF 4 the debug info for large types is put into
.debug_type sections, so that the linker can discard duplicate
info.  This change adds support for reading type units.

Another small change included here is that DWARF 3 supports
storing the byte offset of a struct field as a formData rather
than a formDwarfBlock.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/56300043

11 years agoruntime: fix buffer overflow in stringtoslicerune
Dmitriy Vyukov [Mon, 27 Jan 2014 16:29:21 +0000 (20:29 +0400)]
runtime: fix buffer overflow in stringtoslicerune
On 32-bits n*sizeof(r[0]) can overflow.
Or it can become 1<<32-eps, and mallocgc will "successfully"
allocate 0 pages for it, there are no checks downstream
and MHeap_Grow just does:
npage = (npage+15)&~15;
ask = npage<<PageShift;

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/54760045

11 years agoruntime: smarter slice grow
Dmitriy Vyukov [Mon, 27 Jan 2014 11:11:12 +0000 (15:11 +0400)]
runtime: smarter slice grow
When growing slice take into account size of the allocated memory block.
Also apply the same optimization to string->[]byte conversion.
Fixes #6307.

benchmark                    old ns/op    new ns/op    delta
BenchmarkAppendGrowByte        4541036      4434108   -2.35%
BenchmarkAppendGrowString     59885673     44813604  -25.17%

LGTM=khr
R=khr
CC=golang-codereviews, iant, rsc
https://golang.org/cl/53340044

11 years agotime: increase timeout of TestOverflowRuntimeTimer on Plan 9
David du Colombier [Mon, 27 Jan 2014 10:11:44 +0000 (11:11 +0100)]
time: increase timeout of TestOverflowRuntimeTimer on Plan 9

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/53000043

11 years agoruntime/pprof: plan9 fails the TestGoroutineSwitch, skip for now.
Jeff Sickel [Sat, 25 Jan 2014 18:09:08 +0000 (10:09 -0800)]
runtime/pprof: plan9 fails the TestGoroutineSwitch, skip for now.

LGTM=r
R=golang-codereviews, 0intro, r
CC=golang-codereviews
https://golang.org/cl/55430043

11 years agosync: support Pool under race detector
Dmitriy Vyukov [Sat, 25 Jan 2014 16:11:16 +0000 (20:11 +0400)]
sync: support Pool under race detector
Fixes #7203.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/53020044

11 years agoruntime: combine small NoScan allocations
Dmitriy Vyukov [Fri, 24 Jan 2014 18:35:11 +0000 (22:35 +0400)]
runtime: combine small NoScan allocations
Combine NoScan allocations < 16 bytes into a single memory block.
Reduces number of allocations on json/garbage benchmarks by 10+%.

json-1
allocated                 8039872      7949194      -1.13%
allocs                     105774        93776     -11.34%
cputime                 156200000    100700000     -35.53%
gc-pause-one              4908873      3814853     -22.29%
gc-pause-total            2748969      2899288      +5.47%
rss                      52674560     43560960     -17.30%
sys-gc                    3796976      3256304     -14.24%
sys-heap                 43843584     35192832     -19.73%
sys-other                 5589312      5310784      -4.98%
sys-stack                  393216       393216      +0.00%
sys-total                53623088     44153136     -17.66%
time                    156193436    100886714     -35.41%
virtual-mem             256548864    256540672      -0.00%

garbage-1
allocated                 2996885      2932982      -2.13%
allocs                      62904        55200     -12.25%
cputime                  17470000     17400000      -0.40%
gc-pause-one            932757485    925806143      -0.75%
gc-pause-total            4663787      4629030      -0.75%
rss                    1151074304   1133670400      -1.51%
sys-gc                   66068352     65085312      -1.49%
sys-heap               1039728640   1024065536      -1.51%
sys-other                38038208     37485248      -1.45%
sys-stack                 8650752      8781824      +1.52%
sys-total              1152485952   1135417920      -1.48%
time                     17478088     17418005      -0.34%
virtual-mem            1343709184   1324204032      -1.45%

LGTM=iant, bradfitz
R=golang-codereviews, dave, iant, rsc, bradfitz
CC=golang-codereviews, khr
https://golang.org/cl/38750047

11 years agosync: scalable Pool
Dmitriy Vyukov [Fri, 24 Jan 2014 18:29:53 +0000 (22:29 +0400)]
sync: scalable Pool
Introduce fixed-size P-local caches.
When local caches overflow/underflow a batch of items
is transferred to/from global mutex-protected cache.

benchmark                    old ns/op    new ns/op    delta
BenchmarkPool                    50554        22423  -55.65%
BenchmarkPool-4                 400359         5904  -98.53%
BenchmarkPool-16                403311         1598  -99.60%
BenchmarkPool-32                367310         1526  -99.58%

BenchmarkPoolOverlflow            5214         3633  -30.32%
BenchmarkPoolOverlflow-4         42663         9539  -77.64%
BenchmarkPoolOverlflow-8         46919        11385  -75.73%
BenchmarkPoolOverlflow-16        39454        13048  -66.93%

BenchmarkSprintfEmpty                    84           63  -25.68%
BenchmarkSprintfEmpty-2                 371           32  -91.13%
BenchmarkSprintfEmpty-4                 465           22  -95.25%
BenchmarkSprintfEmpty-8                 565           12  -97.77%
BenchmarkSprintfEmpty-16                498            5  -98.87%
BenchmarkSprintfEmpty-32                492            4  -99.04%

BenchmarkSprintfString                  259          229  -11.58%
BenchmarkSprintfString-2                574          144  -74.91%
BenchmarkSprintfString-4                651           77  -88.05%
BenchmarkSprintfString-8                868           47  -94.48%
BenchmarkSprintfString-16               825           33  -95.96%
BenchmarkSprintfString-32               825           30  -96.28%

BenchmarkSprintfInt                     213          188  -11.74%
BenchmarkSprintfInt-2                   448          138  -69.20%
BenchmarkSprintfInt-4                   624           52  -91.63%
BenchmarkSprintfInt-8                   691           31  -95.43%
BenchmarkSprintfInt-16                  724           18  -97.46%
BenchmarkSprintfInt-32                  718           16  -97.70%

BenchmarkSprintfIntInt                  311          282   -9.32%
BenchmarkSprintfIntInt-2                333          145  -56.46%
BenchmarkSprintfIntInt-4                642          110  -82.87%
BenchmarkSprintfIntInt-8                832           42  -94.90%
BenchmarkSprintfIntInt-16               817           24  -97.00%
BenchmarkSprintfIntInt-32               805           22  -97.17%

BenchmarkSprintfPrefixedInt             309          269  -12.94%
BenchmarkSprintfPrefixedInt-2           245          168  -31.43%
BenchmarkSprintfPrefixedInt-4           598           99  -83.36%
BenchmarkSprintfPrefixedInt-8           770           67  -91.23%
BenchmarkSprintfPrefixedInt-16          829           54  -93.49%
BenchmarkSprintfPrefixedInt-32          824           50  -93.83%

BenchmarkSprintfFloat                   418          398   -4.78%
BenchmarkSprintfFloat-2                 295          203  -31.19%
BenchmarkSprintfFloat-4                 585          128  -78.12%
BenchmarkSprintfFloat-8                 873           60  -93.13%
BenchmarkSprintfFloat-16                884           33  -96.24%
BenchmarkSprintfFloat-32                881           29  -96.62%

BenchmarkManyArgs                      1097         1069   -2.55%
BenchmarkManyArgs-2                     705          567  -19.57%
BenchmarkManyArgs-4                     792          319  -59.72%
BenchmarkManyArgs-8                     963          172  -82.14%
BenchmarkManyArgs-16                   1115          103  -90.76%
BenchmarkManyArgs-32                   1133           90  -92.03%

LGTM=rsc
R=golang-codereviews, bradfitz, minux.ma, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/46010043

11 years agoruntime: do not zero terminate strings
Dmitriy Vyukov [Fri, 24 Jan 2014 18:29:01 +0000 (22:29 +0400)]
runtime: do not zero terminate strings
On top of "tiny allocator" (cl/38750047), reduces number of allocs by 1% on json.
No code must rely on zero termination. So will also make debugging simpler,
by uncovering issues earlier.

json-1
allocated                 7949686      7915766      -0.43%
allocs                      93778        92790      -1.05%
time                    100957795     97250949      -3.67%
rest of the metrics are too noisy.

LGTM=r
R=golang-codereviews, r, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/40370061

11 years agocmd/gc: add zeroing to enable precise stack accounting
Russ Cox [Fri, 24 Jan 2014 04:11:04 +0000 (23:11 -0500)]
cmd/gc: add zeroing to enable precise stack accounting

There is more zeroing than I would like right now -
temporaries used for the new map and channel runtime
calls need to be eliminated - but it will do for now.

This CL only has an effect if you are building with

        GOEXPERIMENT=precisestack ./all.bash

(or make.bash). It costs about 5% in the overall time
spent in all.bash. That number will come down before
we make it on by default, but this should be enough for
Keith to try using the precise maps for copying stacks.

amd64 only (and it's not really great generated code).

TBR=khr, iant
CC=golang-codereviews
https://golang.org/cl/56430043

11 years agoliblink, runtime: fix cgo on arm
Russ Cox [Fri, 24 Jan 2014 03:51:39 +0000 (22:51 -0500)]
liblink, runtime: fix cgo on arm

The addition of TLS to ARM rewrote the MRC instruction
differently depending on whether we were using internal
or external linking mode. That's clearly not okay, since we
don't know that during compilation, which is when we now
generate the code. Also, because the change did not introduce
a real MRC instruction but instead just macro-expanded it
in the assembler, liblink is rewriting a WORD instruction that
may actually be looking for that specific constant, which would
lead to very unexpected results. It was also using one value
that happened to be 8 where a different value that also
happened to be 8 belonged. So the code was correct for those
values but not correct in general, and very confusing.

Throw it all away.

Replace with the following. There is a linker-provided symbol
runtime.tlsgm with a value (address) set to the offset from the
hardware-provided TLS base register to the g and m storage.
Any reference to that name emits an appropriate TLS relocation
to be resolved by either the internal linker or the external linker,
depending on the link mode. The relocation has exactly the
semantics of the R_ARM_TLS_LE32 relocation, which is what
the external linker provides.

This symbol is only used in two routines, runtime.load_gm and
runtime.save_gm. In both cases it is now used like this:

        MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer
        MOVW $runtime·tlsgm(SB), R2
        ADD R2, R0 // now R0 points at thread-local g+m storage

It is likely that this change breaks the generation of shared libraries
on ARM, because the MOVW needs to be rewritten to use the global
offset table and a different relocation type. But let's get the supported
functionality working again before we worry about unsupported
functionality.

LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/56120043

11 years agoeffective_go: move 'Type switch' section into 'Control structures' section.
Rob Pike [Fri, 24 Jan 2014 00:26:42 +0000 (16:26 -0800)]
effective_go: move 'Type switch' section into 'Control structures' section.
Needs to be an h3, not an h2.
Thanks to Mingjie Xing for pointing it out.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/55980046

11 years agoruntime: Print elision message if we skipped frames on traceback.
Keith Randall [Thu, 23 Jan 2014 20:47:30 +0000 (12:47 -0800)]
runtime: Print elision message if we skipped frames on traceback.

Fixes bug 7180

R=golang-codereviews, dvyukov
CC=golang-codereviews, gri
https://golang.org/cl/55810044

11 years agobufio: fix benchmarks behavior
Dmitriy Vyukov [Thu, 23 Jan 2014 20:13:21 +0000 (15:13 -0500)]
bufio: fix benchmarks behavior
Currently the benchmarks lie to testing package by doing O(N)
work under StopTimer. And that hidden O(N) actually consitutes
the bulk of benchmark work (e.g includes GC per iteration).
This behavior accounts for windows-amd64-race builder hangs.

Before:
BenchmarkReaderCopyOptimal-4  1000000       1861 ns/op
BenchmarkReaderCopyUnoptimal-4   500000       3327 ns/op
BenchmarkReaderCopyNoWriteTo-4    50000      34549 ns/op
BenchmarkWriterCopyOptimal-4   100000      16849 ns/op
BenchmarkWriterCopyUnoptimal-4   500000       3126 ns/op
BenchmarkWriterCopyNoReadFrom-4    50000      34609 ns/op
ok   bufio 65.273s

After:
BenchmarkReaderCopyOptimal-4 10000000        172 ns/op
BenchmarkReaderCopyUnoptimal-4 10000000        267 ns/op
BenchmarkReaderCopyNoWriteTo-4   100000      22905 ns/op
BenchmarkWriterCopyOptimal-4 10000000        170 ns/op
BenchmarkWriterCopyUnoptimal-4 10000000        226 ns/op
BenchmarkWriterCopyNoReadFrom-4   100000      20575 ns/op
ok   bufio 14.074s

Note the change in total time.

LGTM=alex.brainman, rsc
R=golang-codereviews, alex.brainman, rsc
CC=golang-codereviews
https://golang.org/cl/51360046

11 years agolib/codereview: add LGTM= line to commit messages
Russ Cox [Thu, 23 Jan 2014 20:10:38 +0000 (15:10 -0500)]
lib/codereview: add LGTM= line to commit messages

The R= is populated by Rietveld, so it's basically
anyone who replied to the CL. The LGTM= is meant
to record who actually signed off on the CL.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/55390043

11 years agoundo CL 45770044 / d795425bfa18
Dmitriy Vyukov [Thu, 23 Jan 2014 15:56:59 +0000 (19:56 +0400)]
undo CL 45770044 / d795425bfa18

Breaks darwin and freebsd.

««« original CL description
runtime: increase page size to 8K
Tcmalloc uses 8K, 32K and 64K pages, and in custom setups 256K pages.
Only Chromium uses 4K pages today (in "slow but small" configuration).
The general tendency is to increase page size, because it reduces
metadata size and DTLB pressure.
This change reduces GC pause by ~10% and slightly improves other metrics.

json-1
allocated                 8037492      8038689      +0.01%
allocs                     105762       105573      -0.18%
cputime                 158400000    155800000      -1.64%
gc-pause-one              4412234      4135702      -6.27%
gc-pause-total            2647340      2398707      -9.39%
rss                      54923264     54525952      -0.72%
sys-gc                    3952624      3928048      -0.62%
sys-heap                 46399488     46006272      -0.85%
sys-other                 5597504      5290304      -5.49%
sys-stack                  393216       393216      +0.00%
sys-total                56342832     55617840      -1.29%
time                    158478890    156046916      -1.53%
virtual-mem             256548864    256593920      +0.02%

garbage-1
allocated                 2991113      2986259      -0.16%
allocs                      62844        62652      -0.31%
cputime                  16330000     15860000      -2.88%
gc-pause-one            789108229    725555211      -8.05%
gc-pause-total            3945541      3627776      -8.05%
rss                    1143660544   1132253184      -1.00%
sys-gc                   65609600     65806208      +0.30%
sys-heap               1032388608   1035599872      +0.31%
sys-other                37501632     22777664     -39.26%
sys-stack                 8650752      8781824      +1.52%
sys-total              1144150592   1132965568      -0.98%
time                     16364602     15891994      -2.89%
virtual-mem            1327296512   1313746944      -1.02%

R=golang-codereviews, dave, khr, rsc, khr
CC=golang-codereviews
https://golang.org/cl/45770044
»»»

R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/56060043

11 years agoruntime: increase page size to 8K
Dmitriy Vyukov [Thu, 23 Jan 2014 14:59:43 +0000 (18:59 +0400)]
runtime: increase page size to 8K
Tcmalloc uses 8K, 32K and 64K pages, and in custom setups 256K pages.
Only Chromium uses 4K pages today (in "slow but small" configuration).
The general tendency is to increase page size, because it reduces
metadata size and DTLB pressure.
This change reduces GC pause by ~10% and slightly improves other metrics.

json-1
allocated                 8037492      8038689      +0.01%
allocs                     105762       105573      -0.18%
cputime                 158400000    155800000      -1.64%
gc-pause-one              4412234      4135702      -6.27%
gc-pause-total            2647340      2398707      -9.39%
rss                      54923264     54525952      -0.72%
sys-gc                    3952624      3928048      -0.62%
sys-heap                 46399488     46006272      -0.85%
sys-other                 5597504      5290304      -5.49%
sys-stack                  393216       393216      +0.00%
sys-total                56342832     55617840      -1.29%
time                    158478890    156046916      -1.53%
virtual-mem             256548864    256593920      +0.02%

garbage-1
allocated                 2991113      2986259      -0.16%
allocs                      62844        62652      -0.31%
cputime                  16330000     15860000      -2.88%
gc-pause-one            789108229    725555211      -8.05%
gc-pause-total            3945541      3627776      -8.05%
rss                    1143660544   1132253184      -1.00%
sys-gc                   65609600     65806208      +0.30%
sys-heap               1032388608   1035599872      +0.31%
sys-other                37501632     22777664     -39.26%
sys-stack                 8650752      8781824      +1.52%
sys-total              1144150592   1132965568      -0.98%
time                     16364602     15891994      -2.89%
virtual-mem            1327296512   1313746944      -1.02%

R=golang-codereviews, dave, khr, rsc, khr
CC=golang-codereviews
https://golang.org/cl/45770044

11 years agocmd/gc: add the word 'archive' to the documentation for -pack
Rob Pike [Wed, 22 Jan 2014 23:55:56 +0000 (15:55 -0800)]
cmd/gc: add the word 'archive' to the documentation for -pack
The term "package file" is unclear.

R=iant, dave
CC=golang-codereviews
https://golang.org/cl/54760044

11 years agocrypto/tls: Client side support for TLS session resumption.
Gautham Thambidorai [Wed, 22 Jan 2014 23:24:03 +0000 (18:24 -0500)]
crypto/tls: Client side support for TLS session resumption.

Adam (agl@) had already done an initial review of this CL in a branch.

Added ClientSessionState to Config which now allows clients to keep state
required to resume a TLS session with a server. A client handshake will try
and use the SessionTicket/MasterSecret in this cached state if the server
acknowledged resumption.

We also added support to cache ClientSessionState object in Config that will
be looked up by server remote address during the handshake.

R=golang-codereviews, agl, rsc, agl, agl, bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/15680043

11 years agodebug/plan9obj: implement parsing of Plan 9 a.out executables
David du Colombier [Wed, 22 Jan 2014 22:30:52 +0000 (23:30 +0100)]
debug/plan9obj: implement parsing of Plan 9 a.out executables

It implements parsing of the header and symbol table for both
32-bit and 64-bit Plan 9 binaries. The nm tool was updated to
use this package.

R=rsc, aram
CC=golang-codereviews
https://golang.org/cl/49970044

11 years agoruntime: fix typo in ARM code
Russ Cox [Wed, 22 Jan 2014 21:39:39 +0000 (16:39 -0500)]
runtime: fix typo in ARM code

The typo was introduced by one of Dmitriy's CLs this morning.
The fix makes the ARM build compile again; it still won't pass
its tests, but one thing at a time.

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/55770044

11 years agotesting: fix SkipNow and FailNow to avoid panic(nil) check
Russ Cox [Wed, 22 Jan 2014 21:34:02 +0000 (16:34 -0500)]
testing: fix SkipNow and FailNow to avoid panic(nil) check

Sorry, too many windows in which to run all.bash.
Fixes build.

TBR=r
CC=golang-codereviews
https://golang.org/cl/55790043

11 years agonet: plan9 changes for default net directory
Jeff Sickel [Wed, 22 Jan 2014 21:21:53 +0000 (22:21 +0100)]
net: plan9 changes for default net directory

This change include updates to the probeIPv4Stack
and probeIPv6Stack to ensure that one or both
protocols are supported by ip(3).
The addition of fdMutex to netFD fixes the
TestTCPConcurrentAccept failures.
Additional changes add support for keepalive.

R=golang-codereviews, 0intro
CC=golang-codereviews, rsc
https://golang.org/cl/49920048

11 years agotesting: diagnose buggy tests that panic(nil)
Russ Cox [Wed, 22 Jan 2014 21:04:50 +0000 (16:04 -0500)]
testing: diagnose buggy tests that panic(nil)

Fixes #6546.

LGTM=dave, bradfitz, r
R=r, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/55780043

11 years agocmd/gc, cmd/ld: fix Plan 9 warnings
David du Colombier [Wed, 22 Jan 2014 20:21:18 +0000 (21:21 +0100)]
cmd/gc, cmd/ld: fix Plan 9 warnings

warning: /usr/go/src/cmd/gc/obj.c:23 format mismatch -10d VLONG, arg 9
warning: /usr/go/src/cmd/gc/plive.c:1680 set and not used: printed
warning: /usr/go/src/cmd/ld/lib.c:332 non-interruptable temporary
warning: /usr/go/src/cmd/ld/lib.c:338 non-interruptable temporary

R=rsc
CC=golang-codereviews
https://golang.org/cl/53820046

11 years agoarchive/tar: add dragonfly build tag
Michael Gehring [Wed, 22 Jan 2014 18:58:38 +0000 (10:58 -0800)]
archive/tar: add dragonfly build tag

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/55720044

11 years agoapi: update next.txt
Brad Fitzpatrick [Wed, 22 Jan 2014 18:54:51 +0000 (10:54 -0800)]
api: update next.txt

Linux Flock_t, Unix FcntlFlock, and various BSD Termios.

R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/55460043

11 years agoapi: add Fchflags exception to more platforms
Brad Fitzpatrick [Wed, 22 Jan 2014 18:48:58 +0000 (10:48 -0800)]
api: add Fchflags exception to more platforms

Unbreaks the build.

R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/53820045

11 years agosyscall: add syscall.Termios on dragonfly, openbsd
Michael Gehring [Wed, 22 Jan 2014 18:39:10 +0000 (10:39 -0800)]
syscall: add syscall.Termios on dragonfly, openbsd

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/55720043

11 years agosyscall: use unsafe.Pointer in BSD kevent
Brad Fitzpatrick [Wed, 22 Jan 2014 18:35:41 +0000 (10:35 -0800)]
syscall: use unsafe.Pointer in BSD kevent

Doesn't really matter for the most part, since the runtime-integrated
network poller uses its own kevent implementation, but for people using
the syscall directly, we should use an unsafe.Pointer for the precise GC
to retain the pointer arguments.

Also push down unsafe.Pointer a bit further in exec_linux.go, not
that there are any GC preemption points in the middle and sys
is still live anyway.

R=golang-codereviews, dvyukov
CC=golang-codereviews, iant
https://golang.org/cl/55520043

11 years agoruntime: fix code formatting
Dmitriy Vyukov [Wed, 22 Jan 2014 09:30:12 +0000 (13:30 +0400)]
runtime: fix code formatting
Place && at the end of line.
Offset expression continuation.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/55380044

11 years agoruntime: remove locks from netpoll hotpaths
Dmitriy Vyukov [Wed, 22 Jan 2014 07:27:16 +0000 (11:27 +0400)]
runtime: remove locks from netpoll hotpaths
Introduces two-phase goroutine parking mechanism -- prepare to park, commit park.
This mechanism does not require backing mutex to protect wait predicate.
Use it in netpoll. See comment in netpoll.goc for details.
This slightly reduces contention between reader, writer and read/write io notifications;
and just eliminates a bunch of mutex operations from hotpaths, thus making then faster.

benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4ConcurrentReadWrite           2109         1945   -7.78%
BenchmarkTCP4ConcurrentReadWrite-2         1162         1113   -4.22%
BenchmarkTCP4ConcurrentReadWrite-4          798          755   -5.39%
BenchmarkTCP4ConcurrentReadWrite-8          803          748   -6.85%
BenchmarkTCP4Persistent                    9411         9240   -1.82%
BenchmarkTCP4Persistent-2                  5888         5813   -1.27%
BenchmarkTCP4Persistent-4                  4016         3968   -1.20%
BenchmarkTCP4Persistent-8                  3943         3857   -2.18%

R=golang-codereviews, mikioh.mikioh, gobot, iant, rsc
CC=golang-codereviews, khr
https://golang.org/cl/45700043

11 years agoruntime/race: race instrument reads/writes in select cases
Dmitriy Vyukov [Wed, 22 Jan 2014 06:36:17 +0000 (10:36 +0400)]
runtime/race: race instrument reads/writes in select cases
The new select tests currently fail (the race is not detected).

R=khr
CC=golang-codereviews
https://golang.org/cl/54220043

11 years agoruntime: allocate goroutine ids in batches
Dmitriy Vyukov [Wed, 22 Jan 2014 06:34:36 +0000 (10:34 +0400)]
runtime: allocate goroutine ids in batches
Helps reduce contention on sched.goidgen.

benchmark                               old ns/op    new ns/op    delta
BenchmarkCreateGoroutines-16                  259          237   -8.49%
BenchmarkCreateGoroutinesParallel-16          127           43  -66.06%

R=golang-codereviews, dave, bradfitz, khr
CC=golang-codereviews, rsc
https://golang.org/cl/46970043

11 years agoruntime: fix and improve CPU profiling
Dmitriy Vyukov [Wed, 22 Jan 2014 06:30:10 +0000 (10:30 +0400)]
runtime: fix and improve CPU profiling

- do not lose profiling signals when we have no mcache (possible for syscalls/cgo)
- do not lose any profiling signals on windows
- fix profiling of cgo programs on windows (they had no m->thread setup)
- properly setup tls in cgo programs on windows
- check _beginthread return value

Fixes #6417.
Fixes #6986.

R=alex.brainman, rsc
CC=golang-codereviews
https://golang.org/cl/44820047

11 years agoliblink: include missing pragmas for plan9 formatter
Jeff Sickel [Wed, 22 Jan 2014 05:23:19 +0000 (06:23 +0100)]
liblink: include missing pragmas for plan9 formatter

R=rsc, r, 0intro
CC=golang-codereviews
https://golang.org/cl/36060047

11 years agocmd/gc: preserve qualified names of unexported methods in imports.
Rémy Oudompheng [Wed, 22 Jan 2014 03:55:50 +0000 (22:55 -0500)]
cmd/gc: preserve qualified names of unexported methods in imports.

Fixes #6295.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/20850043

11 years agocmd/gc: do not typecheck nil types in multiple assignment
Dominik Honnef [Wed, 22 Jan 2014 03:44:54 +0000 (22:44 -0500)]
cmd/gc: do not typecheck nil types in multiple assignment

Fixes #6572.

LGTM=rsc, daniel.morsing, rsc
R=golang-codereviews, bradfitz, minux.ma, iant, rsc, gobot, daniel.morsing
CC=golang-codereviews
https://golang.org/cl/14516055

11 years agosyscall: use unsafe.Pointer instead of uintptr in net syscalls
Brad Fitzpatrick [Wed, 22 Jan 2014 02:54:49 +0000 (18:54 -0800)]
syscall: use unsafe.Pointer instead of uintptr in net syscalls

In particular: setsockopt, getsockopt, bind, connect.

There are probably more.

All platforms cross-compile with make.bash, and all.bash still
pases on linux/amd64.

Update #7169

R=rsc
CC=golang-codereviews
https://golang.org/cl/55410043

11 years agocmd/go: do not require a valid archChar when using -compiler gccgo
Dave Cheney [Wed, 22 Jan 2014 01:19:11 +0000 (12:19 +1100)]
cmd/go: do not require a valid archChar when using -compiler gccgo

Fixes #7152.

R=iant, rsc, gobot
CC=golang-codereviews
https://golang.org/cl/54790044

11 years agoliblink: remove use of linkmode on ARM
Russ Cox [Wed, 22 Jan 2014 00:46:34 +0000 (19:46 -0500)]
liblink: remove use of linkmode on ARM

Now that liblink is compiled into the compilers and assemblers,
it must not refer to the "linkmode", since that is not known until
link time. This CL makes the ARM support no longer use linkmode,
which fixes a bug with cgo binaries that contain their own TLS
variables.

The x86 code must also remove linkmode; that is issue 7164.

Fixes #6992.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/55160043

11 years agomisc/cgo/testtls: make test less flaky
Russ Cox [Wed, 22 Jan 2014 00:44:51 +0000 (19:44 -0500)]
misc/cgo/testtls: make test less flaky

Now it should always fail on ARM.
(The fix is on its way too.)

R=iant, r, dave
CC=golang-codereviews
https://golang.org/cl/55140043

11 years agosyscall: rename method Flock_t.Lock to func FcntlFlock
Brad Fitzpatrick [Wed, 22 Jan 2014 00:27:39 +0000 (16:27 -0800)]
syscall: rename method Flock_t.Lock to func FcntlFlock

Update #7059

R=rsc
CC=golang-codereviews
https://golang.org/cl/55370043

11 years agosyscall: add Flock_t.Lock method
Brad Fitzpatrick [Tue, 21 Jan 2014 22:52:44 +0000 (14:52 -0800)]
syscall: add Flock_t.Lock method

Fixes #7059

R=golang-codereviews, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/53470043

11 years agoruntime: if "panic during panic"'s stacktrace fails, don't recurse.
Keith Randall [Tue, 21 Jan 2014 22:34:37 +0000 (14:34 -0800)]
runtime: if "panic during panic"'s stacktrace fails, don't recurse.

R=golang-codereviews, iant, khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/54160043

11 years agocmd/link: add testdata/pclntab.6 (fix build)
Russ Cox [Tue, 21 Jan 2014 22:12:30 +0000 (17:12 -0500)]
cmd/link: add testdata/pclntab.6 (fix build)

Sorry, "hg status" hides .6 files by default.
We should probably fix that.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/55290043

11 years agocmd/gc: document -pack flag
Ian Lance Taylor [Tue, 21 Jan 2014 19:54:21 +0000 (11:54 -0800)]
cmd/gc: document -pack flag

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/55140044

11 years agocmd/link: pclntab generation
Russ Cox [Tue, 21 Jan 2014 18:47:47 +0000 (13:47 -0500)]
cmd/link: pclntab generation

R=iant
CC=golang-codereviews
https://golang.org/cl/53820043

11 years agocmd/gc: fix build
Russ Cox [Tue, 21 Jan 2014 18:46:14 +0000 (13:46 -0500)]
cmd/gc: fix build

The AKILL stuff is not ready yet and
was not meant to be in the last CL.

R=iant
CC=golang-codereviews
https://golang.org/cl/55170043

11 years agocmd/gc: do not follow uintptr passed as function argument
Russ Cox [Tue, 21 Jan 2014 18:31:34 +0000 (13:31 -0500)]
cmd/gc: do not follow uintptr passed as function argument

The escape analysis works by tracing assignment paths from
variables that start with pointer type, or addresses of variables
(addresses are always pointers).  It does allow non-pointers
in the path, so that in this code it sees x's value escape into y:

        var x *[10]int
        y := (*int)(unsafe.Pointer(uintptr(unsafe.Pointer(x))+32))

It must allow uintptr in order to see through this kind of
"pointer arithmetic".

It also traces such values if they end up as uintptrs passed to
functions. This used to be important because packages like
encoding/gob passed around uintptrs holding real pointers.

The introduction of precise collection of stacks has forced
code to be more honest about which declared stack variables
hold pointers and which do not. In particular, the garbage
collector no longer sees pointers stored in uintptr variables.
Because of this, packages like encoding/gob have been fixed.

There is not much point in the escape analysis accepting
uintptrs as holding pointers at call boundaries if the garbage
collector does not.

Excluding uintptr-valued arguments brings the escape
analysis in line with the garbage collector and has the
useful side effect of making arguments to syscall.Syscall
not appear to escape.

That is, this CL should yield the same benefits as
CL 45930043 (rolled back in CL 53870043), but it does
so by making uintptrs less special, not more.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53940043

11 years agocmd/gc: fix crash in -live debugging output
Russ Cox [Tue, 21 Jan 2014 18:31:22 +0000 (13:31 -0500)]
cmd/gc: fix crash in -live debugging output

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53930043

11 years agocmd/ld: support archives larger than 2G
Ian Lance Taylor [Tue, 21 Jan 2014 17:29:19 +0000 (09:29 -0800)]
cmd/ld: support archives larger than 2G

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/53950043

11 years agoliblink: check for symgrow size too large
Ian Lance Taylor [Tue, 21 Jan 2014 14:12:54 +0000 (06:12 -0800)]
liblink: check for symgrow size too large

Many calls to symgrow pass a vlong value.  Change the function
to not implicitly truncate, and to instead give an error if
the value is too large.

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/54010043

11 years agoruntime: do not collect GC roots explicitly
Dmitriy Vyukov [Tue, 21 Jan 2014 09:06:57 +0000 (13:06 +0400)]
runtime: do not collect GC roots explicitly
Currently we collect (add) all roots into a global array in a single-threaded GC phase.
This hinders parallelism.
With this change we just kick off parallel for for number_of_goroutines+5 iterations.
Then parallel for callback decides whether it needs to scan stack of a goroutine
scan data segment, scan finalizers, etc. This eliminates the single-threaded phase entirely.
This requires to store all goroutines in an array instead of a linked list
(to allow direct indexing).
This CL also removes DebugScan functionality. It is broken because it uses
unbounded stack, so it can not run on g0. When it was working, I've found
it helpless for debugging issues because the two algorithms are too different now.
This change would require updating the DebugScan, so it's simpler to just delete it.

With 8 threads this change reduces GC pause by ~6%, while keeping cputime roughly the same.

garbage-8
allocated                 2987886      2989221      +0.04%
allocs                      62885        62887      +0.00%
cputime                  21286000     21272000      -0.07%
gc-pause-one             26633247     24885421      -6.56%
gc-pause-total             873570       811264      -7.13%
rss                     242089984    242515968      +0.18%
sys-gc                   13934336     13869056      -0.47%
sys-heap                205062144    205062144      +0.00%
sys-other                12628288     12628288      +0.00%
sys-stack                11534336     11927552      +3.41%
sys-total               243159104    243487040      +0.13%
time                      2809477      2740795      -2.44%

R=golang-codereviews, rsc
CC=cshapiro, golang-codereviews, khr
https://golang.org/cl/46860043

11 years agoruntime: delete proc.p
Dmitriy Vyukov [Tue, 21 Jan 2014 08:49:55 +0000 (12:49 +0400)]
runtime: delete proc.p
It's entirely outdated today.

R=golang-codereviews, bradfitz, gobot, r
CC=golang-codereviews
https://golang.org/cl/43500045

11 years agoruntime: per-P defer pool
Dmitriy Vyukov [Tue, 21 Jan 2014 07:20:23 +0000 (11:20 +0400)]
runtime: per-P defer pool
Instead of a per-goroutine stack of defers for all sizes,
introduce per-P defer pool for argument sizes 8, 24, 40, 56, 72 bytes.

For a program that starts 1e6 goroutines and then joins then:
old: rss=6.6g virtmem=10.2g time=4.85s
new: rss=4.5g virtmem= 8.2g time=3.48s

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/42750044

11 years agoruntime: fix race detector by recording read by chansend.
Keith Randall [Tue, 21 Jan 2014 07:17:44 +0000 (11:17 +0400)]
runtime: fix race detector by recording read by chansend.

R=golang-codereviews, dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/54060043

11 years agoruntime: zero 2-word memory blocks in-place
Dmitriy Vyukov [Tue, 21 Jan 2014 06:53:51 +0000 (10:53 +0400)]
runtime: zero 2-word memory blocks in-place
Currently for 2-word blocks we set the flag to clear the flag. Makes no sense.
In particular on 32-bits we call memclr always.

R=golang-codereviews, dave, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/41170044

11 years agoruntime: fix specials deadlock
Dmitriy Vyukov [Tue, 21 Jan 2014 06:48:37 +0000 (10:48 +0400)]
runtime: fix specials deadlock

The deadlock is between span->specialLock and proflock:

goroutine 11 [running]:
runtime.MProf_Free(0x7fa272d26508, 0xc210054180, 0xc0)
        src/pkg/runtime/mprof.goc:220 +0x27
runtime.freespecial(0x7fa272d1e088, 0xc210054180, 0xc0)
        src/pkg/runtime/mheap.c:691 +0x6a
runtime.freeallspecials(0x7fa272d1af50, 0xc210054180, 0xc0)
        src/pkg/runtime/mheap.c:717 +0xb5
runtime.free(0xc210054180)
        src/pkg/runtime/malloc.goc:190 +0xfd
selectgo(0x7fa272a5ef58)
        src/pkg/runtime/chan.c:1136 +0x2d8
runtime.selectgo(0xc210054180)
        src/pkg/runtime/chan.c:840 +0x12
runtime_test.func·058()
        src/pkg/runtime/proc_test.go:146 +0xb4
runtime.goexit()
        src/pkg/runtime/proc.c:1405
created by runtime_test.TestTimerFairness
        src/pkg/runtime/proc_test.go:152 +0xd1

goroutine 12 [running]:
addspecial(0xc2100540c0, 0x7fa272d1e0a0)
        src/pkg/runtime/mheap.c:569 +0x88
runtime.setprofilebucket(0xc2100540c0, 0x7fa272d26508)
        src/pkg/runtime/mheap.c:668 +0x73
runtime.MProf_Malloc(0xc2100540c0, 0xc0, 0x0)
        src/pkg/runtime/mprof.goc:212 +0x16b
runtime.mallocgc(0xc0, 0x0, 0xc200000000)
        src/pkg/runtime/malloc.goc:142 +0x239
runtime.mal(0xbc)
        src/pkg/runtime/malloc.goc:703 +0x38
newselect(0x2, 0x7fa272a5cf60)
        src/pkg/runtime/chan.c:632 +0x53
runtime.newselect(0xc200000002, 0xc21005f000)
        src/pkg/runtime/chan.c:615 +0x28
runtime_test.func·058()
        src/pkg/runtime/proc_test.go:146 +0x37
runtime.goexit()
        src/pkg/runtime/proc.c:1405
created by runtime_test.TestTimerFairness
        src/pkg/runtime/proc_test.go:152 +0xd1

Fixes #7099.

R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/53120043

11 years agoruntime: fix test on windows
Dmitriy Vyukov [Tue, 21 Jan 2014 06:44:08 +0000 (10:44 +0400)]
runtime: fix test on windows
The test prints an excessive \n when /dev/null is not present.

R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/54890043

11 years agonet: fix data race in test
Dmitriy Vyukov [Tue, 21 Jan 2014 06:35:27 +0000 (10:35 +0400)]
net: fix data race in test
Fixes #7157.

R=alex.brainman, bradfitz
CC=golang-codereviews
https://golang.org/cl/54880043