1
0
mirror of https://github.com/golang/go synced 2024-10-02 18:18:33 -06:00
Commit Graph

1085 Commits

Author SHA1 Message Date
Russ Cox
8a6ff3ab34 runtime: allocate heap metadata at run time
Before, the mheap structure was in the bss,
but it's quite large (today, 256 MB, much of
which is never actually paged in), and it makes
Go binaries run afoul of exec-time bss size
limits on some BSD systems.

Fixes #4447.

R=golang-dev, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7307122
2013-02-15 14:27:03 -05:00
Dmitriy Vyukov
f87b7f67b2 runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again and again.
Fixes #4820.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7310096
2013-02-15 22:22:13 +04:00
Russ Cox
d3d89ae7d2 runtime: check rt_sigaction return values on linux
(If the mask size is wrong the system call fails.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7305097
2013-02-15 13:13:19 -05:00
Russ Cox
c7f7bbbf03 runtime: fix build on linux
In addition to the compile failure fixed in signal*.c,
preserving the signal mask led to very strange crashes.
Testing shows that looking for SIG_IGN is all that
matters to get along with nohup, so reintroduce
sigset_zero instead of trying to preserve the signal mask.

TBR=iant
CC=golang-dev
https://golang.org/cl/7323067
2013-02-15 12:18:33 -05:00
Russ Cox
f3407f445d runtime: fix running under nohup
There are two ways nohup(1) might be implemented:
it might mask away the signal, or it might set the handler
to SIG_IGN, both of which are inherited across fork+exec.
So two fixes:

* Make sure to preserve the inherited signal mask at
minit instead of clearing it.

* If the SIGHUP handler is SIG_IGN, leave it that way.

Fixes #4491.

R=golang-dev, mikioh.mikioh, iant
CC=golang-dev
https://golang.org/cl/7308102
2013-02-15 11:18:55 -05:00
Dmitriy Vyukov
a9824f178d runtime: fix debug output
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7312101
2013-02-15 17:04:02 +04:00
Alan Donovan
e49f945603 runtime: expand error for signal received on non-Go thread.
We call runtime.findnull dynamically to avoid exceeding the
static nosplit stack limit check.  (Thanks minux!)

Fixes #4048.

R=rsc, minux.ma, ality
CC=golang-dev
https://golang.org/cl/7232066
2013-02-14 23:37:14 -05:00
Dmitriy Vyukov
6a828482fa runtime: add more tests for LockOSThread()
Just test some additional paths through the scheduler.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7331044
2013-02-15 00:02:12 +04:00
Dmitriy Vyukov
691455f780 runtime: move stack management related code to stack.c
No code changes.
This is mainly in preparation to scheduler changes,
oldstack/newstack are not related to scheduling.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7311085
2013-02-14 12:37:55 +04:00
Russ Cox
e5dae3baaa runtime: tweak addfinroots to preserve original pointer
Use local variable so that stack trace will show value of v.

Fixes #4790.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7300106
2013-02-13 22:31:45 -05:00
Dmitriy Vyukov
4a524311f4 runtime: instrument slicebytetostring for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7322068
2013-02-13 18:29:59 +04:00
Shenghou Ma
2fdd60b9b6 go/build, runtime/cgo: cgo support for NetBSD/ARM
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/7229082
2013-02-13 01:06:52 +08:00
Shenghou Ma
37aba1aa77 runtime: NetBSD/ARM support
R=rsc, dave
CC=golang-dev
https://golang.org/cl/7289044
2013-02-13 01:00:04 +08:00
Jan Ziak
1e01fba2fc runtime: precise garbage collection of hashmaps
R=golang-dev, rsc
CC=dave, dvyukov, golang-dev, minux.ma, remyoudompheng
https://golang.org/cl/7252047
2013-02-08 16:00:33 -05:00
Dmitriy Vyukov
0a9f1ab8bb runtime/race: deflake tests
With the new scheduler races in the tests are reported during execution of other tests.
The change joins goroutines started during the tests.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7310066
2013-02-08 19:24:50 +04:00
Dmitriy Vyukov
45636db01b runtime: fix integer overflow
The problem happens when end=0, then end-1 is very big number.
Observed with the new scheduler.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7307073
2013-02-08 19:05:19 +04:00
Shenghou Ma
6c54bf9916 runtime: fix build for Linux/ARM
R=dave, rsc
CC=golang-dev
https://golang.org/cl/7299055
2013-02-08 13:24:38 +08:00
Dmitriy Vyukov
0a40cd2661 runtime/race: switch to explicit race context instead of goroutine id's
Removes limit on maximum number of goroutines ever existed.
code.google.com/p/goexecutor tests now pass successfully.
Also slightly improves performance.
Before: $ time ./flate.test -test.short
real	0m9.314s
After:  $ time ./flate.test -test.short
real	0m8.958s
Fixes #4286.
The runtime is built from llvm rev 174312.

R=rsc
CC=golang-dev
https://golang.org/cl/7218044
2013-02-06 11:40:54 +04:00
Shenghou Ma
7de3d71797 runtime: save LR to stack when panicking to handle leaf function traceback
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7289047
2013-02-06 01:18:37 +08:00
Dmitriy Vyukov
6b1b613d6a runtime/race: do not include pthread.h
Fixes #4721.

R=alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/7275048
2013-02-05 13:08:07 +04:00
Russ Cox
472354f81e runtime/debug: add controls for garbage collector
Fixes #4090.

R=golang-dev, iant, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/7229070
2013-02-04 00:00:55 -05:00
Russ Cox
f02067a99a cmd/gc: implement latest rules for checking make sizes
Fixes #4085.

R=ken2
CC=golang-dev
https://golang.org/cl/7277047
2013-02-03 14:28:44 -05:00
Russ Cox
2eafbb8878 cmd/gc: elide self-assignment during return
More efficient, less racy code.

Fixes #4014.

R=ken2, ken
CC=golang-dev
https://golang.org/cl/7275047
2013-02-03 01:18:28 -05:00
Ian Lance Taylor
e5ea2d5335 runtime: fix windows build
Fixes #4743.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7284044
2013-02-02 11:41:04 -08:00
Elias Naur
44cf814d50 runtime, cmd/ld: make code more position-independent
Change the stack unwinding code to compensate for the dynamic
relocation of symbols.
Change the gc instruction GC_CALL to use a relative offset instead of
an absolute address.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7248048
2013-02-01 11:24:49 -08:00
Russ Cox
b0a29f393b runtime: cgo-related fixes
* Separate internal and external LockOSThread, for cgo safety.
* Show goroutine that made faulting cgo call.
* Never start a panic due to a signal caused by a cgo call.

Fixes #3774.
Fixes #3775.
Fixes #3797.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7228081
2013-02-01 08:34:41 -08:00
Jan Ziak
4da6b36fbf runtime: local allocation in mprof.goc
Binary data in mprof.goc may prevent the garbage collector from freeing
memory blocks. This patch replaces all calls to runtime·mallocgc() with
calls to an allocator private to mprof.goc, thus making the private
memory invisible to the garbage collector. The addrhash variable is
moved outside of the .bss section.

R=golang-dev, dvyukov, rsc, minux.ma
CC=dave, golang-dev, remyoudompheng
https://golang.org/cl/7135063
2013-01-30 09:01:31 -08:00
Akshat Kumar
c74f3c4576 runtime: add support for panic/recover in Plan 9 note handler
This change also resolves some issues with note handling: we now make
sure that there is enough room at the bottom of every goroutine to
execute the note handler, and the `exitstatus' is no longer a global
entity, which resolves some race conditions.

R=rminnich, npe, rsc, ality
CC=golang-dev
https://golang.org/cl/6569068
2013-01-30 02:53:56 -08:00
Rémy Oudompheng
ccc61eadd5 runtime: implement range access functions in race detector.
Range access functions are already available in TSan library
but were not yet used.

Time for go test -race -short:

Before:
compress/flate 24.244s
exp/norm       >200s
go/printer     78.268s

After:
compress/flate 17.760s
exp/norm        5.537s
go/printer      5.738s

Fixes #4250.

R=dvyukov, golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7229044
2013-01-30 01:55:02 +01:00
Russ Cox
ec1948a44d runtime: clear up lr comments
R=cshapiro
CC=golang-dev
https://golang.org/cl/7230052
2013-01-29 13:12:50 -08:00
Dmitriy Vyukov
81221f512d runtime: dump the full stack of a throwing goroutine
Useful for debugging of runtime bugs.
+ Do not print "stack segment boundary" unless GOTRACEBACK>1.
+ Do not traceback system goroutines unless GOTRACEBACK>1.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7098050
2013-01-29 14:57:11 +04:00
Sébastien Paolacci
09ea3b518e runtime: earlier detection of unused spans.
Mark candidate spans one GC pass earlier.

Move scavenger's code out from mgc0 and constrain it into mheap (where it belongs).

R=rsc, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/7002049
2013-01-28 12:53:35 -05:00
Ian Lance Taylor
e65c0a82ce runtime: use new CNT_MASK in lfstack
This is for SPARC64, a 64-bit processor that uses all 64-bits
of virtual addresses.  The idea is to use the low order 3 bits
to at least get a small ABA counter.  That should work since
pointers are aligned.  The idea is for SPARC64 to set CNT_MASK
== 7, PTR_BITS == 0, PTR_MASK == 0xffffffffffffff8.

Also add uintptr casts to avoid GCC warnings.  The gccgo
runtime code is compiled with GCC, and GCC warns when casting
between a pointer and a type of a different size.

R=dvyukov
CC=golang-dev
https://golang.org/cl/7225043
2013-01-26 18:16:43 -08:00
Shenghou Ma
4019d0e424 runtime: avoid defining the same variable in more than one translation unit
For gccgo runtime and Darwin where -fno-common is the default.

R=iant, dave
CC=golang-dev
https://golang.org/cl/7094061
2013-01-26 09:57:06 +08:00
Dmitriy Vyukov
3c25cd2784 runtime: increase stack limit in a test
Otherwise the test is flaky.
Fixes #4698.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7133071
2013-01-24 20:26:08 +04:00
Dave Cheney
6a9e956f19 all: use t.Skip{,f}
Replace various t.Log{,f} ; return checks with t.Skip{,f}.

R=golang-dev, n13m3y3r, bradfitz, adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7193044
2013-01-24 17:32:10 +11:00
Dmitriy Vyukov
fd32ac4bae runtime: account stop-the-world time in the "other" GOGCTRACE section
Currently it's summed to mark phase.
The change makes it easier to diagnose long stop-the-world phases.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7182043
2013-01-22 13:44:49 +04:00
Jan Ziak
059fed3dfb runtime: try to determine the actual type during garbage collection
If the scanned block has no typeinfo the garbage collector will attempt
to get the actual type of the block.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7093045
2013-01-18 16:56:17 -05:00
Sébastien Paolacci
d8626ef128 runtime: faster mcentral alloc.
Reduce individual object handling by anticipating how much of them are servable.

Not a chunked transfer cache, but decent enough to make sure the bottleneck is not here.

Mac OSX, median of 10 runs:

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5358937333   4892813012   -8.70%
BenchmarkFannkuch11      3257752475   3315436116   +1.77%
BenchmarkGobDecode         23277349     23001114   -1.19%
BenchmarkGobEncode         14367327     14262925   -0.73%
BenchmarkGzip             441045541    440451719   -0.13%
BenchmarkGunzip           139117663    139622494   +0.36%
BenchmarkJSONEncode        45715854     45687802   -0.06%
BenchmarkJSONDecode       103949570    106530032   +2.48%
BenchmarkMandelbrot200      4542462      4548290   +0.13%
BenchmarkParse              7790558      7557540   -2.99%
BenchmarkRevcomp          831436684    832510381   +0.13%
BenchmarkTemplate         133789824    133007337   -0.58%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            32.82        33.33    1.02x
BenchmarkGobEncode            53.42        53.86    1.01x
BenchmarkGzip                 43.70        44.01    1.01x
BenchmarkGunzip              139.09       139.14    1.00x
BenchmarkJSONEncode           42.69        42.56    1.00x
BenchmarkJSONDecode           18.78        17.91    0.95x
BenchmarkParse                 7.37         7.67    1.04x
BenchmarkRevcomp             306.83       305.70    1.00x
BenchmarkTemplate             14.57        14.56    1.00x

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/7005055
2013-01-18 16:39:22 -05:00
Rémy Oudompheng
c13866db7f cmd/5c: fix handling of side effects when assigning a struct literal.
Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043
2013-01-12 09:16:50 +01:00
Rémy Oudompheng
6e981c181c runtime: work around 5c bug in GC code.
5c miscompiles *p++ = struct_literal.

R=dave, golang-dev
CC=golang-dev
https://golang.org/cl/7065069
2013-01-11 00:59:44 +01:00
Jan Ziak
9204eb4d3c runtime: interpret type information during garbage collection
R=rsc, dvyukov, remyoudompheng, dave, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6945069
2013-01-10 15:45:46 -05:00
Dmitriy Vyukov
7847f328cd runtime: faster segmented stacks
benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          548  -17.59%
BenchmarkStackGrowth-2               333          274  -17.72%
BenchmarkStackGrowth-4               224          168  -25.00%
BenchmarkStackGrowth-8               124           91  -26.21%
BenchmarkStackGrowth-16               82           70  -14.55%
BenchmarkStackGrowth-32               73           59  -19.49%

R=nigeltao, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7026044
2013-01-10 11:36:40 +04:00
Dmitriy Vyukov
f82db7d9e4 runtime: less aggressive per-thread stack segment caching
Introduce global stack segment cache and limit per-thread cache size.
This greatly reduces StackSys memory on workloads that create lots of threads.

benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          656   -1.35%
BenchmarkStackGrowth-2               333          328   -1.50%
BenchmarkStackGrowth-4               224          172  -23.21%
BenchmarkStackGrowth-8               124           91  -26.13%
BenchmarkStackGrowth-16               82           47  -41.94%
BenchmarkStackGrowth-32               73           40  -44.79%

BenchmarkStackGrowthDeep           97231        94391   -2.92%
BenchmarkStackGrowthDeep-2         47230        58562  +23.99%
BenchmarkStackGrowthDeep-4         24993        49356  +97.48%
BenchmarkStackGrowthDeep-8         15105        30072  +99.09%
BenchmarkStackGrowthDeep-16        10005        15623  +56.15%
BenchmarkStackGrowthDeep-32        12517        13069   +4.41%

TestStackMem#1,MB                  310          12       -96.13%
TestStackMem#2,MB                  296          14       -95.27%
TestStackMem#3,MB                  479          14       -97.08%

TestStackMem#1,sec                 3.22         2.26     -29.81%
TestStackMem#2,sec                 2.43         2.15     -11.52%
TestStackMem#3,sec                 2.50         2.38      -4.80%

R=sougou, no.smile.face, rsc
CC=golang-dev, msolomon
https://golang.org/cl/7029044
2013-01-10 09:57:06 +04:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Ian Lance Taylor
63bee953a2 runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions.

R=golang-dev, dave, patrick, rsc
CC=golang-dev
https://golang.org/cl/7051043
2013-01-04 07:53:42 -08:00
Jan Ziak
89ec208ee8 runtime: introduce typedefs and delete struct keywords in mgc0.c
R=rsc
CC=golang-dev
https://golang.org/cl/7029055
2013-01-04 10:20:50 -05:00
Dave Cheney
c2d2bfcc49 runtime: fix freebsd/arm instruction cache flush
sysarch requires arguments to be passed on the stack, not in registers.

Credit to Shenghou Ma (minux) for the fix.

R=minux.ma, devon.odell
CC=golang-dev
https://golang.org/cl/7037043
2013-01-01 21:47:42 +11:00
Russ Cox
a22389ec38 runtime: say 'fatal error' instead of 'throw'
Fixes #4597.

R=ken2
CC=golang-dev
https://golang.org/cl/7032043
2012-12-29 21:48:25 -05:00
Sébastien Paolacci
e786829e83 runtime: handle locked mmap failure on Linux
Used to then die on a nil pointer situation. Most Linux standard setups are rather
restrictive regarding the default amount of lockable memory.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6997049
2012-12-29 14:34:06 -05:00