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

1166 Commits

Author SHA1 Message Date
Shenghou Ma
3e3fa7b5f1 runtime: ~3.7x speed up of div/mod on ARM
benchmark                      old ns/op    new ns/op    delta
BenchmarkUint32Div7                  281           75  -73.06%
BenchmarkUint32Div37                 281           75  -73.02%
BenchmarkUint32Div123                281           75  -73.02%
BenchmarkUint32Div763                280           75  -72.89%
BenchmarkUint32Div1247               280           75  -72.93%
BenchmarkUint32Div9305               281           75  -73.02%
BenchmarkUint32Div13307              281           75  -73.06%
BenchmarkUint32Div52513              281           75  -72.99%
BenchmarkUint32Div60978747           281           63  -77.33%
BenchmarkUint32Div106956295          280           63  -77.21%
BenchmarkUint32Mod7                  280           77  -72.21%
BenchmarkUint32Mod37                 280           77  -72.18%
BenchmarkUint32Mod123                280           77  -72.25%
BenchmarkUint32Mod763                280           77  -72.18%
BenchmarkUint32Mod1247               280           77  -72.21%
BenchmarkUint32Mod9305               280           77  -72.21%
BenchmarkUint32Mod13307              280           77  -72.25%
BenchmarkUint32Mod52513              280           77  -72.18%
BenchmarkUint32Mod60978747           280           63  -77.25%
BenchmarkUint32Mod106956295          280           63  -77.21%

R=dave, rsc
CC=dave, golang-dev, rsc
https://golang.org/cl/6717043
2012-10-20 16:40:19 +08:00
Nigel Tao
90ad6a2d11 runtime: update comment for the "extern register" variables g and m.
R=rsc, minux.ma, ality
CC=dave, golang-dev
https://golang.org/cl/6620050
2012-10-19 11:02:32 +11:00
Dmitriy Vyukov
f24323c93e runtime: fix spurious deadlock crashes
Fixes #4243.

R=golang-dev, iant
CC=golang-dev, sebastien.paolacci
https://golang.org/cl/6682050
2012-10-16 14:41:32 +04:00
Dmitriy Vyukov
6273c7324f runtime: add missing if(raceenabled)
R=0xe2.0x9a.0x9b, minux.ma, iant, dave
CC=golang-dev
https://golang.org/cl/6654052
2012-10-15 13:54:31 +04:00
Shenghou Ma
366268aa79 runtime: FreeBSD/ARM support
R=rsc
CC=golang-dev
https://golang.org/cl/6625071
2012-10-12 23:19:39 +08:00
Dmitriy Vyukov
be2b95fe3a runtime/debug: fix the test
If source are not available, then the stack looks like:
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:15 (0x43fb11)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:18 (0x43fb7a)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:37 (0x43fbf4)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/testing/bla-bla-bla/src/pkg/testing/testing.go:301 (0x43b5ba)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/bla-bla-bla/src/pkg/runtime/proc.c:276 (0x410670)
stack_test.go:40:
which is 6 lines.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6637060
2012-10-10 20:49:18 +04:00
Dmitriy Vyukov
27e93fbd00 runtime: fix race detector handling of stackalloc()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6632051
2012-10-10 18:06:29 +04:00
Russ Cox
f76f120324 cmd/ld: use 64-bit alignment for large data and bss objects
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049
2012-10-09 12:50:06 -04:00
Dmitriy Vyukov
2f6cbc74f1 race: runtime changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6535050
2012-10-07 22:05:32 +04:00
Shenghou Ma
f82c59b6cf runtime: disable TestParForParallel for now on 32-bit hosts
Also add call to GC() to make it easier to re-enable the test.

Update #4155.
When we have precise GC merged, re-enable this test.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6622058
2012-10-08 01:56:27 +08:00
Rémy Oudompheng
782464aea5 runtime: fix a panic when growing zero-width-element slices.
Fixes #4197.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6611056
2012-10-06 12:05:52 +02:00
Dmitriy Vyukov
4cc7bf326a pprof: add goroutine blocking profiling
The profiler collects goroutine blocking information similar to Google Perf Tools.
You may see an example of the profile (converted to svg) attached to
http://code.google.com/p/go/issues/detail?id=3946
The public API changes are:
+pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool)
+pkg runtime, func SetBlockProfileRate(int)
+pkg runtime, method (*BlockProfileRecord) Stack() []uintptr
+pkg runtime, type BlockProfileRecord struct
+pkg runtime, type BlockProfileRecord struct, Count int64
+pkg runtime, type BlockProfileRecord struct, Cycles int64
+pkg runtime, type BlockProfileRecord struct, embedded StackRecord

R=rsc, dave, minux.ma, r
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/6443115
2012-10-06 12:56:04 +04:00
Akshat Kumar
23599ca2f6 runtime: mask SSE exceptions on plan9/amd64
The Go run-time assumes that all SSE floating-point exceptions
are masked so that Go programs are not broken by such invalid
operations. By default, the 64-bit version of the Plan 9 kernel
masks only some SSE floating-point exceptions. Here, we mask
them all on a per-thread basis.

R=rsc, rminnich, minux.ma
CC=golang-dev
https://golang.org/cl/6592056
2012-10-05 16:23:30 -04:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Jan Ziak
f8c58373e5 runtime: add types to MSpan
R=rsc
CC=golang-dev
https://golang.org/cl/6554060
2012-09-24 20:08:05 -04:00
Russ Cox
0b08c9483f runtime: prepare for 64-bit ints
This CL makes the runtime understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32',
and it is also careful to distinguish between function arguments
and results of type 'int' vs type 'int32'.

In the runtime, the new typedefs 'intgo' and 'uintgo' refer
to Go int and uint. The C types int and uint continue to be
unavailable (cause intentional compile errors).

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=iant, r, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6551067
2012-09-24 14:58:34 -04:00
Akshat Kumar
e42788628a cmd/dist, pkg/runtime: Plan 9, 64-bit: Get PID from TLS; remove use of `_tos'.
Using offsets from Tos is cumbersome and we've had problems
in the past. Since it's only being used to grab the PID, we'll just
get that from the default TLS instead.

R=rsc, rminnich, npe
CC=golang-dev
https://golang.org/cl/6543049
2012-09-24 12:24:45 -04:00
Jan Ziak
b16c41bed7 runtime: fix typos in comments
R=rsc
CC=golang-dev
https://golang.org/cl/6554043
2012-09-21 12:25:55 -04:00
Shenghou Ma
b151af1f36 runtime: fix mmap comments
We only pass lower 32 bits of file offset to asm routine.

R=r, dave, rsc
CC=golang-dev
https://golang.org/cl/6499118
2012-09-21 13:50:02 +08:00
Dmitriy Vyukov
d151fb9e20 runtime: reset parfor stats
Otherwise they sum up between GCs.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6535048
2012-09-20 22:46:24 +04:00
Jan Ziak
35724c1aa5 runtime: hide the semaphore table from garbage collector
R=rsc, dvyukov, dave
CC=golang-dev
https://golang.org/cl/6528043
2012-09-18 14:30:01 -04:00
Russ Cox
370ae05545 reflect: add Select
R=r, iant, rogpeppe, bradfitz
CC=golang-dev
https://golang.org/cl/6498078
2012-09-18 14:22:41 -04:00
Dmitriy Vyukov
f20fd87384 runtime: refactor goroutine blocking
The change is a preparation for the new scheduler.
It introduces runtime.park() function,
that will atomically unlock the mutex and park the goroutine.
It will allow to remove the racy readyonstop flag
that is difficult to implement w/o the global scheduler mutex.

R=rsc, remyoudompheng, dave
CC=golang-dev
https://golang.org/cl/6501077
2012-09-18 21:15:46 +04:00
Dave Cheney
55ca5ab0be runtime: arm: abort if VFPv3 support missing
Fixes #3456.

This proposal is a reformulation of CL 5987063. This CL resets
the default GOARM value to 6 and allows the use of the VFPv3
optimisation if GOARM=7. Binaries built with this CL in place
will abort if GOARM=7 was used and the target host does not
support VFPv3.

R=minux.ma, rsc, ajstarks
CC=golang-dev
https://golang.org/cl/6501099
2012-09-18 09:55:07 +10:00
Lucio De Re
b29ed23ab5 build: fix various 'set and not used' for Plan 9
R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6501134
2012-09-17 17:25:26 -04:00
Jan Ziak
54193689cc cmd/ld: fix compilation when GOARCH != GOHOSTARCH
R=rsc, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6493123
2012-09-17 17:18:21 -04:00
Shenghou Ma
ecb2a0a9e5 runtime: fix SI_USER for FreeBSD
Ref: http://svnweb.freebsd.org/base/head/sys/sys/signal.h?revision=HEAD&view=markup

R=golang-dev, devon.odell, r
CC=golang-dev
https://golang.org/cl/6490118
2012-09-17 01:08:41 +08:00
Jan Ziak
d09afc2efb gc: generate garbage collection info for types
R=rsc, nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6290043
2012-09-12 12:08:27 -04:00
Daniel Morsing
8fd65b0e1d cmd/gc: Inline pointer sized T2I interface conversions
This CL also adds support for marking the likelyness of IF nodes in the AST being true. This feature is being used here to mark the slow path as unlikely.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2IUintptr           16            1  -91.63%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5416917000   5461355000   +0.82%
BenchmarkFannkuch11      3810355000   3842609000   +0.85%
BenchmarkGobDecode         19950950     19855420   -0.48%
BenchmarkGobEncode         11301220     11308530   +0.06%
BenchmarkGzip             548119600    546869200   -0.23%
BenchmarkGunzip           176145400    180208300   +2.31%
BenchmarkJSONEncode        93117400     70163100  -24.65%
BenchmarkJSONDecode       406626800    409999200   +0.83%
BenchmarkMandelbrot200      6300992      6317866   +0.27%
BenchmarkParse              7664396      7451625   -2.78%
BenchmarkRevcomp         1189424000   1412332000  +18.74%
BenchmarkTemplate         491308400    458654200   -6.65%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            38.47        38.66    1.00x
BenchmarkGobEncode            67.92        67.87    1.00x
BenchmarkGzip                 35.40        35.48    1.00x
BenchmarkGunzip              110.16       107.68    0.98x
BenchmarkJSONEncode           20.84        27.66    1.33x
BenchmarkJSONDecode            4.77         4.73    0.99x
BenchmarkParse                 7.56         7.77    1.03x
BenchmarkRevcomp             213.69       179.96    0.84x
BenchmarkTemplate              3.95         4.23    1.07x

R=rsc, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6351090
2012-09-11 21:42:30 +02:00
Dave Cheney
212ce41d00 runtime: arm: abort if hardware floating point missing
Fixes #3911.

Requires CL 6449127.

dfc@qnap:~$ ./runtime.test
runtime: this CPU has no floating point hardware, so it cannot run
this GOARM=7 binary. Recompile using GOARM=5.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6442109
2012-09-07 14:26:42 +10:00
Alan Donovan
ee911c4265 runtime: fix typo in openbsd-only symbol name.
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6490076
2012-09-04 16:35:05 -04:00
Alan Donovan
532dee3842 runtime: discard SIGPROF delivered to non-Go threads.
Signal handlers are global resources but many language
environments (Go, C++ at Google, etc) assume they have sole
ownership of a particular handler.  Signal handlers in
mixed-language applications must therefore be robust against
unexpected delivery of certain signals, such as SIGPROF.

The default Go signal handler runtime·sigtramp assumes that it
will never be called on a non-Go thread, but this assumption
is violated by when linking in C++ code that spawns threads.
Specifically, the handler asserts the thread has an associated
"m" (Go scheduler).

This CL is a very simple workaround: discard SIGPROF delivered to non-Go threads.  runtime.badsignal(int32) now receives the signal number; if it returns without panicking (e.g. sig==SIGPROF) the signal is discarded.

I don't think there is any really satisfactory solution to the
problem of signal-based profiling in a mixed-language
application.  It's not only the issue of handler clobbering,
but also that a C++ SIGPROF handler called in a Go thread
can't unwind the Go stack (and vice versa).  The best we can
hope for is not crashing.

Note:
- I've ported this to all POSIX platforms, except ARM-linux which already ignores unexpected signals on m-less threads.
- I've avoided tail-calling runtime.badsignal because AFAICT the 6a/6l don't support it.
- I've avoided hoisting 'push sig' (common to both function calls) because it makes the code harder to read.
- Fixed an (apparently incorrect?) docstring.

R=iant, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6498057
2012-09-04 14:40:49 -04:00
Alan Donovan
b2458ff75c runtime/pprof: emit end-of-log marker at end of CPU profile.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6489065
2012-09-04 14:34:03 -04:00
Alex Brainman
7f075ece42 runtime: increase stack frame during cgo call on windows/amd64
Fixes #3945.

R=golang-dev, minux.ma
CC=golang-dev, vcc.163
https://golang.org/cl/6490056
2012-09-03 12:12:51 +10:00
Ivan Krasin
5287175ad9 runtime: add vdso support for linux/amd64. Fixes issue 1933.
R=iant, imkrasin, krasin, iant, minux.ma, rsc, nigeltao, r, fullung
CC=golang-dev
https://golang.org/cl/6454046
2012-08-31 18:07:04 -04:00
Russ Cox
020c6558d9 runtime/pprof: restore articles in type doc comments
Reverts part of CL 6460082.

If a doc comment describes a type by explaining the
meaning of one instance of the type, a leading article
is fine and makes the text less awkward.

Compare:
// A dog is a kind of animal.
// Dog is a kind of animal.

R=golang-dev, dsymonds, dvyukov, r
CC=golang-dev
https://golang.org/cl/6494066
2012-08-31 13:49:57 -04:00
Akshat Kumar
a72bebf6e1 src: Add support for 64-bit version of Plan 9
This set of changes extends the Plan 9 support
to include the AMD64 architecture and should
work on all versions of Plan 9.

R=golang-dev, rminnich, noah.evans, rsc, minux.ma, npe
CC=akskuma, golang-dev, jfflore, noah.evans
https://golang.org/cl/6479052
2012-08-31 13:21:13 -04:00
Joel Sing
79473d6b1c runtime: use netbsd signal ABI v2
Use version 2 of the NetBSD signal ABI - both version 2 and version 3
are supported by the kernel, with near identical behaviour. However,
the netbsd32 compat code does not allow version 3 to be used, which
prevents Go netbsd/386 binaries from running in compat mode on a
NetBSD amd64 kernel. Switch to version 2 of the ABI, which is the
same version currently used by NetBSD's libc.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6476068
2012-08-26 20:57:47 +10:00
Joel Sing
1b6557a0cf runtime: fix netbsd/386 stack pointer handling
When manipulating the stack pointer use the UESP register instead
of the ESP register, since the UESP register is the one that gets
restored from the machine context. Fixes broken tests on netbsd/386.

R=golang-dev, minux.ma, r, bsiegert
CC=golang-dev
https://golang.org/cl/6465054
2012-08-17 21:53:02 +10:00
Joel Sing
b60d45f5b8 runtime: disable crash handler test on netbsd
Disable the crash handler test on NetBSD until I can figure out why
it triggers failures in later tests.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6460090
2012-08-16 02:02:00 +10:00
Dmitriy Vyukov
058149f153 runtime/pprof: fix comments
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6460082
2012-08-14 01:51:42 +04:00
Shenghou Ma
4f308edc86 runtime: use sched_getaffinity for runtime.NumCPU() on Linux
Fixes #3921.

R=iant
CC=golang-dev
https://golang.org/cl/6448132
2012-08-10 10:05:26 +08:00
Rob Pike
c48b77b1b5 all: make Unicode surrogate halves illegal as UTF-8
Surrogate halves are part of UTF-16 and should never appear in UTF-8.
(The rune that two combined halves represent in UTF-16 should
be encoded directly.)

Encoding: encode as RuneError.
Decoding: convert to RuneError, consume one byte.

This requires changing:
        package unicode/utf8
        runtime for range over string
Also added utf8.ValidRune and fixed bug in utf.RuneLen.

Fixes #3927.

R=golang-dev, rsc, bsiegert
CC=golang-dev
https://golang.org/cl/6458099
2012-08-08 14:01:23 -07:00
Shenghou Ma
0157c72d13 runtime: inline several float64 routines to speed up complex128 division
Depends on CL 6197045.

Result obtained on Core i7 620M, Darwin/amd64:
benchmark                       old ns/op    new ns/op    delta
BenchmarkComplex128DivNormal           57           28  -50.78%
BenchmarkComplex128DivNisNaN           49           15  -68.90%
BenchmarkComplex128DivDisNaN           49           15  -67.88%
BenchmarkComplex128DivNisInf           40           12  -68.50%
BenchmarkComplex128DivDisInf           33           13  -61.06%

Result obtained on Core i7 620M, Darwin/386:
benchmark                       old ns/op    new ns/op    delta
BenchmarkComplex128DivNormal           89           50  -44.05%
BenchmarkComplex128DivNisNaN          307          802  +161.24%
BenchmarkComplex128DivDisNaN          309          788  +155.02%
BenchmarkComplex128DivNisInf          278          237  -14.75%
BenchmarkComplex128DivDisInf           46           22  -52.46%

Result obtained on 700MHz OMAP4460, Linux/ARM:
benchmark                       old ns/op    new ns/op    delta
BenchmarkComplex128DivNormal         1557          465  -70.13%
BenchmarkComplex128DivNisNaN         1443          220  -84.75%
BenchmarkComplex128DivDisNaN         1481          218  -85.28%
BenchmarkComplex128DivNisInf          952          216  -77.31%
BenchmarkComplex128DivDisInf          861          231  -73.17%

The 386 version has a performance regression, but as we have
decided to use SSE2 instead of x87 FPU for 386 too (issue 3912),
I won't address this issue.

R=dsymonds, mchaten, iant, dave, mtj, rsc, r
CC=golang-dev
https://golang.org/cl/6024045
2012-08-07 23:45:50 +08:00
Shenghou Ma
6e9506a7b4 math, runtime: use a NaN that matches gcc's
our old choice is not working properly at least on VFPv2 in
ARM1136JF-S (it's not preserved across float64->float32 conversions).

        Fixes #3745.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6344078
2012-08-07 09:57:14 +08:00
Shenghou Ma
41645847b4 runtime: remove unnecessary ROUND in alg.c
Introduced in CL 6452046.

R=golang-dev, nigeltao, dave
CC=golang-dev
https://golang.org/cl/6459051
2012-08-07 09:49:56 +08:00
Alexey Borzenkov
a108369c83 syscall: return EINVAL when string arguments have NUL characters
Since NUL usually terminates strings in underlying syscalls, allowing
it when converting string arguments is a security risk, especially
when dealing with filenames. For example, a program might reason that
filename like "/root/..\x00/" is a subdirectory or "/root/" and allow
access to it, while underlying syscall will treat "\x00" as an end of
that string and the actual filename will be "/root/..", which might
be unexpected. Returning EINVAL when string arguments have NUL in
them makes sure this attack vector is unusable.

R=golang-dev, r, bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6458050
2012-08-05 17:24:32 -04:00
Rémy Oudompheng
77f3e189d2 runtime: faster string equality.
benchmark                                old ns/op    new ns/op    delta
BenchmarkCompareStringEqual                     51           35  -30.20%
BenchmarkCompareStringIdentical                 51            7  -85.71%
BenchmarkCompareStringSameLength                25           18  -28.29%
BenchmarkCompareStringDifferentLength            2            2   +1.46%

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6450092
2012-08-05 21:35:41 +02:00
Michał Derkacz
dee5adcf74 5a, 5l, math: Add support for ABSD, ABSF floating point instructions.
R=golang-dev, dave, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6225051
2012-08-03 16:15:11 -04:00
Shenghou Ma
e07958f7df runtime: round return value address in runtime.equal
Fixes #3866.

R=rsc, r, nigeltao
CC=golang-dev
https://golang.org/cl/6452046
2012-07-31 23:02:46 -04:00
Benny Siegert
b4402a49b6 runtime/cgo: fix netbsd build
Copy over freebsd.c to netbsd.c.

Fixes #3823.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6398045
2012-07-29 18:51:06 -04:00
Ian Lance Taylor
b9e051e82d runtime: ignore signal 33 == SIGSETXID on GNU/Linux
When a cgo program calls setuid, setgid, etc., the GNU/Linux
pthread library sends signal SIGSETXID to each thread to tell
it to update its UID info.  If Go is permitted to intercept
the default SIGSETXID signal handler, the program will hang.

This patch tells the runtime package to not try to intercept
SIGSETXID on GNU/Linux.  This will be odd if a Go program
wants to try to use that signal, but it means that cgo
programs that call setuid, etc., won't hang.

Fixes #3871.

R=rsc, r, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6455050
2012-07-26 22:46:20 -07:00
Dmitriy Vyukov
a54f920bfe runtime: move panic/defer/recover-related stuff to a separate file
Move panic/defer/recover-related stuff from proc.c/runtime.c to a new file panic.c.
No semantic changes.
proc.c is 1800+ LOC and is a bit difficult to work with.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6343071
2012-07-04 14:52:51 +04:00
Dmitriy Vyukov
a0c688331f runtime: refactor proc.c
1. Rename 'g' and 'm' local vars to 'gp' and 'mp' (convention already used in some functions)
'g' and 'm' are global vars that mean current goroutine and current machine,
when they are shadowed by local vars, it's confusing, no ability to debug log both, etc.
2. White-space shuffling.
No semantic changes.
In preparation to bigger changes.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6355061
2012-07-03 12:54:13 +04:00
Nigel Tao
18e86644a3 cmd/gc: cache itab lookup in convT2I.
There may be further savings if convT2I can avoid the function call
if the cache is good and T is uintptr-shaped, a la convT2E, but that
will be a follow-up CL.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2ISmall             43           15  -64.01%
BenchmarkConvT2IUintptr           45           14  -67.48%
BenchmarkConvT2ILarge            130          101  -22.31%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8588997000   8499058000   -1.05%
BenchmarkFannkuch11      5300392000   5358093000   +1.09%
BenchmarkGobDecode         30295580     31040190   +2.46%
BenchmarkGobEncode         18102070     17675650   -2.36%
BenchmarkGzip             774191400    771591400   -0.34%
BenchmarkGunzip           245915100    247464100   +0.63%
BenchmarkJSONEncode       123577000    121423050   -1.74%
BenchmarkJSONDecode       451969800    596256200  +31.92%
BenchmarkMandelbrot200     10060050     10072880   +0.13%
BenchmarkParse             10989840     11037710   +0.44%
BenchmarkRevcomp         1782666000   1716864000   -3.69%
BenchmarkTemplate         798286600    723234400   -9.40%

R=rsc, bradfitz, go.peter.90, daniel.morsing, dave, uriel
CC=golang-dev
https://golang.org/cl/6337058
2012-07-03 09:09:05 +10:00
Dmitriy Vyukov
ed516df4e4 runtime: add freemcache() function
It will be required for scheduler that maintains
GOMAXPROCS MCache's.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6350062
2012-07-01 13:10:01 +04:00
Russ Cox
71643b2fdb runtime: fix string optimization
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6354048
2012-06-27 17:32:41 -04:00
Russ Cox
8744d35dd3 runtime: avoid allocation for "" + x + ""
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6359043
2012-06-27 17:06:49 -04:00
Dmitriy Vyukov
5a5e698c8f runtime: add goroutine creation benchmark
Current results on 2 core darwin/amd64:
BenchmarkGoroutineChain		351 ns/op
BenchmarkGoroutineChain-2	3840 ns/op
BenchmarkGoroutineChain-4	4040 ns/op
BenchmarkConcGoroutineChain	350 ns/op
BenchmarkConcGoroutineChain-2	875 ns/op
BenchmarkConcGoroutineChain-4	2027 ns/op

R=r, rsc
CC=golang-dev
https://golang.org/cl/6332054
2012-06-27 21:57:49 +04:00
Dave Cheney
d1537809ba runtime: add arm soft division and modulo benchmarks
arm soft div and mod performance plays an important part
in runtime performance.

The currently implementation is very stable, but we believe
we can best it. This benchmark provides a reference point.

linux/arm omap4 pandaboard

BenchmarkUint32Div7     10000000               298 ns/op
BenchmarkUint32Div37    10000000               298 ns/op
BenchmarkUint32Div123   10000000               298 ns/op
BenchmarkUint32Div763   10000000               298 ns/op
BenchmarkUint32Div1247  10000000               299 ns/op
BenchmarkUint32Div9305  10000000               298 ns/op
BenchmarkUint32Div13307 10000000               298 ns/op
BenchmarkUint32Div52513 10000000               298 ns/op
BenchmarkUint32Div60978747      10000000               298 ns/op
BenchmarkUint32Div106956295     10000000               297 ns/op
BenchmarkUint32Mod7     10000000               280 ns/op
BenchmarkUint32Mod37    10000000               280 ns/op
BenchmarkUint32Mod123   10000000               280 ns/op
BenchmarkUint32Mod763   10000000               280 ns/op
BenchmarkUint32Mod1247  10000000               280 ns/op
BenchmarkUint32Mod9305  10000000               280 ns/op
BenchmarkUint32Mod13307 10000000               280 ns/op
BenchmarkUint32Mod52513 10000000               280 ns/op
BenchmarkUint32Mod60978747      10000000               280 ns/op
BenchmarkUint32Mod106956295     10000000               280 ns/op

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6258067
2012-06-26 08:58:00 +10:00
Dave Cheney
3a50bc1a24 runtime: remove memset/memclr shim
This CL resolves https://golang.org/cl/6300043/#msg3
by renaming memset_arm.s to memclr_arm.s and merging the function
of the same name from asm_arm.s.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6336054
2012-06-25 23:01:34 +10:00
Dmitriy Vyukov
902911bcff runtime: fix potential GC deadlock
The issue seems to not be triggered right now,
but I've seen the deadlock after some other legal
modifications to runtime.
So I think we are safer this way.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6339051
2012-06-25 11:08:09 +04:00
Russ Cox
bca01cd0bf runtime: detect hash map collision problems
This can only happen if the hash function we're using is getting
far more than it's fair share of collisions, but that has happened
to us repeatedly as we've expanded the allowed use cases for
hash tables (issue 1544, issue 2609, issue 2630, issue 2883, issue 3695).
Maybe this will help the next time we try something new.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6306083
2012-06-24 19:47:50 -04:00
Dave Cheney
e34079bb59 runtime: avoid r9/r10 during memmove
Fixes #3718.

Requires CL 6300043.

R=rsc, minux.ma, extraterrestrial.neighbour
CC=golang-dev
https://golang.org/cl/6305100
2012-06-25 08:28:30 +10:00
Dave Cheney
07826038c3 runtime: avoid r9/r10 during memset
Partially fixes issue 3718.

R=golang-dev, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6300043
2012-06-25 07:59:50 +10:00
Shenghou Ma
a033e36766 runtime: fix struct Sigaction for Linux/386
We need to use kernel headers to generate defs_linux_$GOARCH.h

R=golang-dev, dave, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6296091
2012-06-24 01:41:17 +08:00
Shenghou Ma
d4c4f4d2c4 runtime: fix struct Sigaction for Linux/ARM
if we were to use sizeof(sa.sa_mask) instead of 8 as the last argument
        to rt_sigaction, we would have already fixed this bug, so also updated
        Linux/386 and Linux/amd64 files to use that; also test the return value
        of rt_sigaction.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6297087
2012-06-20 01:17:03 +08:00
Nigel Tao
8f84328fdc cmd/gc: inline convT2E when T is uintptr-shaped.
GOARCH=amd64 benchmarks

src/pkg/runtime
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2ESmall             10           10   +1.00%
BenchmarkConvT2EUintptr            9            0  -92.07%
BenchmarkConvT2EBig               74           74   -0.27%
BenchmarkConvT2I                  27           26   -3.62%
BenchmarkConvI2E                   4            4   -7.05%
BenchmarkConvI2I                  20           19   -2.99%

test/bench/go1
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5930908000   5937260000   +0.11%
BenchmarkFannkuch11      3927057000   3933556000   +0.17%
BenchmarkGobDecode         21998090     21870620   -0.58%
BenchmarkGobEncode         12725310     12734480   +0.07%
BenchmarkGzip             567617600    567892800   +0.05%
BenchmarkGunzip           178284100    178706900   +0.24%
BenchmarkJSONEncode        87693550     86794300   -1.03%
BenchmarkJSONDecode       314212600    324115000   +3.15%
BenchmarkMandelbrot200      7016640      7073766   +0.81%
BenchmarkParse              7852100      7892085   +0.51%
BenchmarkRevcomp         1285663000   1286147000   +0.04%
BenchmarkTemplate         566823800    567606200   +0.14%

I'm not entirely sure why the JSON* numbers have changed, but
eyeballing the profile suggests that it could be spending less
and more time in runtime.{new,old}stack, so it could simply be
stack-split boundary noise.

R=rsc, dave, bsiegert, dsymonds
CC=golang-dev
https://golang.org/cl/6280049
2012-06-14 10:43:20 +10:00
Jan Ziak
51fe5444fa runtime: improved continuity in hash computation
Fixes #3695.

R=r, dave, rsc
CC=golang-dev
https://golang.org/cl/6304062
2012-06-13 15:52:32 -04:00
Dave Cheney
0b09425b5c runtime: use uintptr where possible in malloc stats
linux/arm OMAP4 pandaboard

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17   68723297000  37026214000  -46.12%
BenchmarkFannkuch11     34962402000  35958435000   +2.85%
BenchmarkGobDecode        137298600    124182150   -9.55%
BenchmarkGobEncode         60717160     60006700   -1.17%
BenchmarkGzip            5647156000   5550873000   -1.70%
BenchmarkGunzip          1196350000   1198670000   +0.19%
BenchmarkJSONEncode       863012800    782898000   -9.28%
BenchmarkJSONDecode      3312989000   2781800000  -16.03%
BenchmarkMandelbrot200     45727540     45703120   -0.05%
BenchmarkParse             74781800     59990840  -19.78%
BenchmarkRevcomp          140043650    139462300   -0.42%
BenchmarkTemplate        6467682000   5832153000   -9.83%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode             5.59         6.18    1.11x
BenchmarkGobEncode            12.64        12.79    1.01x
BenchmarkGzip                  3.44         3.50    1.02x
BenchmarkGunzip               16.22        16.19    1.00x
BenchmarkJSONEncode            2.25         2.48    1.10x
BenchmarkJSONDecode            0.59         0.70    1.19x
BenchmarkParse                 0.77         0.97    1.26x
BenchmarkRevcomp              18.15        18.23    1.00x
BenchmarkTemplate              0.30         0.33    1.10x

darwin/386 core duo

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17   10591616577   9678245733   -8.62%
BenchmarkFannkuch11     10758473315  10749303846   -0.09%
BenchmarkGobDecode         34379785     34121250   -0.75%
BenchmarkGobEncode         23523721     23475750   -0.20%
BenchmarkGzip            2486191492   2446539568   -1.59%
BenchmarkGunzip           444179328    444250293   +0.02%
BenchmarkJSONEncode       221138507    219757826   -0.62%
BenchmarkJSONDecode      1056034428   1048975133   -0.67%
BenchmarkMandelbrot200     19862516     19868346   +0.03%
BenchmarkRevcomp         3742610872   3724821662   -0.48%
BenchmarkTemplate         960283112    944791517   -1.61%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            22.33        22.49    1.01x
BenchmarkGobEncode            32.63        32.69    1.00x
BenchmarkGzip                  7.80         7.93    1.02x
BenchmarkGunzip               43.69        43.68    1.00x
BenchmarkJSONEncode            8.77         8.83    1.01x
BenchmarkJSONDecode            1.84         1.85    1.01x
BenchmarkRevcomp              67.91        68.24    1.00x
BenchmarkTemplate              2.02         2.05    1.01x

R=rsc, 0xe2.0x9a.0x9b, mirtchovski
CC=golang-dev, minux.ma
https://golang.org/cl/6297047
2012-06-08 17:35:14 -04:00
Alex Brainman
f54d61061c runtime: include "typekind.h" to fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6305059
2012-06-07 09:37:05 +10:00
Jan Ziak
ede6718cd7 runtime: move type kinds into a separate file
R=rsc
CC=golang-dev
https://golang.org/cl/6285047
2012-06-06 17:20:02 -04:00
Joel Sing
2cb7498455 runtime: fix tv_sec handling for netbsd/386
On netbsd/386, tv_sec is a 64-bit integer for both timeval and timespec.
Fix the time handling code so that it works correctly.

R=golang-dev, rsc, m4dh4tt3r
CC=golang-dev
https://golang.org/cl/6256056
2012-06-06 20:39:27 +10:00
Russ Cox
3a66bc415e runtime: use OS X vsyscall for gettimeofday (amd64)
Thanks to Dave Cheney for the magic words "comm page".

benchmark       old ns/op    new ns/op    delta
BenchmarkNow          197           33  -83.05%

This should make profiling a little better on OS X.
The raw time saved is unlikely to matter: what likely matters
more is that it seems like OS X sends profiling signals on the
way out of system calls more often than it should; avoiding
the system call should increase the accuracy of cpu profiles.

The 386 version would be similar but needs to do different
math for CPU speeds less than 1 GHz. (Apparently Apple has
never shipped a 64-bit CPU with such a slow clock.)

R=golang-dev, bradfitz, dave, minux.ma, r
CC=golang-dev
https://golang.org/cl/6275056
2012-06-05 16:24:37 -04:00
Russ Cox
c7be4defe3 runtime: use OS X vsyscall for gettimeofday (386)
amd64 was done in CL 6275056.

We don't attempt to handle machines with clock speeds
less than 1 GHz. Those will fall back to the system call.

benchmark       old ns/op    new ns/op    delta
BenchmarkNow          364           38  -89.53%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6307045
2012-06-05 16:23:30 -04:00
Dave Cheney
09f48db3e1 runtime: use uintptr for block length in scanblock
Using an int64 for a block size doesn't make
sense on 32bit platforms but extracts a performance
penalty dealing with double word quantities on Arm.

linux/arm

benchmark                 old ns/op    new ns/op    delta
BenchmarkGobDecode        155401600    144589300   -6.96%
BenchmarkGobEncode         72772220     62460940  -14.17%
BenchmarkGzip               5822632      2604797  -55.26%
BenchmarkGunzip              326321       151721  -53.51%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode             4.94         5.31    1.07x
BenchmarkGobEncode            10.55        12.29    1.16x

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6272047
2012-06-05 18:55:14 +10:00
Joel Sing
5131deeeb2 cgo: enable cgo on netbsd/386 and netbsd/amd64
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6261056
2012-06-05 01:43:04 +10:00
Luuk van Dijk
40af78c19e cmd/gc: inline slice[arr,str] in the frontend (mostly).
R=rsc, ality, rogpeppe, minux.ma, dave
CC=golang-dev
https://golang.org/cl/5966075
2012-06-02 22:50:57 -04:00
Shenghou Ma
e8265f18e6 runtime: remove unnecessary macros in vlop_arm.s
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6270045
2012-06-03 04:03:09 +08:00
Jan Ziak
65e61d5770 runtime: add (unused for now) gc field to type information
R=rsc
CC=golang-dev
https://golang.org/cl/6255074
2012-06-02 14:02:44 -04:00
Rémy Oudompheng
baf91c313f runtime: lower memory overhead of heap profiling.
The previous code was preparing arrays of entries that would be
filled if there was one entry every 128 bytes. Moving to a 4096
byte interval reduces the overhead per megabyte of address space
to 2kB from 64kB (on 64-bit systems).
The performance impact will be negative for very small MemProfileRate.

test/bench/garbage/tree2 -heapsize 800000000 (default memprofilerate)
Before: mprof 65993056 bytes (1664 bucketmem + 65991392 addrmem)
After:  mprof  1989984 bytes (1680 bucketmem +  1988304 addrmem)

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6257069
2012-05-31 23:30:55 +02:00
Rémy Oudompheng
c4a814f2da runtime/pprof, misc/pprof: correct profile of total allocations.
The previous heap profile format did not include buckets with
zero used bytes. Also add several missing MemStats fields in
debug mode.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6249068
2012-05-31 07:57:49 +02:00
Joel Sing
deb93b0f7b runtime: always initialise procid on netbsd
The correct procid is needed for unparking LWPs on NetBSD - always
initialise procid in minit() so that cgo works correctly. The non-cgo
case already works correctly since procid is initialised via
lwp_create().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6257071
2012-05-31 03:27:04 +10:00
Jan Ziak
334bf95f9e runtime: update field types in preparation for GC changes
R=rsc, remyoudompheng, minux.ma, ality
CC=golang-dev
https://golang.org/cl/6242061
2012-05-30 13:07:52 -04:00
Jan Ziak
46d7d5fcf5 runtime: hide symbol table from garbage collector
R=rsc
CC=golang-dev
https://golang.org/cl/6243059
2012-05-30 13:04:48 -04:00
Alex Brainman
994cdcea18 runtime: disable new TestCrashHandle on freebsd to fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/6256069
2012-05-30 16:41:15 +10:00
Rémy Oudompheng
348087877c runtime: do not unset the special bit after finalization.
A block with finalizer might also be profiled. The special bit
is needed to unregister the block from the profile. It will be
unset only when the block is freed.

Fixes #3668.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6249066
2012-05-30 08:04:11 +02:00
Alex Brainman
afe0e97aa6 runtime: handle windows exceptions, even in cgo programs
Fixes #3543.

R=golang-dev, kardianos, rsc
CC=golang-dev, hectorchu, vcc.163
https://golang.org/cl/6245063
2012-05-30 15:10:54 +10:00
Russ Cox
c1b53d43e8 merge unexpected branch 2012-05-29 14:37:41 -04:00
Dmitriy Vyukov
a0efca84e6 time: fix deadlock in Sleep(0)
See time/sleep_test.go for repro.

R=golang-dev, r, rsc
CC=golang-dev, patrick.allen.higgins
https://golang.org/cl/6250072
2012-05-29 22:30:56 +04:00
Russ Cox
6dbaa206fb runtime: replace runtime·rnd function with ROUND macro
It's sad to introduce a new macro, but rnd shows up consistently
in profiles, and the function call overwhelms the two arithmetic
instructions it performs.

R=r
CC=golang-dev
https://golang.org/cl/6260051
2012-05-29 14:02:29 -04:00
Joel Sing
fb32d60cd1 runtime: make go work on netbsd/386
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6254055
2012-05-30 02:52:50 +10:00
Russ Cox
bf18d57d4a runtime: handle and test large map values
This is from CL 5451105 but was dropped from that CL.
See also CL 6137051.

The only change compared to 5451105 is to check for
h != nil in reflect·mapiterinit; allowing use of nil maps
must have happened after that original CL.

Fixes #3573.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6215078
2012-05-24 22:41:07 -04:00
Rob Pike
11c1b1f96b runtime: fix docs for Caller and Callers
The previous attempt to explain this got it backwards (all the more reason to be
sad we couldn't make the two functions behave the same).

Fixes #3669.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6249051
2012-05-24 14:15:43 -07:00
Dmitriy Vyukov
b0702bd0db runtime: faster GC mark phase
Also bump MaxGcproc to 8.

benchmark             old ns/op    new ns/op    delta
Parser               3796323000   3763880000   -0.85%
Parser-2             3591752500   3518560250   -2.04%
Parser-4             3423825250   3334955250   -2.60%
Parser-8             3304585500   3267014750   -1.14%
Parser-16            3313615750   3286160500   -0.83%

Tree                  984128500    942501166   -4.23%
Tree-2                932564444    883266222   -5.29%
Tree-4                835831000    799912777   -4.30%
Tree-8                819238500    789717333   -3.73%
Tree-16               880837833    837840055   -5.13%

Tree2                 604698100    579716900   -4.13%
Tree2-2               372414500    356765200   -4.20%
Tree2-4               187488100    177455900   -5.56%
Tree2-8               136315300    102086700  -25.11%
Tree2-16               93725900     76705800  -22.18%

ParserPause           157441210    166202783   +5.56%
ParserPause-2          93842650     85199900   -9.21%
ParserPause-4          56844404     53535684   -5.82%
ParserPause-8          35739446     30767613  -16.15%
ParserPause-16         32718255     27212441  -16.83%

TreePause              29610557     29787725   +0.60%
TreePause-2            24001659     20674421  -13.86%
TreePause-4            15114887     12842781  -15.03%
TreePause-8            13128725     10741747  -22.22%
TreePause-16           16131360     12506901  -22.47%

Tree2Pause           2673350920   2651045280   -0.83%
Tree2Pause-2         1796999200   1709350040   -4.88%
Tree2Pause-4         1163553320   1090706480   -6.67%
Tree2Pause-8          987032520    858916360  -25.11%
Tree2Pause-16         864758560    809567480   -6.81%

ParserLastPause       280537000    289047000   +3.03%
ParserLastPause-2     183030000    166748000   -8.90%
ParserLastPause-4     105817000     91552000  -13.48%
ParserLastPause-8      65127000     53288000  -18.18%
ParserLastPause-16     45258000     38334000  -15.30%

TreeLastPause          45072000     51449000  +12.39%
TreeLastPause-2        39269000     37866000   -3.57%
TreeLastPause-4        23564000     20649000  -12.37%
TreeLastPause-8        20881000     15807000  -24.30%
TreeLastPause-16       23297000     17309000  -25.70%

Tree2LastPause       6046912000   5797120000   -4.13%
Tree2LastPause-2     3724034000   3567592000   -4.20%
Tree2LastPause-4     1874831000   1774524000   -5.65%
Tree2LastPause-8     1363108000   1020809000  -12.79%
Tree2LastPause-16     937208000    767019000  -22.18%

R=rsc, 0xe2.0x9a.0x9b
CC=golang-dev
https://golang.org/cl/6223050
2012-05-24 10:55:50 +04:00
Joel Sing
5a043de746 runtime: make go work on netbsd/amd64
R=golang-dev, rsc, devon.odell
CC=golang-dev
https://golang.org/cl/6222044
2012-05-24 11:33:11 +10:00
Shenghou Ma
fb3a1b6821 runtime: support conditional execution in ARM softfloat
Fixes #3638.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6213057
2012-05-23 02:00:40 +08:00
Dmitriy Vyukov
845aa1fc2c runtime: faster GC sweep phase
benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               3731065750   3715543750   -0.41%
garbage.BenchmarkParser-2             3631299750   3495248500   -3.75%
garbage.BenchmarkParser-4             3386486000   3339353000   -1.39%
garbage.BenchmarkParser-8             3267632000   3286422500   +0.58%
garbage.BenchmarkParser-16            3299203000   3316081750   +0.51%

garbage.BenchmarkTree                  977532888    919453833   -5.94%
garbage.BenchmarkTree-2                919948555    853478000   -7.23%
garbage.BenchmarkTree-4                841329000    790207000   -6.08%
garbage.BenchmarkTree-8                787792777    740380666   -6.01%
garbage.BenchmarkTree-16               899257166    846594555   -5.86%

garbage.BenchmarkTree2                 574876300    571885800   -0.52%
garbage.BenchmarkTree2-2               348162700    345888900   -0.65%
garbage.BenchmarkTree2-4               184912500    179137000   -3.22%
garbage.BenchmarkTree2-8               104243900    103485600   -0.73%
garbage.BenchmarkTree2-16               97269500     85137100  -14.25%

garbage.BenchmarkParserPause           141101976    157746974  +11.80%
garbage.BenchmarkParserPause-2         103096051     83043048  -19.45%
garbage.BenchmarkParserPause-4          52153133     45951111  -11.89%
garbage.BenchmarkParserPause-8          36730190     38901024   +5.91%
garbage.BenchmarkParserPause-16         32678875     29578585   -9.49%

garbage.BenchmarkTreePause              29487065     29648439   +0.55%
garbage.BenchmarkTreePause-2            22443494     21306159   -5.07%
garbage.BenchmarkTreePause-4            15799691     14985647   -5.15%
garbage.BenchmarkTreePause-8            10768112     9531420   -12.97%
garbage.BenchmarkTreePause-16           16329891     15205158   -6.89%

garbage.BenchmarkTree2Pause           2586957240   2577533200   -0.36%
garbage.BenchmarkTree2Pause-2         1683383760   1673923800   -0.56%
garbage.BenchmarkTree2Pause-4         1102860320   1074040280   -2.68%
garbage.BenchmarkTree2Pause-8          902627920    886122400   -1.86%
garbage.BenchmarkTree2Pause-16         856470920    804152320   -6.50%

garbage.BenchmarkParserLastPause       277316000    280839000   +1.25%
garbage.BenchmarkParserLastPause-2     179446000    163687000   -8.78%
garbage.BenchmarkParserLastPause-4     106752000     94144000  -11.81%
garbage.BenchmarkParserLastPause-8      57758000     61640000   +6.72%
garbage.BenchmarkParserLastPause-16     51235000     42552000  -16.95%

garbage.BenchmarkTreeLastPause          45244000     50786000  +12.25%
garbage.BenchmarkTreeLastPause-2        37163000     34654000   -6.75%
garbage.BenchmarkTreeLastPause-4        24178000     21967000   -9.14%
garbage.BenchmarkTreeLastPause-8        20390000     15648000  -30.30%
garbage.BenchmarkTreeLastPause-16       22398000     20180000   -9.90%

garbage.BenchmarkTree2LastPause       5748706000   5718809000   -0.52%
garbage.BenchmarkTree2LastPause-2     3481570000   3458844000   -0.65%
garbage.BenchmarkTree2LastPause-4     1849073000   1791330000   -3.22%
garbage.BenchmarkTree2LastPause-8     1042375000   1034811000   -0.73%
garbage.BenchmarkTree2LastPause-16     972637000    851323000  -14.25%

There is also visible improvement in consumed CPU time:
tree2 -heapsize=8000000000 -cpus=12
before: 248.74user 6.36system 0:52.74elapsed 483%CPU
after:  229.86user 6.33system 0:51.08elapsed 462%CPU
-1.66s of real time, but -18.91s of consumed CPU time

R=golang-dev
CC=golang-dev
https://golang.org/cl/6215065
2012-05-22 13:35:52 -04:00
Russ Cox
85266dfd4d runtime: relax TestGcSys
This fixes occasional 64-bit failures.
Maybe it will fix the 32-bit failures too,
so re-enable on 32-bit for now.

R=golang-dev, bradfitz, r, dvyukov
CC=golang-dev
https://golang.org/cl/6218050
2012-05-22 00:07:13 -04:00
Andrew Gerrand
283a3ddab8 runtime: disable gc test on non-amd64 systems
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6210062
2012-05-17 11:34:28 +10:00
Akshat Kumar
f5752848fd pkg/runtime: Fix semasleep on Plan 9
With the timed semacquire patch
(kernel-tsemacquire) for Plan 9,
we can now properly do a timed
wait for the semaphore, in
semasleep.

R=golang-dev, rsc, rminnich, ality, r
CC=0intro, golang-dev, john, mirtchovski
https://golang.org/cl/6197046
2012-05-16 15:09:28 -07:00
Joel Sing
efa67b2c55 runtime: implement getcontext and sigprocmask for netbsd
Implement getcontext and sigprocmask for NetBSD - these will soon be
used by the thread handling code.

Also fix netbsd/386 signal handling - there is no sigreturn, just
return so that we hit the trampoline.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6215049
2012-05-16 04:32:49 +10:00
Joel Sing
0b7bcb84e3 runtime: fix netbsd syscalls
Use correct system calls/syscall numbers for NetBSD.

R=golang-dev, for.go.yong, rsc
CC=golang-dev
https://golang.org/cl/6200070
2012-05-16 03:33:37 +10:00
Joel Sing
4a5a5b20a5 runtime: fix netbsd signal handling
Update/correct NetBSD signal handling - most of this is needed due to
the correctly generated runtime definitions.

R=golang-dev, m4dh4tt3r, rsc
CC=golang-dev
https://golang.org/cl/6195079
2012-05-16 01:53:26 +10:00
Joel Sing
8a9edcf790 runtime: fix netbsd runtime defs
Fix and regenerate runtime defs for NetBSD.

Whilst the mcontext struct can be handled across architectures,
the registers are provided as defines that index an array, rather
than as members of the struct. Since these are architecture
dependent, include them via a defs_netbsd_<arch>.go file.

R=golang-dev, m4dh4tt3r, rsc
CC=golang-dev
https://golang.org/cl/6190070
2012-05-16 01:52:20 +10:00
Jan Ziak
773685b4a3 runtime: fix counting of free objects
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6206056
2012-05-15 11:48:58 -04:00
Dmitriy Vyukov
01826280eb runtime: refactor helpgc functionality in preparation for parallel GC
Parallel GC needs to know in advance how many helper threads will be there.
Hopefully it's the last patch before I can tackle parallel sweep phase.
The benchmarks are unaffected.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6200064
2012-05-15 19:10:16 +04:00
Joel Sing
b42ebb6fbf runtime: fix TLS handling for netbsd
Set the TLS base using the _lwp_setprivate() syscall, instead of via
sysarch(). NetBSD tracks the pointer passed to _lwp_setprivate() and
restores this value when restoring mcontext. If sysarch() is used
directly, restoring an mcontext trashes the FS/GS value, resulting
in a segfault when we next try to access the TLS.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6206062
2012-05-15 11:26:05 +10:00
Dmitriy Vyukov
eb0bc8164a runtime: revert MaxGcproc from 16 to 4
The change accidentally come in with this revision:
https://code.google.com/p/go/source/detail?spec=svn345cbca96c5550f2e89bc727703301933802923c&r=14c38c23c819a17021b1808cf4a34ef3a1a17db5

R=golang-dev
CC=golang-dev
https://golang.org/cl/6195073
2012-05-11 13:30:34 +04:00
Dmitriy Vyukov
95643647ae runtime: add parallel for algorithm
This is factored out part of:
https://golang.org/cl/5279048/
(parallel GC)

R=bsiegert, mpimenov, rsc, minux.ma, r
CC=golang-dev
https://golang.org/cl/5986054
2012-05-11 10:50:03 +04:00
Shenghou Ma
aa45e52e74 runtime: fix complex division benchmarks
we can't add the division result to n during iteration, because it might
turn n into NaN or Inf.

R=golang-dev, rsc, iant, iant
CC=golang-dev
https://golang.org/cl/6197045
2012-05-11 03:09:14 +08:00
Joel Sing
5374ded1f3 runtime: fix syscalls for netbsd
Use correct syscall numbers and arguments for NetBSD.
Provide a trampoline for signal returns (using signal API 3).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6209048
2012-05-11 03:48:43 +10:00
Joel Sing
38445ca089 runtime: fix netbsd sigaction struct
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6198063
2012-05-11 03:48:16 +10:00
Shenghou Ma
a642ca4930 runtime: get per-process random number from auxv for hash table
Decode AT_RANDOM, AT_HWCAP, and AT_PLATFORM.
This CL only make use of AT_RANDOM, but future CLs will make use of the others.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/5978051
2012-05-05 01:59:14 +08:00
Shenghou Ma
a29304bfb8 runtime: fix c compiler warning
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6185047
2012-05-05 01:39:09 +08:00
Shenghou Ma
018bcc3535 runtime, misc/cgo/test: fix build for Linux/ARM
1. In CL 5989057, I made a mistake in the last minute change.
"MOVW.W R4, -4(SP)" should really be "MOVW.W R4, -4(R13)",
as 5l will rewrite offset for SP.
2. misc/cgo/test/issue1560.go tests for parallel sleep of 1s,
but on ARM, the deadline is frequently missed, so change sleep
time to 2s on ARM.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6202043
2012-05-05 01:35:13 +08:00
Akshat Kumar
ccdca2cd6b pkg/runtime: Plan 9 signal handling in Go
This adds proper note handling for Plan 9,
and fixes the issue of properly killing go procs.
Without this change, the first go proc that dies
(using runtime·exit()) would kill all the running
go procs. Proper signal handling is needed.

R=golang-dev, ality, rminnich, rsc
CC=golang-dev, john, mirtchovski
https://golang.org/cl/5617048
2012-05-04 03:48:34 -07:00
Shenghou Ma
5cffce611a runtime: cgo support for Linux/ARM
Part 2 of CL 5601044 (cgo: Linux/ARM support)

R=dave, rsc
CC=golang-dev
https://golang.org/cl/5989057
2012-05-04 18:20:09 +08:00
Russ Cox
d42495aa80 cmd/cc: add PREFETCH built-in (like SET, USED)
This makes it possible to inline the prefetch of upcoming
memory addresses during garbage collection, instead of
needing to flush registers, make a function call, and
reload registers.  On garbage collection-heavy workloads,
this results in a 5% speedup.

Fixes #3493.

R=dvyukov, ken, r, dave
CC=golang-dev
https://golang.org/cl/5990066
2012-05-02 16:22:56 -04:00
Dmitriy Vyukov
c1c851bbe8 runtime: avoid unnecessary zeroization of huge memory blocks
+move zeroization out of the heap mutex

R=golang-dev, iant, rsc
CC=golang-dev
https://golang.org/cl/6094050
2012-05-02 18:01:11 +04:00
Shenghou Ma
44fd1d1a6a runtime: give proper messages when user defined DYLD_INSERT_LIBRARIES on Darwin
also gives clear error when bsdthread_register fails on Darwin
       Fixes #2992.

R=rsc, krautz
CC=golang-dev
https://golang.org/cl/5966067
2012-04-30 15:55:07 -04:00
Joel Sing
689d5b9163 runtime: use __tfork() syscall on openbsd
Switch from using the rfork() syscall on OpenBSD, to the __tfork()
syscall.  The __tfork() syscall is the preferred way of creating
system threads and the rfork() syscall has recently been removed.

Note: this will break compatibility with OpenBSD releases prior to 5.1.

R=golang-dev, bradfitz, devon.odell, rsc
CC=golang-dev
https://golang.org/cl/6037048
2012-04-26 00:08:02 +10:00
Shenghou Ma
0f80050542 runtime: fix runtime.Breakpoint for ARM
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6100053
2012-04-24 23:19:44 +08:00
Michael Chaten
32c3a626da runtime: add benchmark for complex128 division
R=golang-dev, dave, rsc
CC=golang-dev, minux.ma
https://golang.org/cl/6070043
2012-04-21 13:24:41 +10:00
Ian Lance Taylor
244706bd0f runtime: disable memory profiler in gc_test
This lets the test pass on PPC64 GNU/Linux, which uses a much
larger page size and thus uses more memory to hold blocks
allocated for memory profiling.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6048054
2012-04-20 11:36:06 -07:00
Joel Sing
99fc281743 runtime: update defs for openbsd
Update runtime defs for openbsd. Add struct __tfork, which will be
needed by an upcoming change.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6007050
2012-04-17 02:35:41 +10:00
Dmitriy Vyukov
4945fc8e40 runtime: speedup GC sweep phase (batch free)
benchmark                             old ns/op    new ns/op    delta
garbage.BenchmarkParser              4370050250   3779668750  -13.51%
garbage.BenchmarkParser-2            3713087000   3628771500   -2.27%
garbage.BenchmarkParser-4            3519755250   3406349750   -3.22%
garbage.BenchmarkParser-8            3386627750   3319144000   -1.99%

garbage.BenchmarkTree                 493585529    408102411  -17.32%
garbage.BenchmarkTree-2               500487176    402285176  -19.62%
garbage.BenchmarkTree-4               473238882    361484058  -23.61%
garbage.BenchmarkTree-8               486977823    368334823  -24.36%

garbage.BenchmarkTree2                 31446600     31203200   -0.77%
garbage.BenchmarkTree2-2               21469000     21077900   -1.82%
garbage.BenchmarkTree2-4               11007600     10899100   -0.99%
garbage.BenchmarkTree2-8                7692400      7032600   -8.58%

garbage.BenchmarkParserPause          241863263    163249450  -32.50%
garbage.BenchmarkParserPause-2        120135418    112981575   -5.95%
garbage.BenchmarkParserPause-4         83411552     64580700  -22.58%
garbage.BenchmarkParserPause-8         51870697     42207244  -18.63%

garbage.BenchmarkTreePause             20940474     13147011  -37.22%
garbage.BenchmarkTreePause-2           20115124     11146715  -44.59%
garbage.BenchmarkTreePause-4           17217584      7486327  -56.52%
garbage.BenchmarkTreePause-8           18258845      7400871  -59.47%

garbage.BenchmarkTree2Pause           174067190    172674190   -0.80%
garbage.BenchmarkTree2Pause-2         131175809    130615761   -0.43%
garbage.BenchmarkTree2Pause-4          95406666     93972047   -1.50%
garbage.BenchmarkTree2Pause-8          86056095     85334952   -0.84%

garbage.BenchmarkParserLastPause      329932000    324790000   -1.56%
garbage.BenchmarkParserLastPause-2    209383000    210456000   +0.51%
garbage.BenchmarkParserLastPause-4    113981000    112921000   -0.93%
garbage.BenchmarkParserLastPause-8     77967000     76625000   -1.72%

garbage.BenchmarkTreeLastPause         29752000     18444000  -38.01%
garbage.BenchmarkTreeLastPause-2       24274000     14766000  -39.17%
garbage.BenchmarkTreeLastPause-4       19565000      8726000  -55.40%
garbage.BenchmarkTreeLastPause-8       21956000     10530000  -52.04%

garbage.BenchmarkTree2LastPause       314411000    311945000   -0.78%
garbage.BenchmarkTree2LastPause-2     214641000    210836000   -1.77%
garbage.BenchmarkTree2LastPause-4     110024000    108943000   -0.98%
garbage.BenchmarkTree2LastPause-8      76873000     70263000   -8.60%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991049
2012-04-12 12:01:24 +04:00
Dmitriy Vyukov
a5dc7793c0 runtime: add lock-free stack
This is factored out part of the:
https://golang.org/cl/5279048/
(parallel GC)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5993043
2012-04-12 11:49:25 +04:00
Dave Cheney
d8e9b04ca6 runtime: add interface microbenchmarks
2011 Mac Mini, Core i5 @ 2.3Ghz

BenchmarkConvT2E        50000000                40.4 ns/op
BenchmarkConvT2EBig     20000000               107 ns/op
BenchmarkConvT2I        100000000               28.9 ns/op
BenchmarkConvI2E        500000000                5.93 ns/op
BenchmarkConvI2I        100000000               19.0 ns/op
BenchmarkAssertE2T      100000000               14.1 ns/op
BenchmarkAssertE2TBig   100000000               17.8 ns/op
BenchmarkAssertE2I      100000000               21.3 ns/op
BenchmarkAssertI2T      100000000               14.3 ns/op
BenchmarkAssertI2I      100000000               20.8 ns/op
BenchmarkAssertI2E      500000000                5.58 ns/op

Pandaboard, 2 x Omap4 @ 1.2Ghz

BenchmarkConvT2E        10000000               215 ns/op
BenchmarkConvT2EBig      1000000              3697 ns/op
BenchmarkConvT2I         5000000               666 ns/op
BenchmarkConvI2E        50000000                42.4 ns/op
BenchmarkConvI2I         5000000               489 ns/op
BenchmarkAssertE2T      20000000                90.0 ns/op
BenchmarkAssertE2TBig   20000000                91.6 ns/op
BenchmarkAssertE2I       5000000               515 ns/op
BenchmarkAssertI2T      20000000               124 ns/op
BenchmarkAssertI2I       5000000               517 ns/op
BenchmarkAssertI2E      50000000                47.2 ns/op
BenchmarkAssertE2E      50000000                42.7 ns/op

R=minux.ma, rsc, fullung, bsiegert, dsymonds
CC=golang-dev
https://golang.org/cl/5777048
2012-04-11 22:45:44 +10:00
Joel Sing
8cea1bf102 runtime: update openbsd thread related syscalls to match kernel
Update the threxit and thrsleep syscalls to match the ABI of the
OpenBSD 5.1 kernel. These changes are backwards compatible with
older kernels.

Fixes #3311.

R=golang-dev, rsc, devon.odell
CC=golang-dev
https://golang.org/cl/5777079
2012-04-11 22:02:08 +10:00
Shenghou Ma
1a59e6239c 5l, runtime: remove softfloat emulation code when not used
This leads to ~30kB improvement on code size for ARM machines with VFP/NEON.
Example: go test -c math
       GOARM=5  GOARM=6
  Old: 1884200  1839144
  New: 1884165  1805245
  -:        35    33899

R=rsc, bradfitz, dave, kai.backman
CC=golang-dev
https://golang.org/cl/5975060
2012-04-11 04:11:27 +08:00
Akshat Kumar
7056ec6bfd runtime: fix floating point exception on Plan 9
Change 5660047 moved an FLDCW instruction
that disables invalid operand traps into
runtime·asminit, which is called from
runtime·mstart. Thus, runtime·check is being
called prior to setting the appropriate control bits,
which on any QNaN comparison will cause Plan 9
to take an invalid operand trap. This change loads
the control bits (for Plan 9) prior to runtime·check.
Ideally, this should be done before the QNaN checks
on any system, but possibly other kernels simply
don't ever trap on invalid operands.

R=golang-dev, rminnich
CC=golang-dev, john, rsc
https://golang.org/cl/5939045
2012-04-10 15:14:10 -04:00
Quan Yong Zhai
e133ee9538 runtime: unregister the SIGILL handler after ARM EABI test
Part of issue 3381

R=rsc, minux.ma, dave
CC=golang-dev
https://golang.org/cl/5969064
2012-04-10 15:05:22 -04:00
Russ Cox
3d462449f6 8a, 8l: add PREFETCH instructions
R=ken2
CC=golang-dev
https://golang.org/cl/5992082
2012-04-10 10:09:27 -04:00
Russ Cox
35d260fa4c 6a, 6l: add PREFETCH instructions
R=ken2
CC=golang-dev
https://golang.org/cl/5989073
2012-04-10 10:09:09 -04:00
Joel Sing
098b9dcf2f runtime: block signals during thread creation on openbsd
Block signals during thread creation, otherwise the new thread can
receive a signal prior to initialisation completing.

Fixes #3102.

R=golang-dev, rsc, devon.odell, minux.ma
CC=golang-dev
https://golang.org/cl/5757064
2012-04-10 21:57:05 +10:00
Rob Pike
6849c4db0c runtime.Callers: make documentation match code
It is a bug that Caller and Callers disagree about the offset of the skip
parameter. Document the bug.

R=rsc, dsymonds, r, iant
CC=golang-dev
https://golang.org/cl/5976064
2012-04-10 09:47:57 +10:00
Dmitriy Vyukov
342658bbb6 runtime: preparation for parallel GC
make MHeap.allspans an array instead on a linked-list,
it's required for parallel for

benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkTree                  494435529    487962705   -1.31%
garbage.BenchmarkTree-2                499652705    485358000   -2.86%
garbage.BenchmarkTree-4                468482117    454093117   -3.07%
garbage.BenchmarkTree-8                488533235    471872470   -3.41%
garbage.BenchmarkTree-16               507835176    492558470   -3.01%

garbage.BenchmarkTree2                  31453900     31404300   -0.16%
garbage.BenchmarkTree2-2                21440600     21477000   +0.17%
garbage.BenchmarkTree2-4                10982000     11117400   +1.23%
garbage.BenchmarkTree2-8                 7544700      7456700   -1.17%
garbage.BenchmarkTree2-16                7049500      6805700   -3.46%

garbage.BenchmarkParser               4448988000   4453264000   +0.10%
garbage.BenchmarkParser-2             4086045000   4057948000   -0.69%
garbage.BenchmarkParser-4             3677365000   3661246000   -0.44%
garbage.BenchmarkParser-8             3517253000   3540190000   +0.65%
garbage.BenchmarkParser-16            3506562000   3463478000   -1.23%

garbage.BenchmarkTreePause              20969784     21100238   +0.62%
garbage.BenchmarkTreePause-2            20215875     20139572   -0.38%
garbage.BenchmarkTreePause-4            17240709     16683624   -3.23%
garbage.BenchmarkTreePause-8            18196386     17639306   -3.06%
garbage.BenchmarkTreePause-16           20621158     20215056   -1.97%

garbage.BenchmarkTree2Pause            173992142    173872380   -0.07%
garbage.BenchmarkTree2Pause-2          131281904    131366666   +0.06%
garbage.BenchmarkTree2Pause-4           93484952     95109619   +1.74%
garbage.BenchmarkTree2Pause-8           88950523     86533333   -2.72%
garbage.BenchmarkTree2Pause-16          86071238     84089190   -2.30%

garbage.BenchmarkParserPause           135815000    135255952   -0.41%
garbage.BenchmarkParserPause-2          92691523     91451428   -1.34%
garbage.BenchmarkParserPause-4          53392190     51611904   -3.33%
garbage.BenchmarkParserPause-8          36059523     35116666   -2.61%
garbage.BenchmarkParserPause-16         30174300     27340600   -9.39%

garbage.BenchmarkTreeLastPause          28420000     29142000   +2.54%
garbage.BenchmarkTreeLastPause-2        23514000     26779000  +13.89%
garbage.BenchmarkTreeLastPause-4        21773000     18660000  -14.30%
garbage.BenchmarkTreeLastPause-8        24072000     21276000  -11.62%
garbage.BenchmarkTreeLastPause-16       25149000     28541000  +13.49%

garbage.BenchmarkTree2LastPause        314491000    313982000   -0.16%
garbage.BenchmarkTree2LastPause-2      214363000    214715000   +0.16%
garbage.BenchmarkTree2LastPause-4      109778000    111115000   +1.22%
garbage.BenchmarkTree2LastPause-8       75390000     74522000   -1.15%
garbage.BenchmarkTree2LastPause-16      70333000     67880000   -3.49%

garbage.BenchmarkParserLastPause       327247000    326815000   -0.13%
garbage.BenchmarkParserLastPause-2     217039000    212529000   -2.08%
garbage.BenchmarkParserLastPause-4     119722000    111535000   -6.84%
garbage.BenchmarkParserLastPause-8      70806000     69613000   -1.68%
garbage.BenchmarkParserLastPause-16     62813000     48009000  -23.57%

R=rsc, r
CC=golang-dev
https://golang.org/cl/5992055
2012-04-09 13:05:43 +04:00
Dmitriy Vyukov
f09e63a2a0 runtime: add memory prefetching to GC
benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               4448988000   4370531000   -1.76%
garbage.BenchmarkParser-2             4086045000   4023083000   -1.54%
garbage.BenchmarkParser-4             3677365000   3667020000   -0.28%
garbage.BenchmarkParser-8             3517253000   3543946000   +0.76%
garbage.BenchmarkParser-16            3506562000   3512518000   +0.17%

garbage.BenchmarkTree                  494435529    505784058   +2.30%
garbage.BenchmarkTree-2                499652705    502774823   +0.62%
garbage.BenchmarkTree-4                468482117    465713352   -0.59%
garbage.BenchmarkTree-8                488533235    482287000   -1.28%
garbage.BenchmarkTree-16               507835176    500654882   -1.41%

garbage.BenchmarkTree2                  31453900     28804600   -8.42%
garbage.BenchmarkTree2-2                21440600     19065800  -11.08%
garbage.BenchmarkTree2-4                10982000     10009100   -8.86%
garbage.BenchmarkTree2-8                 7544700      6479800  -14.11%
garbage.BenchmarkTree2-16                7049500      6163200  -12.57%

garbage.BenchmarkParserPause           135815000    125360666   -7.70%
garbage.BenchmarkParserPause-2          92691523     84365476   -8.98%
garbage.BenchmarkParserPause-4          53392190     46995809  -11.98%
garbage.BenchmarkParserPause-8          36059523     30998900  -14.03%
garbage.BenchmarkParserPause-16         30174300     27613350   -8.49%

garbage.BenchmarkTreePause              20969784     22568102   +7.62%
garbage.BenchmarkTreePause-2            20215875     20975130   +3.76%
garbage.BenchmarkTreePause-4            17240709     17180666   -0.35%
garbage.BenchmarkTreePause-8            18196386     18205870   +0.05%
garbage.BenchmarkTreePause-16           20621158     20486867   -0.65%

garbage.BenchmarkTree2Pause            173992142    159995285   -8.04%
garbage.BenchmarkTree2Pause-2          131281904    118013714  -10.11%
garbage.BenchmarkTree2Pause-4           93484952     85092666   -8.98%
garbage.BenchmarkTree2Pause-8           88950523     77340809  -13.05%
garbage.BenchmarkTree2Pause-16          86071238     76557952  -11.05%

garbage.BenchmarkParserLastPause       327247000    288205000  -11.93%
garbage.BenchmarkParserLastPause-2     217039000    187336000  -13.69%
garbage.BenchmarkParserLastPause-4     119722000    105069000  -12.24%
garbage.BenchmarkParserLastPause-8      70806000     64755000   -8.55%
garbage.BenchmarkParserLastPause-16     62813000     53486000  -14.85%

garbage.BenchmarkTreeLastPause          28420000     29735000   +4.63%
garbage.BenchmarkTreeLastPause-2        23514000     25427000   +8.14%
garbage.BenchmarkTreeLastPause-4        21773000     19548000  -10.22%
garbage.BenchmarkTreeLastPause-8        24072000     24046000   -0.11%
garbage.BenchmarkTreeLastPause-16       25149000     25291000   +0.56%

garbage.BenchmarkTree2LastPause        314491000    287988000   -8.43%
garbage.BenchmarkTree2LastPause-2      214363000    190616000  -11.08%
garbage.BenchmarkTree2LastPause-4      109778000    100052000   -8.86%
garbage.BenchmarkTree2LastPause-8       75390000     64753000  -14.11%
garbage.BenchmarkTree2LastPause-16      70333000     61484000  -12.58%

FTR, below are result with the empty prefetch function,
that is, single RET but no real prefetching.
It suggests that inlinable PREFETCH is worth pursuing.

benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               4448988000   4560488000   +2.51%
garbage.BenchmarkParser-2             4086045000   4129728000   +1.07%
garbage.BenchmarkParser-4             3677365000   3728672000   +1.40%
garbage.BenchmarkParser-8             3517253000   3583968000   +1.90%
garbage.BenchmarkParser-16            3506562000   3591414000   +2.42%

garbage.BenchmarkTree                  494435529    499580882   +1.04%
garbage.BenchmarkTree-4                468482117    467387294   -0.23%
garbage.BenchmarkTree-8                488533235    478311117   -2.09%
garbage.BenchmarkTree-2                499652705    499324235   -0.07%
garbage.BenchmarkTree-16               507835176    502005705   -1.15%

garbage.BenchmarkTree2                  31453900     33296800   +5.86%
garbage.BenchmarkTree2-2                21440600     22466400   +4.78%
garbage.BenchmarkTree2-4                10982000     11402700   +3.83%
garbage.BenchmarkTree2-8                 7544700      7476500   -0.90%
garbage.BenchmarkTree2-16                7049500      7338200   +4.10%

garbage.BenchmarkParserPause           135815000    139529142   +2.73%
garbage.BenchmarkParserPause-2          92691523     95229190   +2.74%
garbage.BenchmarkParserPause-4          53392190     53083476   -0.58%
garbage.BenchmarkParserPause-8          36059523     34594800   -4.06%
garbage.BenchmarkParserPause-16         30174300     30063300   -0.37%

garbage.BenchmarkTreePause              20969784     21866920   +4.28%
garbage.BenchmarkTreePause-2            20215875     20731125   +2.55%
garbage.BenchmarkTreePause-4            17240709     17275837   +0.20%
garbage.BenchmarkTreePause-8            18196386     17898777   -1.64%
garbage.BenchmarkTreePause-16           20621158     20662772   +0.20%

garbage.BenchmarkTree2Pause            173992142    184336857   +5.95%
garbage.BenchmarkTree2Pause-2          131281904    138005714   +5.12%
garbage.BenchmarkTree2Pause-4           93484952     98449238   +5.31%
garbage.BenchmarkTree2Pause-8           88950523     89286095   +0.38%
garbage.BenchmarkTree2Pause-16          86071238     89568666   +4.06%

garbage.BenchmarkParserLastPause       327247000    342189000   +4.57%
garbage.BenchmarkParserLastPause-2     217039000    217224000   +0.09%
garbage.BenchmarkParserLastPause-4     119722000    121327000   +1.34%
garbage.BenchmarkParserLastPause-8      70806000     71941000   +1.60%
garbage.BenchmarkParserLastPause-16     62813000     60166000   -4.21%

garbage.BenchmarkTreeLastPause          28420000     27840000   -2.04%
garbage.BenchmarkTreeLastPause-2        23514000     27390000  +16.48%
garbage.BenchmarkTreeLastPause-4        21773000     21414000   -1.65%
garbage.BenchmarkTreeLastPause-8        24072000     21705000   -9.83%
garbage.BenchmarkTreeLastPause-16       25149000     23932000   -4.84%

garbage.BenchmarkTree2LastPause        314491000    332894000   +5.85%
garbage.BenchmarkTree2LastPause-2      214363000    224611000   +4.78%
garbage.BenchmarkTree2LastPause-4      109778000    113976000   +3.82%
garbage.BenchmarkTree2LastPause-8       75390000     67223000  -10.83%
garbage.BenchmarkTree2LastPause-16      70333000     73216000   +4.10%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991057
2012-04-07 17:02:44 +04:00
Dmitriy Vyukov
9903d6870f runtime: minor refactoring in preparation for parallel GC
factor sweepspan() out of sweep(), no logical changes

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991047
2012-04-05 21:02:20 +04:00
Dmitriy Vyukov
d839a809b2 runtime: make GC stats per-M
This is factored out part of:
https://golang.org/cl/5279048/
(Parallel GC)

benchmark                             old ns/op    new ns/op    delta
garbage.BenchmarkParser              3999106750   3975026500   -0.60%
garbage.BenchmarkParser-2            3720553750   3719196500   -0.04%
garbage.BenchmarkParser-4            3502857000   3474980500   -0.80%
garbage.BenchmarkParser-8            3375448000   3341310500   -1.01%
garbage.BenchmarkParserLastPause      329401000    324097000   -1.61%
garbage.BenchmarkParserLastPause-2    208953000    214222000   +2.52%
garbage.BenchmarkParserLastPause-4    110933000    111656000   +0.65%
garbage.BenchmarkParserLastPause-8     71969000     78230000   +8.70%
garbage.BenchmarkParserPause          230808842    197237400  -14.55%
garbage.BenchmarkParserPause-2        123674365    125197595   +1.23%
garbage.BenchmarkParserPause-4         80518525     85710333   +6.45%
garbage.BenchmarkParserPause-8         58310243     56940512   -2.35%
garbage.BenchmarkTree2                 31471700     31289400   -0.58%
garbage.BenchmarkTree2-2               21536800     21086300   -2.09%
garbage.BenchmarkTree2-4               11074700     10880000   -1.76%
garbage.BenchmarkTree2-8                7568600      7351400   -2.87%
garbage.BenchmarkTree2LastPause       314664000    312840000   -0.58%
garbage.BenchmarkTree2LastPause-2     215319000    210815000   -2.09%
garbage.BenchmarkTree2LastPause-4     110698000    108751000   -1.76%
garbage.BenchmarkTree2LastPause-8      75635000     73463000   -2.87%
garbage.BenchmarkTree2Pause           174280857    173147571   -0.65%
garbage.BenchmarkTree2Pause-2         131332714    129665761   -1.27%
garbage.BenchmarkTree2Pause-4          93803095     93422904   -0.41%
garbage.BenchmarkTree2Pause-8          86242333     85146761   -1.27%

R=rsc
CC=golang-dev
https://golang.org/cl/5987045
2012-04-05 20:48:28 +04:00
Dmitriy Vyukov
fd04f05f2f runtime: replace XOR AX, AX with MOV $0, AX
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5985048
2012-04-05 18:59:50 +04:00
Dmitriy Vyukov
4667571619 runtime: add 64-bit atomics
This is factored out part of:
https://golang.org/cl/5279048/
(Parallel GC)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5985047
2012-04-05 18:47:43 +04:00
Dmitriy Vyukov
a28a10e1a2 runtime: remove redundant code
R=rsc
CC=golang-dev
https://golang.org/cl/5987046
2012-04-05 18:37:46 +04:00
Maxim Pimenov
6727a2ad78 runtime: fix a comment
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5975043
2012-04-02 11:27:50 -04:00
Russ Cox
5eb007dede runtime: work around false negative in deadlock detection
Not a complete fix for issue 3342, but fixes the trivial case.
There may still be a race in the instants before and after
a scavenger-induced garbage collection.

Intended to be "obviously safe": a call to runtime·gosched
before main.main is no different than a call to runtime.Gosched
at the beginning of main.main, and it is (or had better be)
safe to call runtime.Gosched at any point during main.

Update #3342.

R=iant
CC=golang-dev
https://golang.org/cl/5919052
2012-03-27 12:22:19 -04:00
Mikio Hara
4c2614c57c undo CL 5844051 / 5d0322034aa8
Breaks closure test when GOMAXPROCS=2 or more.

««« original CL description
runtime: restore deadlock detection in the simplest case.

Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051

»»»

R=rsc
CC=golang-dev
https://golang.org/cl/5924045
2012-03-27 13:05:17 +09:00
Rémy Oudompheng
84bb2547fb runtime: restore deadlock detection in the simplest case.
Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051
2012-03-26 23:06:20 -04:00
Shenghou Ma
4b1933dfb2 runtime: remove unused goc2c.c
Its functionality has been moved into cmd/dist.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5843062
2012-03-21 00:49:45 +08:00
Russ Cox
2e4a035995 runtime: do not handle signals before configuring handler
There was a small window during program initialization
where a signal could come in before the handling mechanisms
were set up to handle it.  Delay the signal-handler installation
until we're ready for the signals.

Fixes #3314.

R=golang-dev, dsymonds, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5833049
2012-03-15 22:17:54 -04:00
Russ Cox
bd6404a4cc runtime: fix arm build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5832047
2012-03-15 17:40:17 -04:00
Russ Cox
9e5db8c90a 5l, 6l, 8l: fix stack split logic for stacks near default segment size
Fixes #3310.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5823051
2012-03-15 15:22:30 -04:00
Shenghou Ma
b2a9079e54 runtime: manage stack by ourselves for badcallback on windows/amd64
This function uses 48-byte of precious non-split stack for every callback
function, and without this CL, it can easily overflow the non-split stack.
I encountered this when trying to enable misc/cgo/test on windows/amd64.

R=rsc
CC=golang-dev
https://golang.org/cl/5784075
2012-03-15 02:24:49 +08:00
Mikio Hara
9eeb90945e runtime/cgo: linux signal masking
Fixes #3314.
Fixes #3101 (again).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5820047
2012-03-14 13:07:25 +09:00
Mikio Hara
1fc9a17c7e runtime/cgo: darwin signal masking
Fixes #3101 (again).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5825043
2012-03-14 12:49:59 +09:00
Alex Brainman
16ade99d9d runtime: fix windows/amd64 exception handler
R=golang-dev, rsc
CC=golang-dev, hectorchu
https://golang.org/cl/5797077
2012-03-12 22:42:55 -04:00
Russ Cox
2d3cc97c9c runtime: fix windows/amd64
Maybe.

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/5754091
2012-03-12 16:48:16 -04:00
Russ Cox
b23691148f runtime: print error on receipt of signal on non-Go thread
It's the best we can do before Go 1.

For issue 3250; not a fix but at least less mysterious.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5797068
2012-03-12 15:55:18 -04:00
Russ Cox
c9e5600f7d runtime: move runtime.write back to C
It may have to switch stacks, since we are calling
a DLL instead of a system call.

badcallback says where it is, because it is being called
on a Windows stack already.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5782060
2012-03-09 00:10:34 -05:00
Russ Cox
8a1b3d5a57 runtime: fix windows build
Implement runtime·write, like on the other systems,
and also runtime·badcallback, in assembly to reduce
stack footprint.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5785055
2012-03-08 15:53:11 -05:00
Russ Cox
36aa7d4d14 runtime: inline calls to notok
When a very low-level system call that should never fail
does fail, we call notok, which crashes the program.
Often, we are then left with only the program counter as
information about the crash, and it is in notok.
Instead, inline calls to notok (it is just one instruction
on most systems) so that the program counter will
tell us which system call is unhappy.

R=golang-dev, gri, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/5792048
2012-03-08 14:03:56 -05:00
Russ Cox
9b73238daa cgo, runtime: diagnose callback on non-Go thread
Before:
$ go run x.go
signal 11 (core dumped)
$

After:
$ go run x.go
runtime: cgo callback on thread not created by Go.
signal 11 (core dumped)
$

For issue 3068.
Not a fix, but as much of a fix as we can do before Go 1.

R=golang-dev, rogpeppe, gri
CC=golang-dev
https://golang.org/cl/5781047
2012-03-08 12:12:40 -05:00
Russ Cox
b0beeb1501 runtime: fix freebsd crash
FreeBSD, alone among our supported operating systems,
required that usleep not be interrupted.  Don't require that.

Fixes #3217.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5781045
2012-03-07 15:30:54 -05:00
Rémy Oudompheng
3dcedb620c runtime: try extending arena size in 32-bit allocator.
If it didn't reach the limit, we can try extending the arena
before resorting to random memory mappings and praying for the
kernel to be kind.

Fixes #3173.

R=rsc, rsc
CC=golang-dev
https://golang.org/cl/5725045
2012-03-07 14:21:45 -05:00
Russ Cox
b37841cc06 runtime/pprof: disable test on Leopard 64-bit
Fixes #3234.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5756078
2012-03-07 11:44:54 -05:00
Ian Lance Taylor
aabbcda816 runtime: remove unused runtime·signame and runtime·newError
R=golang-dev
CC=golang-dev
https://golang.org/cl/5756044
2012-03-06 09:07:00 -08:00
Russ Cox
4e110af169 runtime: add Compiler
R=iant, r, gri
CC=golang-dev
https://golang.org/cl/5720073
2012-03-05 22:28:02 -05:00
Rémy Oudompheng
aa1aaee7fd runtime: wait for main goroutine before setting GOMAXPROCS.
Fixes #3182.

R=golang-dev, dvyukov, rsc
CC=golang-dev, remy
https://golang.org/cl/5732057
2012-03-05 16:40:27 -05:00
Russ Cox
c0a842e57f runtime/debug: fix test when source cannot be found
This happens with GOROOT_FINAL=/somewhere/else

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5727069
2012-03-05 16:13:15 -05:00
Russ Cox
dc159fabff runtime: run init on main thread
Fixes #3125.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/5714049
2012-03-01 11:48:17 -05:00
Shenghou Ma
357b257cd1 runtime/pprof: skip test on 64-bit Mac OS X 10.6
R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5709060
2012-03-01 03:11:37 +08:00
Luuk van Dijk
fb2706113f pkg/runtime: 2 sanity checks in the runtime-gdb.py prettyprinters.
Don't try to print obviously corrupt slices or interfaces.
Doesn't actually solve 3047 or 2818, but seems a good idea anyway.

R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5708061
2012-02-29 16:42:25 +01:00
Russ Cox
6e2ae0a12c runtime/pprof: support OS X CPU profiling
Work around profiling kernel bug with signal masks.
Still broken on 64-bit Snow Leopard kernel,
but I think we can ignore that one and let people
upgrade to Lion.

Add new trivial tools addr2line and objdump to take
the place of the GNU tools of the same name, since
those are not installed on OS X.

Adapt pprof to invoke 'go tool addr2line' and
'go tool objdump' if the system tools do not exist.

Clean up disassembly of base register on amd64.

Fixes #2008.

R=golang-dev, bradfitz, mikioh.mikioh, r, iant
CC=golang-dev
https://golang.org/cl/5697066
2012-02-28 16:18:24 -05:00
Russ Cox
102274a30e runtime: size arena to fit in virtual address space limit
For Brad.
Now FreeBSD/386 binaries run on nearlyfreespeech.net.

Fixes #2302.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5700060
2012-02-24 15:28:51 -05:00
Russ Cox
51a84bbfaa runtime: fix arm
signal.test binary passes on my phone; should fix builder

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5694064
2012-02-23 23:10:38 -05:00
Shenghou Ma
1bddfb5203 runtime: check for ARM syscall failures
While we are at it, also update some comments.
    Tested on Linux/ARM builder.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5696047
2012-02-23 15:43:14 -05:00
Russ Cox
224f05ba88 runtime: darwin signal masking
Fixes #3101 (darwin).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5693044
2012-02-23 14:44:06 -05:00
Russ Cox
240b1d5b44 runtime: linux signal masking
Fixes #3101 (Linux).

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/5696043
2012-02-23 14:43:58 -05:00
Russ Cox
ebae73bb24 pprof: add Profile type
Makes it possible for client code to maintain its own profiles,
and also reduces the API surface by giving us a type that
models built-in profiles.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5684056
2012-02-22 21:46:12 -05:00
Russ Cox
e4b02bfdc0 runtime: goroutine profile, stack dumps
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5687076
2012-02-22 21:45:01 -05:00
Devon H. O'Dell
b0891060ae runtime: fix FreeBSD signal handling around thread creation
Ignore signals while we are spawning a new thread. Previously, a
signal arriving just before runtime.minit setting up the signal
handler triggers a "double fault" in signal trampolining.
Fixes #3017.

R=rsc, mikioh.mikioh, minux.ma, adg
CC=golang-dev
https://golang.org/cl/5684060
2012-02-22 15:44:09 +11:00
Russ Cox
5bcad92f07 ld: add NOPTRBSS for large, pointer-free uninitialized data
cc: add #pragma textflag to set it
runtime: mark mheap to go into noptr-bss.
        remove special case in garbage collector

Remove the ARM from.flag field created by CL 5687044.
The DUPOK flag was already in p->reg, so keep using that.

Otherwise test/nilptr.go creates a very large binary.
Should fix the arm build.
Diagnosed by minux.ma; replacement for CL 5690044.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/5686060
2012-02-21 22:08:42 -05:00
Devon H. O'Dell
8542dc0764 runtime: use SYSCALL instead of INT 0x80 in FreeBSD's runtime.osyield on amd64
R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/5690062
2012-02-22 11:04:25 +09:00
Russ Cox
fc7ed45b35 runtime: avoid malloc during malloc
A fault during malloc might lead to the program's
first call to findfunc, which would in turn call malloc.
Don't do that.

Fixes #1777.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5689047
2012-02-21 16:36:15 -05:00
Mikio Hara
22c41ff019 runtime: remove an obsolete file
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5686049
2012-02-21 12:07:38 +09:00
Devon H. O'Dell
dff5535aaa runtime: implement runtime.osyield on FreeBSD 386, amd64
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5689046
2012-02-21 07:32:20 +09:00
Russ Cox
8a4c2b3cc4 runtime: fix another memory leak
morebuf holds a pc/sp from the last stack split or
reflect.call or panic/recover.  If the pc is a closure,
the reference will keep it from being collected.

moreargp holds a pointer to the arguments from the
last stack split or reflect.call or panic/recover.
Normally it is a stack pointer and thus not of interest,
but in the case of reflect.call it is an allocated argument
list and holds up the arguments to the call.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5674109
2012-02-19 11:05:19 -05:00
Russ Cox
89b075cc90 runtime: fix tiny memory leak
The m->cret word holds the C return value when returning
across a stack split boundary.  It was not being cleared after
use, which means that the return value (if a C function)
or else the value of AX/R0 at the time of the last stack unsplit
was being kept alive longer than necessary.  Clear it.

I think the effect here should be very small, but worth fixing
anyway.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5677092
2012-02-19 00:26:33 -05:00
Russ Cox
03f2289f7e runtime: API
Delete Alloc, Free, Lookup, Semacquire, Semrelease

Fixes #2955.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/5675093
2012-02-19 00:11:44 -05:00
Gustavo Niemeyer
ce020ffacd runtime: remove use of ?:
Fixes #3061.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5656089
2012-02-17 17:13:16 -02:00
Alex Brainman
b8f465644c runtime: silence warnings
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5656084
2012-02-17 17:05:41 +11:00
David Symonds
3d8ebefbbe runtime: Permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU.
Fixes #3037.

R=rsc, minux.ma, r, rsc
CC=golang-dev
https://golang.org/cl/5674072
2012-02-17 14:36:40 +11:00
David Symonds
4b171e5040 runtime: rename Cgocalls and Goroutines to NumCgoCall and NumGoroutine, respectively.
Update some other docs too.

Update #2955.

R=rsc
CC=golang-dev
https://golang.org/cl/5676060
2012-02-17 08:49:41 +11:00
Sébastien Paolacci
5c598d3c9f runtime: release unused memory to the OS.
Periodically browse MHeap's freelists for long unused spans and release them if any.

Current hardcoded settings:
        - GC is forced if none occured over the last 2 minutes.
        - spans are handed back after 5 minutes of uselessness.

SysUnused (for Unix) is a wrapper on madvise MADV_DONTNEED on Linux and MADV_FREE on BSDs.

R=rsc, dvyukov, remyoudompheng
CC=golang-dev
https://golang.org/cl/5451057
2012-02-16 13:30:04 -05:00
David du Colombier
1064f3a97b runtime: define NSIG to fix plan 9 build
R=rsc
CC=golang-dev
https://golang.org/cl/5677053
2012-02-15 14:36:20 -05:00
Gustavo Niemeyer
8eee153bc8 runtime: fix grsec support
Changeset 36c9c7810f14 broke support for grsec-patched kernels.
Those do not give back the address requested without MAP_FIXED,
so when verifying an mmap without this flag for success, the
resulting address must not be compared against the requested
address since it may have succeeded at a different location.

R=golang-dev, rsc, gustavo, iant
CC=golang-dev
https://golang.org/cl/5650072
2012-02-14 22:09:02 -02:00
Rémy Oudompheng
2a6e6999a4 runtime, time: accelerate tests in short mode.
before   after
go test -short time                4.144s  1.215s
go test -short runtime             1.315s  0.351s
go test -short -cpu=1,2,4 runtime  4.376s  1.266s

Partially solves issue 3015.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/5673045
2012-02-14 22:13:19 +01:00
Russ Cox
1707a9977f runtime: on 386, fix FP control word on all threads, not just initial thread
It is possible that Linux and Windows copy the FP control word
from the parent thread when creating a new thread.  Empirically,
Darwin does not.  Reset the FP control world in all cases.

Enable the floating-point strconv test.

Fixes #2917 (again).

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5660047
2012-02-14 01:23:15 -05:00
Russ Cox
55a54691f9 runtime: use startpanic so that only one thread handles an incoming SIGQUIT
Typing ^\ delivers the SIGQUIT to all threads, it appears.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5657044
2012-02-13 23:06:21 -05:00
Russ Cox
0995aba983 runtime/debug: fix build
TBR=r
CC=golang-dev
https://golang.org/cl/5661053
2012-02-13 23:05:19 -05:00
Rob Pike
bf2838334c testing: let runtime catch the panic.
It's not as pretty, but it deletes some irrelevant information from the
printout and avoids a dependency.
It also means the test binary will stop if a test panics. That's a feature,
not a bug.
Any output printed by the test appears before the panic traceback.

before:

--- FAIL: TestPanic (0.00 seconds)
        fmt_test.go:19: HI
        testing.go:257: runtime error: index out of range
                /Users/r/go/src/pkg/testing/testing.go:257 (0x23998)
                        _func_003: t.Logf("%s\n%s", err, debug.Stack())
                /Users/r/go/src/pkg/runtime/proc.c:1388 (0x10d2d)
                        panic: reflect·call(d->fn, d->args, d->siz);
                /Users/r/go/src/pkg/runtime/runtime.c:128 (0x119b0)
                        panicstring: runtime·panic(err);
                /Users/r/go/src/pkg/runtime/runtime.c:85 (0x11857)
                        panicindex: runtime·panicstring("index out of range");
                /Users/r/go/src/pkg/fmt/fmt_test.go:21 (0x23d72)
                        TestPanic: a[10]=1
                /Users/r/go/src/pkg/testing/testing.go:264 (0x21b75)
                        tRunner: test.F(t)
                /Users/r/go/src/pkg/runtime/proc.c:258 (0xee9e)
                        goexit: runtime·goexit(void)
FAIL

after:

--- FAIL: TestPanic (0.00 seconds)
        fmt_test.go:19: HI
panic: runtime error: index out of range [recovered]
        panic: (*testing.T) (0xec3b0,0xf8400001c0)

goroutine 2 [running]:
testing._func_003(0x21f5fa8, 0x21f5100, 0x21f5fb8, 0x21f5e88)
        /Users/r/go/src/pkg/testing/testing.go:259 +0x108
----- stack segment boundary -----
fmt_test.TestPanic(0xf8400001c0, 0x27603728)
        /Users/r/go/src/pkg/fmt/fmt_test.go:21 +0x6b
testing.tRunner(0xf8400001c0, 0x18edb8, 0x0, 0x0)
        /Users/r/go/src/pkg/testing/testing.go:264 +0x6f
created by testing.RunTests
        /Users/r/go/src/pkg/testing/testing.go:343 +0x76e

goroutine 1 [chan receive]:
testing.RunTests(0x2000, 0x18edb8, 0x2400000024, 0x100000001, 0x200000001, ...)
        /Users/r/go/src/pkg/testing/testing.go:344 +0x791
testing.Main(0x2000, 0x18edb8, 0x2400000024, 0x188a58, 0x800000008, ...)
        /Users/r/go/src/pkg/testing/testing.go:275 +0x62
main.main()
        /var/folders/++/+++Fn+++6+0++4RjPqRgNE++2Qk/-Tmp-/go-build743922747/fmt/_test/_testmain.go:129 +0x91
exit status 2

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/5658048
2012-02-14 14:53:30 +11:00
Alex Brainman
07a2989d17 runtime, syscall, os/signal: fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656048
2012-02-14 13:51:38 +11:00
Shenghou Ma
31ab16f98e fix build for Linux/ARM.
1, IMO, the fatal error "regfree: not a register" from 5g when
         compiling runtime/debug.go is due to gcc miscompile, it doesn't
         show up when compiled with -O0. But I still haven't thought of
         a way to fix this, should all ARM builds be built with -O0?
        2, fixed mksysnum_linux.pl, so zsysnum_linux_arm.go no longer
        needs to be hand-generated.
        3, regen all in pkg syscall for Linux/ARM on Debian 6.0
This CL is somewhat big, I'd like to split it if necessary.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/5659044
2012-02-13 20:16:57 -05:00
Andrew Gerrand
2d53d227f6 runtime, syscall: fix freebsd-386 build
R=rsc
CC=golang-dev
https://golang.org/cl/5659045
2012-02-14 10:04:59 +11:00
Andrew Gerrand
7c2607a91d runtime, syscall: fix freebsd build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5661047
2012-02-14 09:29:51 +11:00
Shenghou Ma
9a4487458a all: update 'gotest' to 'go test'
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5645099
2012-02-13 13:58:17 -05:00
Russ Cox
35586f718c os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only.  Also, signals
go to everyone who asks, not just one client.

This could plausibly move into package os now
that there are no magic side effects as a result
of the import.

Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)

Tested on darwin,linux 386,amd64.

Fixes #1266.

R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 13:52:37 -05:00
Russ Cox
f735d2d9d3 testing: use runtime/debug to format panics
Among other things, this avoids putting a testing.go:nnn:
prefix on every line of the stack trace.

R=golang-dev, r, dsymonds, r
CC=golang-dev
https://golang.org/cl/5651081
2012-02-12 23:39:40 -05:00
Russ Cox
6a75ece01c runtime: delete Type and implementations (use reflect instead)
unsafe: delete Typeof, Reflect, Unreflect, New, NewArray

Part of issue 2955 and issue 2968.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5650069
2012-02-12 23:26:20 -05:00
Ian Lance Taylor
53e139c7a0 runtime: put lockorder before pollorder in Select memory block.
Otherwise lockorder may be misaligned, since lockorder is a
list of pointers and pollorder is a list of uint16.
Discovered running gccgo (which uses a modified copy of this
code) on SPARC.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5655054
2012-02-10 21:24:14 -08:00
Russ Cox
f91cc3bdbb gc: optimize interface ==, !=
If the values being compared have different concrete types,
then they're clearly unequal without needing to invoke the
actual interface compare routine.  This speeds tests for
specific values, like if err == io.EOF, by about 3x.

benchmark                  old ns/op    new ns/op    delta
BenchmarkIfaceCmp100             843          287  -65.95%
BenchmarkIfaceCmpNil100          184          182   -1.09%

Fixes #2591.

R=ken2
CC=golang-dev
https://golang.org/cl/5651073
2012-02-11 00:19:24 -05:00
Shenghou Ma
bb40196ebf runtime: Linux/ARM: exit early on OABI systems, and give an error message
Fixes #2533.

R=rsc
CC=golang-dev
https://golang.org/cl/5654045
2012-02-09 16:18:21 -05:00
Russ Cox
1253c75cf5 runtime: fix compiler warnings
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5642068
2012-02-09 16:48:52 +11:00
Shenghou Ma
073aeff785 runtime: fix "SysReserve returned unaligned address" bug on 32-bit systems
R=rsc
CC=golang-dev
https://golang.org/cl/5642064
2012-02-09 09:25:10 +11:00
Paul Borman
d37a8b73c5 runtime: drop to 32 bit malloc if 64 bit will not work
On 64 bit UML it is not possible to reserve memory at 0xF8<<32.
Detect when linux cannot use these high virtual memory addresses
and drop back to the 32 bit memory allocator.

R=rsc, cw
CC=golang-dev
https://golang.org/cl/5634050
2012-02-08 14:39:16 -05:00
Russ Cox
5b93fc9da6 runtime, pprof: add profiling of thread creation
Same idea as heap profile: how did each thread get created?
Low memory (256 bytes per OS thread), high reward for
programs that suddenly have many threads running.

Fixes #1477.

R=golang-dev, r, dvyukov
CC=golang-dev
https://golang.org/cl/5639059
2012-02-08 10:33:54 -05:00
Rob Pike
0bd53d2ce0 runtime/cgo: silence warning on windows
It appears to want a * on an indirect function call (assembly language)

TBR=rsc

R=golang-dev
CC=golang-dev
https://golang.org/cl/5643054
2012-02-08 15:26:36 +11:00
Rémy Oudompheng
842c906e2e runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats.
The new accessor requires passing a pointer to a user-allocated
MemStats structure.

Fixes #2572.

R=bradfitz, rsc, bradfitz, gustavo
CC=golang-dev, remy
https://golang.org/cl/5616072
2012-02-06 19:16:26 +01:00
Shenghou Ma
6392b43a15 8a, 8l: implement support for RDTSC instruction.
Also modify runtime/asm_386.s to use it.

R=rsc
CC=golang-dev
https://golang.org/cl/5634043
2012-02-06 12:49:28 -05:00
Russ Cox
facee93a86 runtime: fix float64 hash on 32-bit machine
Multiplying by the low 32 bits was a bad idea
no matter what, but it was a particularly unfortunate
choice because those bits are 0 for small integer values.

Fixes #2883.

R=ken2
CC=golang-dev
https://golang.org/cl/5634047
2012-02-06 11:24:34 -05:00
Russ Cox
48bd13911d runtime: use GOTRACEBACK to decide whether to show runtime frames
Right now, GOTRACEBACK=0 means do not show any stack traces.
Unset means the default behavior (declutter by hiding runtime routines).

This CL makes GOTRACEBACK=2 mean include the runtime routines.
It avoids having to recompile the runtime when you want to see
the runtime in the tracebacks.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5633050
2012-02-06 11:24:14 -05:00
Russ Cox
961f96b5d2 build: delete buildscripts, runtime scripts
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5620059
2012-02-04 00:54:26 -05:00
Russ Cox
b3750ff52d build: rename $GOROOT/bin/go-tool to $GOROOT/bin/tool.
The go- is redundant now that the directory is required
to be inside $GOROOT.  Rob LGTMed the idea.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5618044
2012-02-02 23:32:41 -05:00
Damian Gryski
8e765da941 runtime: add runtime.cputicks() and seed fastrand with it
This patch adds a function to get the current cpu ticks.  This is
deemed to be 'sufficiently random' to use to seed fastrand to mitigate
the algorithmic complexity attacks on the hash table implementation.

On AMD64 we use the RDTSC instruction.  For 386, this instruction,
while valid, is not recognized by 8a so I've inserted the opcode by
hand.  For ARM, this routine is currently stubbed to return a constant
0 value.

Future work: update 8a to recognize RDTSC.

Fixes #2630.

R=rsc
CC=golang-dev
https://golang.org/cl/5606048
2012-02-02 14:09:27 -05:00
Russ Cox
9a15c2186c build: move goapi, quietgcc, cgo, gotype, ebnflint into go-tool
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5552054
2012-01-31 10:38:07 -05:00
Damian Gryski
85aeeadaec runtime: use per-map hash seeds
This patch adds a hash seed to the Hmap struct.  Each seed is
initialized by runtime.fastrand1().  This is the first step of a
solution to issue 2630.  Fastrand1 still needs to be updated to provide
us with actually random bits.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5599046
2012-01-31 00:37:03 -05:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Russ Cox
56e6a02490 runtime: fix mkasmh.sh for arm?
The builder is Debian, so maybe running dash,
the shell that time forgot.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5600053
2012-01-30 23:17:11 -05:00
Anthony Martin
bacb1b70f7 runtime: fix mkasmh.h
We weren't properly deleting the various header
files (that were temporarily renamed) if a $CC
for the current $GOARCH didn't exist.  And since
the compiler checks the current directory for
headers before any -I arguments, this had the
unfortunate side effect of including the last
generated headers instead of the correct ones.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5581055
2012-01-30 19:25:40 -08:00
Rob Pike
91cb3489ab go: move compilers into the go-tool directory
Also delete gotest, since it's messy to fix and slated for deletion anyway.
A couple of things outside src can't be tested any more. "go test" will be
fixed and these tests will be re-enabled. They're noisy for now.

Fixes #284.

R=rsc
CC=golang-dev
https://golang.org/cl/5598049
2012-01-30 14:46:31 -08:00
Russ Cox
022aac7883 runtime: fix float64 hash
R=ken2
CC=golang-dev
https://golang.org/cl/5580046
2012-01-30 11:10:59 -05:00
Russ Cox
408f0b1f74 gc, runtime: handle floating point map keys
Fixes #2609.

R=ken2
CC=golang-dev
https://golang.org/cl/5572069
2012-01-26 16:25:07 -05:00
David Symonds
0ae9d812c8 runtime: move NumCPU declaration into debug.go.
R=rsc
CC=golang-dev
https://golang.org/cl/5574060
2012-01-25 14:13:11 +11:00
Shenghou Ma
0ae6084fef build: do not build all C compilers
In order to allow buildscript.sh to generate buildscripts for all
        $GOOS/$GOARCH combinations, we have to generate dummy files for cmd/go.
        Fixes #2586.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5557050
2012-01-24 15:03:41 -05:00
Shenghou Ma
e021357673 runtime: update out-of-date comment
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5532118
2012-01-22 10:34:17 -08:00
Dmitriy Vyukov
1ff1405cc7 runtime: add type algorithms for zero-sized types
BenchmarkChanSem old=127ns new=78.6ns

R=golang-dev, bradfitz, sameer, rsc
CC=golang-dev
https://golang.org/cl/5558049
2012-01-20 10:32:55 +04:00
Alex Brainman
8d6958fc04 misc/cgo/test: make tests run on windows
- use proper Win64 gcc calling convention when
  calling initcgo on amd64
- increase g0 stack size to 64K on amd64 to make
  it the same as 386
- implement C.sleep
- do not use C.stat, since it is renamed to C._stat by mingw
- use fopen to implement TestErrno, since C.strtol
  always succeeds on windows
- skip TestSetEnv on windows, because os.Setenv
  sets windows process environment, while C.getenv
  inspects internal C runtime variable instead

R=golang-dev, vcc.163, rsc
CC=golang-dev
https://golang.org/cl/5500094
2012-01-20 12:59:44 +11:00
Shenghou Ma
fec7aa952f doc: update out-of-date comments about runtime/cgo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5532100
2012-01-19 17:13:33 -05:00
Dave Cheney
c354f93b93 runtime: madvise and SysUnused for Darwin
SysUnused is a direct call to madvise MADV_FREE.

R=sebastien.paolacci, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/5531073
2012-01-19 15:51:29 -05:00
Olivier Duperray
e5c1f3870b pkg: Add & fix Copyright of "hand generated" files
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5554064
2012-01-19 10:14:56 -08:00
Shenghou Ma
c30ba7e65a runtime: implement runtime.usleep for FreeBSD/386 and amd64.
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/5528106
2012-01-17 03:22:34 +11:00
Maxim Pimenov
0aaf2c2d10 runtime: fix typo in comment
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/5540059
2012-01-16 18:42:18 +04:00
Dmitriy Vyukov
a03c519a8c effective_go: provide reference to runtime.NumCPU()
R=golang-dev, robert.hencke, r
CC=golang-dev
https://golang.org/cl/5538050
2012-01-12 22:06:50 +04:00
Russ Cox
610757b155 runtime: delete duplicate implementation of pcln walker
It's hard enough to get right once.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5533073
2012-01-11 18:45:32 -08:00
Shenghou Ma
1250f94f93 runtime: runtime.usleep() bugfix on darwin/amd64 and linux/arm
pkg/runtime/sys_darwin_amd64.s: fixes syscall select nr
pkg/runtime/sys_linux_arm.s: uses newselect instead of the now unimplemented
        (old) select, also fixes the wrong div/mod statements in runtime.usleep.
Fixes #2633

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5504096
2012-01-10 20:48:02 -08:00
Russ Cox
a6d8b483b6 runtime: make garbage collector faster by deleting code
Suggested by Sanjay Ghemawat.  5-20% faster depending
on the benchmark.

Add tree2 garbage benchmark.
Update other garbage benchmarks to build again.

R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/5530074
2012-01-10 19:49:11 -08:00
Maxim Pimenov
dcdc309c7c runtime: fix typo in comment
R=golang-dev
CC=golang-dev
https://golang.org/cl/5529059
2012-01-10 12:56:25 -08:00
Russ Cox
5032a7dc0c runtime: distinct panic message for call of nil func value
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5531062
2012-01-10 11:46:57 -08:00
Dave Cheney
bc1f4c1823 runtime: regenerate defs_darwin_{386,amd64}.h
Regenerated under Lion 10.7.2 amd64.
Also tested on Snow Leopart 10.6.8 386.

R=golang-dev, dsymonds, minux.ma
CC=golang-dev
https://golang.org/cl/5533058
2012-01-10 09:48:10 -08:00
Devon H. O'Dell
12bf00054e runtime: enable runtime.ncpu on FreeBSD
R=adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5528062
2012-01-10 17:39:17 +11:00