Commit Graph

5677 Commits

Author SHA1 Message Date
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
Dave Cheney
d165dc6036 build: handle broken awk in version.bash
R=adg, rsc, ality
CC=golang-dev
https://golang.org/cl/4281069
2011-03-25 18:00:19 -04:00
Rob Pike
d406f8f650 testing: set up structure for faster testing using the new -test.short flag.
New make target "testshort" runs "gotest -test.short" and is invoked
by run.bash, which is invoked by all.bash.

Use -test.short to make one package (crypto ecdsa) run much faster.
More changes to come.

Once this is in, I will update the long-running tests to use the new flag.

R=rsc
CC=golang-dev
https://golang.org/cl/4317043
2011-03-25 14:50:44 -07:00
Peter Mundy
91bcdb620b net: fix Windows build
R=rsc
CC=golang-dev
https://golang.org/cl/4314042
2011-03-25 16:11:19 -04:00
Albert Strasheim
e83d69647f syscall: GetsockoptInt for darwin, freebsd.
R=rsc
CC=golang-dev
https://golang.org/cl/4298060
2011-03-25 14:43:59 -04:00
Albert Strasheim
e480b81971 net: add FileConn, FilePacketConn, FileListener
R=iant, rsc, brainman
CC=golang-dev
https://golang.org/cl/4306042
2011-03-25 14:42:25 -04:00
Rob Pike
9db2bc741e flag: fix error in documentation example.
Fixes #1615.
This time for sure.

R=rsc, gri
CC=golang-dev
https://golang.org/cl/4275079
2011-03-25 11:28:31 -07:00
Russ Cox
071d212a22 runtime/pprof: disable test on darwin
Fixes #1641.

Actually it side steps the real issue, which is that the
setitimer(2) implementation on OS X is not useful for
profiling of multi-threaded programs.  I filed the below
using the Apple Bug Reporter.

/*
Filed as Apple Bug Report #9177434.

This program creates a new pthread that loops, wasting cpu time.
In the main pthread, it sleeps on a condition that will never come true.
Before doing so it sets up an interval timer using ITIMER_PROF.
The handler prints a message saying which thread it is running on.

POSIX does not specify which thread should receive the signal, but
in order to be useful in a user-mode self-profiler like pprof or gprof
   http://code.google.com/p/google-perftools
   http://www.delorie.com/gnu/docs/binutils/gprof_25.html
it is important that the thread that receives the signal is the one
whose execution caused the timer to expire.

Linux and FreeBSD handle this by sending the signal to the process's
queue but delivering it to the current thread if possible:

   http://lxr.linux.no/linux+v2.6.38/kernel/signal.c#L802
     807        /*
     808         * Now find a thread we can wake up to take the signal off the queue.
     809         *
     810         * If the main thread wants the signal, it gets first crack.
     811         * Probably the least surprising to the average bear.
     812         * /

   http://fxr.watson.org/fxr/source/kern/kern_sig.c?v=FREEBSD8;im=bigexcerpts#L1907
     1914         /*
     1915          * Check if current thread can handle the signal without
     1916          * switching context to another thread.
     1917          * /

On those operating systems, this program prints:

    $ ./a.out
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    signal on cpu-chewing looper thread
    $

The OS X kernel does not have any such preference.  Its get_signalthread
does not prefer current_thread(), in contrast to the other two systems,
so the signal gets delivered to the first thread in the list that is able to
handle it, which ends up being the main thread in this experiment.
http://fxr.watson.org/fxr/source/bsd/kern/kern_sig.c?v=xnu-1456.1.26;im=excerpts#L1666

    $ ./a.out
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    signal on sleeping main thread
    $

The fix is to make get_signalthread use the same heuristic as
Linux and FreeBSD, namely to use current_thread() if possible
before scanning the process thread list.

*/

#include <sys/time.h>
#include <sys/signal.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

static void handler(int);
static void* looper(void*);

static pthread_t pmain, ploop;

int
main(void)
{
        struct itimerval it;
        struct sigaction sa;
        pthread_cond_t cond;
        pthread_mutex_t mu;

        memset(&sa, 0, sizeof sa);
        sa.sa_handler = handler;
        sa.sa_flags = SA_RESTART;
        memset(&sa.sa_mask, 0xff, sizeof sa.sa_mask);
        sigaction(SIGPROF, &sa, 0);

        pmain = pthread_self();
        pthread_create(&ploop, 0, looper, 0);

        memset(&it, 0, sizeof it);
        it.it_interval.tv_usec = 10000;
        it.it_value = it.it_interval;
        setitimer(ITIMER_PROF, &it, 0);

        pthread_mutex_init(&mu, 0);
        pthread_mutex_lock(&mu);

        pthread_cond_init(&cond, 0);
        for(;;)
                pthread_cond_wait(&cond, &mu);

        return 0;
}

static void
handler(int sig)
{
        static int nsig;
        pthread_t p;

        p = pthread_self();
        if(p == pmain)
                printf("signal on sleeping main thread\n");
        else if(p == ploop)
                printf("signal on cpu-chewing looper thread\n");
        else
                printf("signal on %p\n", (void*)p);
        if(++nsig >= 10)
                exit(0);
}

static void*
looper(void *v)
{
        for(;;);
}

R=r
CC=golang-dev
https://golang.org/cl/4273113
2011-03-25 13:47:07 -04:00
Ian Lance Taylor
7c616b3809 runtime: always set *received in chanrecv.
Also fix comment.

The only caller of chanrecv initializes the value to false, so
this patch makes no difference at present.  But it seems like
the right thing to do.

R=rsc
CC=golang-dev
https://golang.org/cl/4312053
2011-03-25 10:36:22 -07:00
Ian Lance Taylor
f6d0e81179 runtime/darwin: remove unused local variables.
R=rsc
CC=golang-dev
https://golang.org/cl/4309049
2011-03-25 10:35:46 -07:00
Russ Cox
e857dd5d3f http/pprof: cpu profiling support
R=r
CC=golang-dev
https://golang.org/cl/4280060
2011-03-25 12:50:12 -04:00
Roger Pau Monné
500effe79e http: modified perl cgi test to remove newline from env variables
Fixes #1639

R=golang-dev, bradfitzgo
CC=golang-dev
https://golang.org/cl/4291069
2011-03-25 09:33:45 -07:00
Russ Cox
1f2234633f runtime: fix arm build
R=adg, dfc, r
CC=golang-dev
https://golang.org/cl/4296042
2011-03-25 12:30:49 -04:00
Devon H. O'Dell
e37892c36c freebsd-386: update defs
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4273102
2011-03-25 10:18:04 +11:00
Robert Griesemer
1b2c3e664b go/parser: resolve identifiers properly
Correctly distinguish between lhs and rhs identifiers
and resolve/declare them accordingly.

Collect field and method names in respective scopes
(will be available after some minor AST API changes).

Also collect imports since it's useful to have that
list directly w/o having to re-traverse the AST
(will also be available after some minor AST API changes).

No external API changes in this CL.

R=rsc, rog
CC=golang-dev
https://golang.org/cl/4271061
2011-03-24 11:45:52 -07:00
Rob Pike
d1b75bbc46 gob: remove another allocation.
The top level bytes.Buffer is always there and can be re-used.
Rpc goes from 83 to 79 mallocs per round trip.

R=rsc
CC=golang-dev
https://golang.org/cl/4271062
2011-03-23 21:49:19 -07:00
Andrew Gerrand
1c05a90ae2 runtime: fix freebsd-amd64 (and part of 386)
R=rsc
CC=golang-dev
https://golang.org/cl/4285063
2011-03-24 11:45:12 +11:00
Alex Brainman
913c8d7397 syscall: StartProcess fixes for windows
- StartProcess will work with relative (to attr.Dir, not
  current directory) executable filenames
- StartProcess will only work if executable filename points
  to the real file, it will not search for executable in the
  $PATH list and others (see CreateProcess manual for details)
- StartProcess argv strings can contain any characters

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4306041
2011-03-24 11:20:28 +11:00
Russ Cox
543acc97f9 testing: add -test.cpuprofile flag
R=r
CC=golang-dev
https://golang.org/cl/4272066
2011-03-23 18:17:14 -04:00
Luuk van Dijk
14b9032f84 5l/6l/8l: undo spadj cleanup at ARET for following instructions in the same stackframe.
5l was already correct, clarified comment and added diags for unmaintained code.

R=rsc
CC=golang-dev
https://golang.org/cl/4277070
2011-03-23 23:11:29 +01:00
Brad Fitzpatrick
9d3b39986c http: don't chunk 304 responses
rsc's earlier fix, plus tests.

R=rsc
CC=golang-dev
https://golang.org/cl/4285062
2011-03-23 14:29:26 -07:00
Brad Fitzpatrick
054a0c338f gotest: fix gofmt issue in generated _testmain.go
R=rsc, r
CC=golang-dev
https://golang.org/cl/4287074
2011-03-23 14:23:05 -07:00
Albert Strasheim
c6810e76ed syscall: GetsockoptInt.
R=rsc, iant
CC=golang-dev
https://golang.org/cl/4271060
2011-03-23 14:33:48 -04:00
Russ Cox
f2483c74f6 gofmt: add profiling flag
R=gri
CC=golang-dev
https://golang.org/cl/4295062
2011-03-23 14:28:38 -04:00
Russ Cox
b47ec598b7 runtime/pprof: cpu profiling support
R=r, bradfitzgo, r2
CC=golang-dev
https://golang.org/cl/4313041
2011-03-23 13:54:31 -04:00
Brad Fitzpatrick
059c07cab0 http: export Transport, add keep-alive support
This patch adds a connection cache and keep-alive
support to Transport, which is used by the
HTTP client.

It's also structured such that it's easy to add
HTTP pipelining in the future.

R=rsc, petar-m, bradfitzwork, r
CC=golang-dev
https://golang.org/cl/4272045
2011-03-23 10:38:18 -07:00
Russ Cox
c19b373c8a runtime: cpu profiling support
R=r
CC=golang-dev
https://golang.org/cl/4306043
2011-03-23 11:43:37 -04:00
Russ Cox
f9fc1ddf75 runtime: fix print - no %v in C
R=r
CC=golang-dev
https://golang.org/cl/4280061
2011-03-23 11:34:03 -04:00
Russ Cox
fba0606220 godefs: handle volatile
R=iant
CC=golang-dev
https://golang.org/cl/4291063
2011-03-23 11:33:53 -04:00
Russ Cox
8dee872963 runtime: os-specific types and code for setitimer
R=r
CC=golang-dev
https://golang.org/cl/4273097
2011-03-23 11:31:42 -04:00
Russ Cox
ccdbb8a6c2 runtime: more stack split fixes
Found by stkcheck after 6l, 8l bug fixes Luuk is about to submit.

R=lvd
CC=golang-dev
https://golang.org/cl/4306047
2011-03-23 11:28:24 -04: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
Ken Thompson
a73817716a chan: allocate a new chan with one
malloc rather than nelements + 1.

R=rob
CC=golang-dev
https://golang.org/cl/4291064
2011-03-22 18:41:17 -07:00
Andrew Gerrand
005fe41125 godoc: add -template flag to specify custom templates
R=gri, niemeyer, rsc1
CC=golang-dev
https://golang.org/cl/4291059
2011-03-23 09:44:23 +11:00
Robert Griesemer
76061f7240 go/printer: Revert API change of CL 4274075.
Revert changes to printer.Config. Pass in the
nodeSizes map trough an internal helper function.

R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4309042
2011-03-22 14:14:26 -07:00
Ian Lance Taylor
bc0469da33 Make.pkg: Always define _CGO_CFLAGS and friends.
Submitting TBR to fix Darwin build.

TBR=rsc
CC=golang-dev
https://golang.org/cl/4273096
2011-03-22 13:30:16 -07:00
Ian Lance Taylor
f91b37b962 Make.pkg: add support for SWIG, and add two SWIG examples
The SWIG examples are not yet built or tested by default.

R=r, rsc, iant2
CC=golang-dev
https://golang.org/cl/4287056
2011-03-22 13:05:51 -07:00
Rob Pike
f492bd7012 gob: fix up ugly formatting introduced by buggy (now fixed) gofmt.
R=rsc
CC=golang-dev
https://golang.org/cl/4281065
2011-03-22 11:52:41 -07:00
Rob Pike
544cf75904 gob: use pointers in bootstrapType so interfaces behave properly
and don't lead to a nil reflect.Type.
Fixes #1626.

R=rsc
CC=golang-dev
https://golang.org/cl/4289062
2011-03-22 11:43:00 -07:00
Robert Griesemer
6684d5503a go/printer, gofmt: simplify struct formatting and respect line breaks
Also: gofmt src misc

Fixes #1627.

R=rsc
CC=golang-dev
https://golang.org/cl/4303042
2011-03-22 11:05:26 -07:00
Russ Cox
1da382c871 gopprof: fix bug: do not rotate 180 degrees for large scrolls
R=r
CC=golang-dev
https://golang.org/cl/4273088
2011-03-22 02:04:59 -04:00
Andrew Gerrand
d4b19bdbed ld: return > 0 exit code on unsafe import
R=rsc
CC=golang-dev
https://golang.org/cl/4273092
2011-03-22 15:00:21 +11:00
Robert Griesemer
4a33d440b8 go/printer, gofmt: avoid exponential layout algorithm
Use memoization to avoid repeated recomputation of nested
node sizes. Speeds up testdata/slow.input by several orders
of magnitude.

- added respective test case
- added timeout to test code
- deleted some unrelated unused code

Fixes #1628.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4274075
2011-03-21 17:15:59 -07:00
Brad Fitzpatrick
708013064f cgi: extra failure debugging in host_test
Trying to track down why this fails on some
people's machines.

R=rsc, adg, dsymonds
CC=golang-dev
https://golang.org/cl/4304041
2011-03-21 14:43:38 -07:00
Rob Pike
45aeca4727 time: give a helpful message when we can't set the time zone for testing.
Fixes #1625.

R=bradfitzgo, bradfitzwork, r2
CC=golang-dev
https://golang.org/cl/4295060
2011-03-21 13:48:31 -07:00
Rob Pike
319a8c45ac syscall: rename from .sh to .pl, because these files are in Perl.
Also delete references to nacl.

R=rsc, r2
CC=golang-dev
https://golang.org/cl/4275060
2011-03-21 13:02:10 -07:00
Gustavo Niemeyer
2187f43e63 exec: document dir option for Run
R=golang-dev, bradfitzwork, rsc1, peterGo
CC=golang-dev
https://golang.org/cl/4271056
2011-03-21 11:25:00 -03:00
Gustavo Niemeyer
b889a9f941 build: reenable clean.bash without gomake
This change had already been made in revision 7371, but
was then undone with changes in revision 7606.

R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4239064
2011-03-21 00:27:50 -03:00
Andrew Gerrand
f91e677e12 goinstall: add -clean flag to docs
Fixes #1629.

R=rsc
CC=golang-dev
https://golang.org/cl/4291057
2011-03-21 14:18:12 +11:00
Gustavo Niemeyer
126911dcd2 rpc: increase server_test timeout
These timeouts are breaking tests in very slow
systems every once in a while.  I've noticed
problems when compiling the Ubuntu packages for
arm, specifically.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4291058
2011-03-21 00:07:22 -03:00