1
0
mirror of https://github.com/golang/go synced 2024-10-04 14:31:21 -06:00
Commit Graph

56 Commits

Author SHA1 Message Date
Dmitriy Vyukov
ab596cae9e sync/atomic: replace MFENCE with LOCK XADD
MFENCE was introduced only on the Pentium4 (SSE2),
while XADD was introduced on the 486.
Fixes #2268.

R=golang-dev, rsc
CC=fshahriar, golang-dev
https://golang.org/cl/5056045
2011-09-19 11:09:00 -07:00
Dmitriy Vyukov
cf0d8c0941 sync/atomic: add 64-bit Load and Store
R=rsc
CC=golang-dev
https://golang.org/cl/4977054
2011-09-08 11:58:48 +04:00
Alex Brainman
794489ecf3 sync/atomic: do not run TestStoreLoadSeq for too long (fix windows builder)
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4962057
2011-09-08 13:31:40 +10:00
Dmitriy Vyukov
1fc676332f sync/atomic: add Store functions
R=rsc
CC=golang-dev
https://golang.org/cl/4950060
2011-09-07 21:50:51 +04:00
Dmitriy Vyukov
ea23ba3e2d sync/atomic: add LoadUintptr
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4985041
2011-09-01 15:17:25 -04:00
Dmitriy Vyukov
d2ab2b9f42 sync: improve Once fast path
Use atomic.LoadUint32(&done) instead of
atomic.AddInt32(&done, 0) on fast path.

benchmark            old ns/op    new ns/op    delta
BenchmarkOnce            13.40         7.26  -45.82%
BenchmarkOnce-2          22.90         4.04  -82.36%
BenchmarkOnce-4          25.60         2.16  -91.56%
BenchmarkOnce-8          25.80         1.38  -94.65%
BenchmarkOnce-16         24.40         1.33  -94.55%

(on HP Z600, 2 x Intel Xeon E5620, 8 HT cores, 2.4 GHz)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4787041
2011-07-21 11:30:14 -04:00
Rob Pike
62f618a22c sync/atomic: delete workaround
Load seems to work on arm now.

R=dsymonds
CC=golang-dev
https://golang.org/cl/4795042
2011-07-20 08:39:24 +10:00
Dmitriy Vyukov
0b200b4d09 sync/atomic: fix LoadInt32 on ARM
R0 is clobbered after cas,
while R1 preserves its value.

R=golang-dev
CC=golang-dev
https://golang.org/cl/4782042
2011-07-19 22:10:07 +10:00
Rob Pike
3bbeef5201 sync/atomic: attempt to get the arm build green.
Disable the LoadInt32 and LoadUint32 tests, since they fail.
These should be fixed but we want to get through the rest of the build
to see if something else unrelated is broken.  The arm build has been
bad for a long time.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4780041
2011-07-19 17:06:13 +10:00
Dmitriy Vyukov
ee6e1a3ff7 sync: add fast paths to WaitGroup
benchmark                                        old ns/op    new ns/op    delta
BenchmarkWaitGroupUncontended                        93.50        33.60  -64.06%
BenchmarkWaitGroupUncontended-2                      44.30        16.90  -61.85%
BenchmarkWaitGroupUncontended-4                      21.80         8.47  -61.15%
BenchmarkWaitGroupUncontended-8                      12.10         4.86  -59.83%
BenchmarkWaitGroupUncontended-16                      7.38         3.35  -54.61%
BenchmarkWaitGroupAddDone                            58.40        33.70  -42.29%
BenchmarkWaitGroupAddDone-2                         293.00        85.80  -70.72%
BenchmarkWaitGroupAddDone-4                         243.00        51.10  -78.97%
BenchmarkWaitGroupAddDone-8                         236.00        52.20  -77.88%
BenchmarkWaitGroupAddDone-16                        215.00        43.30  -79.86%
BenchmarkWaitGroupAddDoneWork                       826.00       794.00   -3.87%
BenchmarkWaitGroupAddDoneWork-2                     450.00       424.00   -5.78%
BenchmarkWaitGroupAddDoneWork-4                     277.00       220.00  -20.58%
BenchmarkWaitGroupAddDoneWork-8                     440.00       116.00  -73.64%
BenchmarkWaitGroupAddDoneWork-16                    569.00        66.50  -88.31%
BenchmarkWaitGroupWait                               29.00         8.04  -72.28%
BenchmarkWaitGroupWait-2                             74.10         4.15  -94.40%
BenchmarkWaitGroupWait-4                            117.00         2.30  -98.03%
BenchmarkWaitGroupWait-8                            111.00         1.31  -98.82%
BenchmarkWaitGroupWait-16                           104.00         1.27  -98.78%
BenchmarkWaitGroupWaitWork                          802.00       792.00   -1.25%
BenchmarkWaitGroupWaitWork-2                        411.00       401.00   -2.43%
BenchmarkWaitGroupWaitWork-4                        210.00       199.00   -5.24%
BenchmarkWaitGroupWaitWork-8                        206.00       105.00  -49.03%
BenchmarkWaitGroupWaitWork-16                       334.00        54.40  -83.71%

R=rsc
CC=golang-dev
https://golang.org/cl/4672050
2011-07-18 12:35:55 -04:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Dmitriy Vyukov
daaf29cf93 sync: improve RWMutex performance
The new implementation features wait-free
fast path for readers which significantly improves
performance/scalability on read-mostly workloads.
Benchmark results on HP Z600 (2 x Xeon E5620, 8 HT cores, 2.40GHz)
are as follows:
benchmark                              old ns/op    new ns/op    delta
BenchmarkRWMutexUncontended               179.00        96.60  -46.03%
BenchmarkRWMutexUncontended-2              89.10        49.10  -44.89%
BenchmarkRWMutexUncontended-4              44.70        24.70  -44.74%
BenchmarkRWMutexUncontended-8              23.30        12.90  -44.64%
BenchmarkRWMutexUncontended-16             16.80         8.75  -47.92%
BenchmarkRWMutexWrite100                   79.60        26.80  -66.33%
BenchmarkRWMutexWrite100-2                305.00        33.00  -89.18%
BenchmarkRWMutexWrite100-4                245.00       113.00  -53.88%
BenchmarkRWMutexWrite100-8                330.00       147.00  -55.45%
BenchmarkRWMutexWrite100-16               371.00       152.00  -59.03%
BenchmarkRWMutexWrite10                    78.30        29.80  -61.94%
BenchmarkRWMutexWrite10-2                 348.00       165.00  -52.59%
BenchmarkRWMutexWrite10-4                 447.00       199.00  -55.48%
BenchmarkRWMutexWrite10-8                 564.00       180.00  -68.09%
BenchmarkRWMutexWrite10-16                492.00       192.00  -60.98%
BenchmarkRWMutexWorkWrite100             1077.00      1037.00   -3.71%
BenchmarkRWMutexWorkWrite100-2            659.00       596.00   -9.56%
BenchmarkRWMutexWorkWrite100-4            509.00       361.00  -29.08%
BenchmarkRWMutexWorkWrite100-8            603.00       351.00  -41.79%
BenchmarkRWMutexWorkWrite100-16           750.00       607.00  -19.07%
BenchmarkRWMutexWorkWrite10               990.00       951.00   -3.94%
BenchmarkRWMutexWorkWrite10-2            1119.00      1070.00   -4.38%
BenchmarkRWMutexWorkWrite10-4            1300.00      1199.00   -7.77%
BenchmarkRWMutexWorkWrite10-8            1424.00      1291.00   -9.34%
BenchmarkRWMutexWorkWrite10-16           1981.00      1786.00   -9.84%

R=rsc
CC=golang-dev
https://golang.org/cl/4671051
2011-07-12 09:24:21 -07:00
Dmitriy Vyukov
dd2074c82a sync: improve Mutex to allow successive acquisitions
This implementation allows a goroutine to do successive acquisitions
of a mutex even if there are blocked goroutines.
Moreover, it allows a newcomer goroutine to acquire a mutex ahead of
blocked goroutines (that is, it does not enforce FIFO).
On implementation level it's achieved by separating waiter count and
locked flag.
Benchmark results on HP Z600 (2 x Xeon E5620, 8 HT cores, 2.40GHz)
are as follows (with 4631059 "replace Semacquire/Semrelease implementation"
patch applied):
benchmark                                        old ns/op    new ns/op    delta
sync_test.BenchmarkMutexUncontended                  24.10        25.40   +5.39%
sync_test.BenchmarkMutexUncontended-2                12.00        13.00   +8.33%
sync_test.BenchmarkMutexUncontended-4                 6.06         6.83  +12.71%
sync_test.BenchmarkMutexUncontended-8                 3.63         3.60   -0.83%
sync_test.BenchmarkMutexUncontended-16                2.38         2.49   +4.62%

sync_test.BenchmarkMutex                             25.00        26.40   +5.60%
sync_test.BenchmarkMutex-2                          231.00        49.00  -78.79%
sync_test.BenchmarkMutex-4                          259.00       114.00  -55.98%
sync_test.BenchmarkMutex-8                          641.00       110.00  -82.84%
sync_test.BenchmarkMutex-16                        1380.00        96.30  -93.02%

sync_test.BenchmarkMutexSlack                        24.80        26.20   +5.65%
sync_test.BenchmarkMutexSlack-2                     210.00       106.00  -49.52%
sync_test.BenchmarkMutexSlack-4                     453.00       119.00  -73.73%
sync_test.BenchmarkMutexSlack-8                    1024.00       105.00  -89.75%
sync_test.BenchmarkMutexSlack-16                   1291.00        91.90  -92.88%

sync_test.BenchmarkMutexWork                        796.00       796.00   +0.00%
sync_test.BenchmarkMutexWork-2                      399.00       401.00   +0.50%
sync_test.BenchmarkMutexWork-4                      216.00       212.00   -1.85%
sync_test.BenchmarkMutexWork-8                     1547.00       196.00  -87.33%
sync_test.BenchmarkMutexWork-16                    2754.00       287.00  -89.58%

sync_test.BenchmarkMutexWorkSlack                   792.00       800.00   +1.01%
sync_test.BenchmarkMutexWorkSlack-2                 430.00       420.00   -2.33%
sync_test.BenchmarkMutexWorkSlack-4                 467.00       230.00  -50.75%
sync_test.BenchmarkMutexWorkSlack-8                1860.00       273.00  -85.32%
sync_test.BenchmarkMutexWorkSlack-16               3029.00       294.00  -90.29%

R=rsc
CC=golang-dev
https://golang.org/cl/4631075
2011-06-30 11:13:29 -04:00
Dmitriy Vyukov
93dde6b0e6 sync: add fast path to Once
The implementation does not grab the lock,
if Once is already initalized.
Benchmark results on HP Z600 (2 x Xeon E5620, 8 HT cores, 2.40GHz)
are as follows:
benchmark                                        old ns/op    new ns/op    delta
sync_test.BenchmarkOnce                             187.00        14.00  -92.51%
sync_test.BenchmarkOnce-2                           909.00        21.40  -97.65%
sync_test.BenchmarkOnce-4                          3684.00        20.90  -99.43%
sync_test.BenchmarkOnce-8                          5987.00        23.00  -99.62%
sync_test.BenchmarkOnce-16                         5051.00        21.60  -99.57%

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4641066
2011-06-28 09:43:01 -04:00
Dmitriy Vyukov
5c15f8710c sync: replace Mutex benchmarks
For both contended and uncontended case:
 - support arbitrary number of cpus (not just 2)
 - dynamic load balancing (improves stability)
 - periodic execution of Gosched() to work around non-preemptiviness
For uncontended case eliminates possible false-sharing.
For contended case includes additional variation with some
amount of local work between mutex operations.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4634093
2011-06-28 08:14:54 -04:00
Dmitriy Vyukov
3a4a581c49 sync: add benchmark for Once.
R=r, rsc
CC=golang-dev
https://golang.org/cl/4650054
2011-06-27 16:02:13 -04:00
Dmitriy Vyukov
8cab7f5703 sync: restore GOMAXPROCS during benchmarks
R=golang-dev
CC=dvyukov, golang-dev
https://golang.org/cl/4631060
2011-06-22 16:20:37 -04:00
Andrew Gerrand
d44c4c351d sync/atomic: fix arm check64 bug
R=r, rsc
CC=golang-dev
https://golang.org/cl/4571059
2011-06-10 13:50:19 +10:00
Dmitriy Vyukov
79b397b27e testing: check that tests and benchmarks do not affect GOMAXPROCS
Plus fix spoiling of GOMAXPROCS in 2 existing rwmutex tests.
Plus fix benchmark output to stdout (now it outputs to stderr like all other output).

R=rsc
CC=golang-dev
https://golang.org/cl/4529111
2011-06-03 13:50:44 -04:00
Russ Cox
69cb8fef43 sync/atomic: fix check64
The LDREXD and STREXD instructions require
aligned addresses, and the ARM stack is not
guaranteed to be aligned during the check.
This may cause other problems later (on the ARM
not all 64-bit pointers may be 64-bit aligned)
but at least the check is correct now.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4564053
2011-06-02 13:13:51 -04:00
Gustavo Niemeyer
17bfa32fde sync: always wake up previously sleeping goroutines on Cond.Signal
This changes the internal implementation of Cond so that
it uses two generations of waiters.  This enables Signal
to guarantee that it will only wake up waiters that are
currently sleeping at the call time.

Fixes #1648.

R=dvyukov, gustavo, rsc
CC=golang-dev
https://golang.org/cl/4524083
2011-06-01 20:30:42 -03:00
Russ Cox
540feaae47 runtime, sync/atomic: fix arm cas
Works around bug in kernel implementation on old ARM5 kernels.
Bug was fixed on 26 Nov 2007 (between 2.6.23 and 2.6.24) but
old kernels persist.

Fixes #1750.

R=dfc, golang-dev
CC=golang-dev
https://golang.org/cl/4436072
2011-05-02 10:49:19 -04:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Russ Cox
6b3357129a build: add all-qemu.bash, handful of arm fixes
R=r
CC=golang-dev
https://golang.org/cl/4313051
2011-03-27 23:39:42 -04:00
Rob Pike
f0cf7d296c testing: shorten some tests.
These are the top runners.  More to come.
Also print two digits of timing info under -test.v.

R=rsc
CC=golang-dev
https://golang.org/cl/4317044
2011-03-25 16:31:10 -07:00
Andrew Gerrand
39ffd546bd sync: fix example code
Fixes #1631.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4303046
2011-03-23 14:24:30 +11:00
Russ Cox
c833d2fd94 sync/atomic: make BUG comment godoc-compatible
go/doc wants to see text after BUG(uid): on the same line
in order to treat it as an official bug comment.

R=gri
CC=golang-dev
https://golang.org/cl/4250043
2011-02-25 14:40:36 -05:00
Russ Cox
12b7875bf2 sync: use sync/atomic
Remove references to custom assembly routines.

R=r, r2
CC=golang-dev
https://golang.org/cl/4241043
2011-02-25 14:29:47 -05:00
Russ Cox
22eab1f5c7 sync/atomic: new package
Fixes #170.

R=gri, iant, r, r2
CC=golang-dev
https://golang.org/cl/4241041
2011-02-25 14:29:36 -05:00
Robert Griesemer
9fc0f159c3 sync: make package comment appear
R=rsc
CC=golang-dev
https://golang.org/cl/4220044
2011-02-23 10:12:38 -08:00
Gustavo Niemeyer
05b1dbd0a6 sync: add Cond
R=rsc, rog, r
CC=golang-dev
https://golang.org/cl/3775048
2011-02-16 14:11:07 -05:00
Russ Cox
26880d7e03 sync: check Unlock of unlocked Mutex
R=r, adg
CC=golang-dev
https://golang.org/cl/4180044
2011-02-11 17:47:17 -05:00
Gustavo Niemeyer
63457d089e sync: Proposal for barrier implementation
As discussed in the mailing list, this adds a simple barrier
implementation to the sync package which enables one or more
goroutines to wait for a counter to go down to zero.

R=rsc, rog, r
CC=golang-dev
https://golang.org/cl/3770045
2011-02-03 12:39:11 -08:00
Rob Pike
7c189a8417 sync: tidy a couple of comments.
no semantic change.

R=rsc
CC=golang-dev
https://golang.org/cl/4128048
2011-02-01 21:29:46 -08:00
Rob Pike
08a206cc9e sync: a couple of documentation nits.
R=golang-dev, agl1
CC=golang-dev
https://golang.org/cl/4079051
2011-01-29 14:56:15 -08:00
Dean Prichard
cd319092e0 sync: small naming fix for armv5
R=rsc
CC=golang-dev
https://golang.org/cl/3268042
2010-12-07 12:05:00 -05:00
Robert Griesemer
417e22b584 sync: fix typo in documentation
R=rsc, adg
CC=golang-dev
https://golang.org/cl/2841041
2010-11-02 16:01:07 -07:00
Russ Cox
da392d9136 build: no required environment variables
R=adg, r, PeterGo
CC=golang-dev
https://golang.org/cl/1942044
2010-08-18 10:08:49 -04:00
Rob Pike
32a81fa8bb sync.once: document that Do cannot be invoked recursively.
documentation change only.

R=rsc
CC=golang-dev
https://golang.org/cl/1964043
2010-08-12 12:59:37 +10:00
Rob Pike
895c5db6df sync: add sync.Once, a proposed replacement for package once.
This implementation is simpler and more useful, since it can work
with methods.

R=rsc
CC=golang-dev
https://golang.org/cl/1864051
2010-08-05 13:31:10 +10:00
Dean Prichard
86b0ea6447 sync: allow to work on armv5
asm_arm.s was using ldrex which does not work
on armv5. Tested on Sheevaplug.

R=rsc, kaib
CC=golang-dev
https://golang.org/cl/214049
2010-02-18 15:37:16 -08:00
Russ Cox
718be3215f in C and asm, replace pkg·name with ·name
(eliminate assumption of package global name space,
make code easier to move between packages).

R=r
CC=golang-dev
https://golang.org/cl/194072
2010-01-25 18:52:55 -08:00
Robert Griesemer
d65a5cce89 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

4th set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180049
2009-12-15 15:40:16 -08:00
Péter Szabó
12206f64dd sync.RWMutex: rewritten to add support for concurrent readers.
Also made sync.xadd public to help testing sync.RWMutex.

Also added unit tests for sync.RWMutex.

R=rsc
https://golang.org/cl/162044
2009-11-30 12:10:56 -08:00
Trevor Strohman
f586870ec2 Add benchmarks for commonly used routines.
R=rsc, r, r1
https://golang.org/cl/160046
2009-11-24 00:21:50 -08:00
Sergio Luis O. B. Correia
6fc820729e go: makes it build for the case $GOROOT has whitespaces
the bash scripts and makefiles for building go didn't take into account
the fact $GOROOT / $GOBIN could both be directories containing whitespaces,
and was not possible to build it in such a situation.

this commit adjusts the various makefiles/scripts to make it aware of that
possibility, and now it builds successfully when using a path with whitespaces
as well.

Fixes #115.

R=rsc, dsymonds1
https://golang.org/cl/157067
2009-11-23 17:32:51 -08:00
Robert Griesemer
3bb0032cd6 - replaced gofmt expression formatting algorithm with
rsc's algorithm
- applied gofmt -w misc src
- partial CL (last chunk)

R=rsc, r
http://go/go-review/1024041
2009-11-09 21:23:52 -08:00
Robert Griesemer
40621d5c0d remove semis after statements in one-statement statement lists
R=rsc, r
http://go/go-review/1025029
2009-11-09 12:07:39 -08:00
Robert Griesemer
368f8cbc75 - fine-tuning of one-line func heuristic (nodes.go)
- enabled for function declarations (not just function literals)
- applied gofmt -w $GOROOT/src
(look for instance at src/pkg/debug/elf/elf.go)

R=r, rsc
CC=go-dev
http://go/go-review/1026006
2009-11-06 14:24:38 -08:00
Robert Griesemer
ed494c6398 gofmt-ify sort, sync
R=rsc
http://go/go-review/1018057
2009-11-04 23:25:29 -08:00