]> Cypherpunks repositories - gostls13.git/log
gostls13.git
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

11 years agoruntime: ensure fair scheduling during frequent GCs
Dmitriy Vyukov [Tue, 21 Jan 2014 06:24:42 +0000 (10:24 +0400)]
runtime: ensure fair scheduling during frequent GCs
What was happenning is as follows:
Each writer goroutine always triggers GC during its scheduling quntum.
After GC goroutines are shuffled so that the timer goroutine is always second in the queue.
This repeats infinitely, causing timer goroutine starvation.
Fixes #7126.

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

11 years agoexpvar: sort maps, fix race
Brad Fitzpatrick [Mon, 20 Jan 2014 17:59:23 +0000 (09:59 -0800)]
expvar: sort maps, fix race

It's pretty distracting to use expvar with the output of both
the top-level map and map values jumping around randomly.

Also fixes a potential race where multiple clients trying to
increment a map int or float key at the same time could lose
updates.

R=golang-codereviews, couchmoney
CC=golang-codereviews
https://golang.org/cl/54320043

11 years agonet/http, net/http/httputil: make chunked reader alloc test more robust
Brad Fitzpatrick [Sun, 19 Jan 2014 18:02:10 +0000 (10:02 -0800)]
net/http, net/http/httputil: make chunked reader alloc test more robust

Use testing.AllocsPerRun now that it exists, instead of doing it by hand.

Fixes #6076

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

11 years agosyscall: add syscall.Termios on netbsd
Michael Gehring [Sun, 19 Jan 2014 17:57:02 +0000 (09:57 -0800)]
syscall: add syscall.Termios on netbsd

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

11 years agosyscall: fix typo
Mikio Hara [Sat, 18 Jan 2014 07:02:59 +0000 (16:02 +0900)]
syscall: fix typo

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

11 years agoruntime: print stack trace when "panic during panic"
Keith Randall [Sat, 18 Jan 2014 02:47:40 +0000 (18:47 -0800)]
runtime: print stack trace when "panic during panic"

Fixes bug 7145

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

11 years agosyscall: fix build
Mikio Hara [Sat, 18 Jan 2014 02:22:32 +0000 (11:22 +0900)]
syscall: fix build

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

11 years agosyscall: make getrlimit, setrlimit tests work on unix variants
Mikio Hara [Fri, 17 Jan 2014 23:34:31 +0000 (08:34 +0900)]
syscall: make getrlimit, setrlimit tests work on unix variants

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

11 years agoruntime, cmd/gc: Get rid of vararg channel calls.
Keith Randall [Fri, 17 Jan 2014 22:48:45 +0000 (14:48 -0800)]
runtime, cmd/gc: Get rid of vararg channel calls.

Vararg C calls present a problem for the GC because the
argument types are not derivable from the signature.  Remove
them by passing pointers to channel elements instead of the
channel elements directly.

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

11 years agoruntime: fix TestLFStackStress
Russ Cox [Fri, 17 Jan 2014 22:42:24 +0000 (17:42 -0500)]
runtime: fix TestLFStackStress

Fixes #7138.

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

11 years agoundo CL 45930043 / c22889382a17
Russ Cox [Fri, 17 Jan 2014 21:58:14 +0000 (16:58 -0500)]
undo CL 45930043 / c22889382a17

The compiler change is an ugly hack.
We can do better.

««« original CL description
syscall: mark arguments to Syscall as noescape
Heap arguments to "async" syscalls will break when/if we have moving GC anyway.
With this change is must not break until moving GC, because a user must
reference the object in Go to preserve liveness. Otherwise the code is broken already.
Reduces number of leaked params from 125 to 36 on linux.

R=golang-codereviews, mikioh.mikioh, bradfitz
CC=cshapiro, golang-codereviews, khr, rsc
https://golang.org/cl/45930043
»»»

R=golang-codereviews, r
CC=bradfitz, dvyukov, golang-codereviews
https://golang.org/cl/53870043

11 years agosyscall: allocate 64 bits of "basep" for Getdirentries
Rob Pike [Fri, 17 Jan 2014 21:19:00 +0000 (13:19 -0800)]
syscall: allocate 64 bits of "basep" for Getdirentries
Recent crashes on 386 Darwin appear to be caused by this system call
smashing the stack. Phenomenology shows that allocating more data
here addresses the probem.
The guess is that since the actual system call is getdirentries64, 64 is
what we should allocate.

Should fix the darwin/386 build.

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

11 years agodoc: replace "private" with "unexported" in Effective Go.
David Symonds [Fri, 17 Jan 2014 17:06:39 +0000 (09:06 -0800)]
doc: replace "private" with "unexported" in Effective Go.

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

11 years agoregexp: remove unnecessary sentence in doc comment.
David Symonds [Fri, 17 Jan 2014 17:06:28 +0000 (09:06 -0800)]
regexp: remove unnecessary sentence in doc comment.

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

11 years agoA+C: Maxim Khitrov (individual CLA)
Adam Langley [Fri, 17 Jan 2014 16:26:42 +0000 (11:26 -0500)]
A+C: Maxim Khitrov (individual CLA)

Generated by addca.

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

11 years agosyscall: mark arguments to Syscall as noescape
Dmitriy Vyukov [Fri, 17 Jan 2014 16:18:37 +0000 (20:18 +0400)]
syscall: mark arguments to Syscall as noescape
Heap arguments to "async" syscalls will break when/if we have moving GC anyway.
With this change is must not break until moving GC, because a user must
reference the object in Go to preserve liveness. Otherwise the code is broken already.
Reduces number of leaked params from 125 to 36 on linux.

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

11 years agocrypto/cipher: improved cbc performance
Luke Curley [Fri, 17 Jan 2014 16:07:04 +0000 (11:07 -0500)]
crypto/cipher: improved cbc performance

decrypt: reduced the number of copy calls from 2n to 1.
encrypt: reduced the number of copy calls from n to 1.

Encryption is straight-forward: use dst instead of tmp when
xoring the block with the iv.

Decryption now loops backwards through the blocks abusing the
fact that the previous block's ciphertext (src) is the iv. This
means we don't need to copy the iv every time, in addition to
using dst instead of tmp like encryption.

R=golang-codereviews, agl, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/50900043

11 years agoA+C: Luke Curley (individual CLA)
Adam Langley [Fri, 17 Jan 2014 16:01:03 +0000 (11:01 -0500)]
A+C: Luke Curley (individual CLA)

Generated by addca.

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

11 years agoruntime: add support for GOOS=solaris
Aram Hăvărneanu [Fri, 17 Jan 2014 04:58:10 +0000 (17:58 +1300)]
runtime: add support for GOOS=solaris

R=alex.brainman, dave, jsing, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/35990043

11 years agonet/rpc: fix inconsistency in documentation of Service.Register
Rob Pike [Thu, 16 Jan 2014 23:57:32 +0000 (15:57 -0800)]
net/rpc: fix inconsistency in documentation of Service.Register
Falsely claimed an old, no longer true condition that the first argument
must be a pointer.
Fixes #6697

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

11 years agonet: skip TestDualStackTCPListener in short mode
Dave Cheney [Thu, 16 Jan 2014 22:49:38 +0000 (09:49 +1100)]
net: skip TestDualStackTCPListener in short mode

Update #5001

This test is flakey on linux servers and fails otherwise good builds. Mikio has some proposals to fix the test, but they require additional plumbing.

In the meantime, disable this test in -short mode so it will run during the full net test suite, but not during builder ci.

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

11 years agotime: break parse and formatting tests into a separate source file
Rob Pike [Thu, 16 Jan 2014 22:30:01 +0000 (14:30 -0800)]
time: break parse and formatting tests into a separate source file
No changes, just rearrangement. The tests were in need of a little
housekeeping.

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

11 years agosyscall: add Flock_t on Linux
Brad Fitzpatrick [Thu, 16 Jan 2014 22:08:32 +0000 (14:08 -0800)]
syscall: add Flock_t on Linux

Matches Darwin and the BSDs. This means leveldb-go, kv,
Camlistore, etc can stop defining these structs on Linux by
hand.

Update #7059

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

11 years agoreflect: Remove imprecise techniques from channel/select operations.
Keith Randall [Thu, 16 Jan 2014 21:35:29 +0000 (13:35 -0800)]
reflect: Remove imprecise techniques from channel/select operations.

Reflect used to communicate to the runtime using interface words,
which is bad for precise GC because sometimes iwords hold a pointer
and sometimes they don't.  This change rewrites channel and select
operations to always pass pointers to the runtime.

reflect.Select gets somewhat more expensive, as we now do an allocation
per receive case instead of one allocation whose size is the max of
all the received types.  This seems unavoidable to get preciseness
(unless we move the allocation into selectgo, which is a much bigger
change).

Fixes #6490

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

11 years agonet/http: don't allow Content-Type or body on 204 and 1xx
Brad Fitzpatrick [Thu, 16 Jan 2014 19:43:52 +0000 (11:43 -0800)]
net/http: don't allow Content-Type or body on 204 and 1xx

Status codes 204, 304, and 1xx don't allow bodies. We already
had a function for this, but we were hard-coding just 304
(StatusNotModified) in a few places.  Use the function
instead, and flesh out tests for all codes.

Fixes #6685

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

11 years agonet/smtp: add examples
Kamil Kisiel [Thu, 16 Jan 2014 18:49:58 +0000 (10:49 -0800)]
net/smtp: add examples

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

11 years agonet/http: cache transport environment lookup
Brad Fitzpatrick [Thu, 16 Jan 2014 18:25:45 +0000 (10:25 -0800)]
net/http: cache transport environment lookup

Apparently this is expensive on Windows.

Fixes #7020

R=golang-codereviews, alex.brainman, mattn.jp, dvyukov
CC=golang-codereviews
https://golang.org/cl/52840043

11 years agofmt: fix bug printing large zero-padded hexadecimal
Rob Pike [Thu, 16 Jan 2014 17:48:23 +0000 (09:48 -0800)]
fmt: fix bug printing large zero-padded hexadecimal
We forgot to include the width of "0x" when computing the crossover
from internal buffer to allocated buffer.
Also add a helper function to the test for formatting large zero-padded
test strings.

Fixes #6777.

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

11 years agocmd/gc: handle non-escaping address-taken variables better
Russ Cox [Thu, 16 Jan 2014 15:32:30 +0000 (10:32 -0500)]
cmd/gc: handle non-escaping address-taken variables better

This CL makes the bitmaps a little more precise about variables
that have their address taken but for which the address does not
escape to the heap, so that the variables are kept in the stack frame
rather than allocated on the heap.

The code before this CL handled these variables by treating every
return statement as using every such variable and depending on
liveness analysis to essentially treat the variable as live during the
entire function. That approach has false positives and (worse) false
negatives. That is, it's both sloppy and buggy:

        func f(b1, b2 bool) { // x live here! (sloppy)
                if b2 {
                        print(0) // x live here! (sloppy)
                        return
                }
                var z **int
                x := new(int)
                *x = 42
                z = &x
                print(**z) // x live here (conservative)
                if b2 {
                        print(1) // x live here (conservative)
                        return
                }
                for {
                        print(**z) // x not live here (buggy)
                }
        }

The first two liveness annotations (marked sloppy) are clearly
wrong: x cannot be live if it has not yet been declared.

The last liveness annotation (marked buggy) is also wrong:
x is live here as *z, but because there is no return statement
reachable from this point in the code, the analysis treats x as dead.

This CL changes the liveness calculation to mark such variables
live exactly at points in the code reachable from the variable
declaration. This keeps the conservative decisions but fixes
the sloppy and buggy ones.

The CL also detects ambiguously live variables, those that are
being marked live but may not actually have been initialized,
such as in this example:

        func f(b1 bool) {
                var z **int
                if b1 {
                        x := new(int)
                        *x = 42
                        z = &x
                } else {
                        y := new(int)
                        *y = 54
                        z = &y
                }
                print(**z) // x, y live here (conservative)
        }

Since the print statement is reachable from the declaration of x,
x must conservatively be marked live. The same goes for y.
Although both x and y are marked live at the print statement,
clearly only one of them has been initialized. They are both
"ambiguously live".

These ambiguously live variables cause problems for garbage
collection: the collector cannot ignore them but also cannot
depend on them to be initialized to valid pointer values.

Ambiguously live variables do not come up too often in real code,
but recent changes to the way map and interface runtime functions
are invoked has created a large number of ambiguously live
compiler-generated temporary variables. The next CL will adjust
the analysis to understand these temporaries better, to make
ambiguously live variables fairly rare.

Once ambiguously live variables are rare enough, another CL will
introduce code at the beginning of a function to zero those
slots on the stack. At that point the garbage collector and the
stack copying routines will be able to depend on the guarantee that
if a slot is marked as live in a liveness bitmap, it is initialized.

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

11 years agocmd/gc: fix race build
Russ Cox [Thu, 16 Jan 2014 15:11:06 +0000 (10:11 -0500)]
cmd/gc: fix race build

Missed this case in CL 51010045.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/53200043

11 years agoruntime: output how long goroutines are blocked
Dmitriy Vyukov [Thu, 16 Jan 2014 08:54:46 +0000 (12:54 +0400)]
runtime: output how long goroutines are blocked
Example of output:

goroutine 4 [sleep for 3 min]:
time.Sleep(0x34630b8a000)
        src/pkg/runtime/time.goc:31 +0x31
main.func·002()
        block.go:16 +0x2c
created by main.main
        block.go:17 +0x33

Full program and output are here:
http://play.golang.org/p/NEZdADI3Td

Fixes #6809.

R=golang-codereviews, khr, kamil.kisiel, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/50420043

11 years agoruntime: use lock-free ring for work queues
Dmitriy Vyukov [Thu, 16 Jan 2014 08:17:00 +0000 (12:17 +0400)]
runtime: use lock-free ring for work queues
Use lock-free fixed-size ring for work queues
instead of an unbounded mutex-protected array.
The ring has single producer and multiple consumers.
If the ring overflows, work is put onto global queue.

benchmark              old ns/op    new ns/op    delta
BenchmarkMatmult               7            5  -18.12%
BenchmarkMatmult-4             2            2  -18.98%
BenchmarkMatmult-16            1            0  -12.84%

BenchmarkCreateGoroutines                     105           88  -16.10%
BenchmarkCreateGoroutines-4                   376          219  -41.76%
BenchmarkCreateGoroutines-16                  241          174  -27.80%
BenchmarkCreateGoroutinesParallel             103           87  -14.66%
BenchmarkCreateGoroutinesParallel-4           169          143  -15.38%
BenchmarkCreateGoroutinesParallel-16          158          151   -4.43%

R=golang-codereviews, rsc
CC=ddetlefs, devon.odell, golang-codereviews
https://golang.org/cl/46170044

11 years agoreflect: add precise GC info for Call argument frame.
Keith Randall [Wed, 15 Jan 2014 21:56:59 +0000 (13:56 -0800)]
reflect: add precise GC info for Call argument frame.

Give proper types to the argument/return areas
allocated for reflect calls.  Avoid use of iword to
manipulate receivers, which may or may not be pointers.

Update #6490

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

11 years agonet/http: add disabled test for Body Read/Close lock granularity
Brad Fitzpatrick [Wed, 15 Jan 2014 21:12:32 +0000 (13:12 -0800)]
net/http: add disabled test for Body Read/Close lock granularity

Update #7121

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

11 years agogo/scanner: report too short escape sequences
Robert Griesemer [Wed, 15 Jan 2014 17:50:55 +0000 (09:50 -0800)]
go/scanner: report too short escape sequences

Generally improve error messages for escape sequences.

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

11 years agocmd/pack: rewrite in Go
Rob Pike [Wed, 15 Jan 2014 17:13:52 +0000 (09:13 -0800)]
cmd/pack: rewrite in Go
Replace the pack command, a C program, with a clean reimplementation in Go.
It does not need to reproduce the full feature set and it is no longer used by
the build chain, but has a role in looking inside archives created by the build
chain directly.

Since it's not in C, it is no longer build by dist, so remove it from cmd/dist and
make it a "tool" in cmd/go terminology.

Fixes #2705

R=rsc, dave, minux.ma, josharian
CC=golang-codereviews
https://golang.org/cl/52310044

11 years agoruntime: fix data race in GC
Dmitriy Vyukov [Wed, 15 Jan 2014 15:38:08 +0000 (19:38 +0400)]
runtime: fix data race in GC
Fixes #5139.
Update #7065.

R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/52090045

11 years agonet/http: return UnexpectedEOF instead of EOF on truncated resposne
Brad Fitzpatrick [Wed, 15 Jan 2014 03:08:40 +0000 (19:08 -0800)]
net/http: return UnexpectedEOF instead of EOF on truncated resposne

Fixes #6564

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