Robert Griesemer [Thu, 17 Mar 2011 22:32:29 +0000 (15:32 -0700)]
go/parser: fix memory leak by making a copy of token literals
The scanner returns slices into the original source
for token values. If those slices are making it into
the AST and from there into other long-living data
structures (e.g. godoc search), references to the
original source are kept around involuntarily.
For the current godoc and source tree, this change reduces
memory consumption after indexing and before GC by ~92MB
or almost 30%, and by ~10MB after GC (or about 6%).
Ian Lance Taylor [Thu, 17 Mar 2011 20:42:40 +0000 (13:42 -0700)]
net: Don't force epoll/kqueue to wake up in order to add new events.
In conjunction with the non-blocking system call CL, this
gives about an 8% performance improvement on a client/server
test running on my local machine.
Rob Pike [Thu, 17 Mar 2011 17:47:42 +0000 (10:47 -0700)]
gob: eliminate two more allocations in decode.
- just an oversight; we were reallocating a buffer.
- use unsafe to avoid allocating storage for a string twice.
Rob Pike [Thu, 17 Mar 2011 01:03:13 +0000 (18:03 -0700)]
gob: remove a few more allocations.
- use enc.err and dec.err instead of return values in deferred error catcher
- replace io.WriteString with buffer.WriteString
now at:
mallocs per encode of type Bench: 7
mallocs per decode of type Bench: 8
Rob Pike [Wed, 16 Mar 2011 17:32:21 +0000 (10:32 -0700)]
testing: compile regexp only once
The -test.run and -test.bench flags were compilng the regexp for ever test
function, which was mucking up memory profiles. Add a simple wrapper
to save the compiled state so that the regexp is compiled only once for
each flag.
Robert Griesemer [Wed, 16 Mar 2011 00:45:16 +0000 (17:45 -0700)]
go/printer: output tuning for gofix
If braces don't have position information for a composite
literal, don't assume alignment of key:value pairs under
the (wrong) assumption that there may be multiple lines.
Rob Pike [Tue, 15 Mar 2011 17:02:44 +0000 (10:02 -0700)]
rpc: add buffering to the encode path.
This reduces the number of writes by 2 (1 client, 1 server) on each round trip.
A simple test shows 24% higher throughput.
Russ Cox [Mon, 14 Mar 2011 17:22:34 +0000 (13:22 -0400)]
gc: include all dependencies in export metadata
This change records more metadata about what
influenced the creation of the object file.
Specifically, if a package imports, say, "fmt" but does not
need to describe any fmt types in its own export data,
that package's object file did not mention the dependency
on "fmt" before. Now it does.
Listing the import is purely informational.
It has no effect on which files are opened or consulted
when importing a package.
Import lines are marked indirect when they are needed
to explain the API but were not imported directly.
For example http imports crypto/tls and exports
a struct with a field of type tls.ConnectionState,
which contains an x509.Certificate. Since http does
not import x509 but needs to explain the x509.Certificate
type in its export data, the import of x509 is marked
as indirect. These import lines were always present;
marking them with the indirect comment makes clear
which were imported directly and which are incidental.
Ian Lance Taylor [Sat, 12 Mar 2011 02:01:28 +0000 (18:01 -0800)]
net: don't loop to drain wakeup pipe.
The loop always makes an extra system call. It only makes a
difference if more than 100 goroutines started waiting for
something to happen on a network file descriptor since the
last time the pipe was drained, which is unlikely since we
will be woken up the first time a goroutine starts waiting.
If we don't drain the pipe this time, we'll be woken up again
right away and can drain again.
Rob Pike [Sat, 12 Mar 2011 00:24:09 +0000 (16:24 -0800)]
gob: use bufio on the decode to avoid a system call on each read.
Add a benchmark.
BenchmarkEndToEndPipe gives 14.3microseconds/op before,
13.1microseconds/op after, or about 76e3 round trips per second
through the kernel.
With a bytes buffer, and therefore no system calls for I/O, the
numbers go to 7.3microseconds/op, or about 137e3 round trips
per second.
Ian Lance Taylor [Wed, 9 Mar 2011 21:15:46 +0000 (13:15 -0800)]
syslog: split Unix domain support from network support.
This is to make it easier to support Solaris syslog. On
Solaris syslog messages are sent via STREAMS using putmsg to
/dev/conslog. The putmsg call uses a a control buffer of type
log_cdtl and a data buffer which is the message, and it is in
general a big mess. This CL just splits out the Unix domain
support so that Solaris can use a different mechanism. I do
not propose to implement the Solaris support today. This
split will make it possible for gccgo to just call the libc
function for now.
Roger Peppe [Wed, 9 Mar 2011 18:01:47 +0000 (10:01 -0800)]
fmt: make ScanState.Token more general.
When writing custom scanners, I found that
Token itself was rarely useful, as I did not always
want to stop at white space. This change makes
it possible to stop at any class of characters
while reusing the buffer within State.
(also fix a bug in Token)
Russ Cox [Wed, 9 Mar 2011 16:18:29 +0000 (11:18 -0500)]
ld: preserve symbol sizes during data layout
Fixes the broken linux/amd64 build.
The symbol table, itself a symbol, was having
its size rounded up to the nearest word boundary.
If the rounding add >7 zero bytes then it confused
the debug/gosym symbol table parser. So you've
got a 1/8 chance to hit the bug on an amd64 system.
Just started in the recent change because I fixed
the rounding to round to word boundary instead
of to 4-byte boundary.
David Anderson [Wed, 9 Mar 2011 13:58:47 +0000 (05:58 -0800)]
syscall: implement Mount and Unmount for linux.
Note that, while the final argument of mount(2) is a void*, in
practice all filesystem implementations treat it as a string
of comma-separated mount options.
Robert Griesemer [Wed, 9 Mar 2011 01:27:44 +0000 (17:27 -0800)]
big: implemented custom Gob(En/De)coder for Int type
- factored implementation of Int.Bytes, Int.SetBytes
and replaced existing code with much simpler cores
- use the shared bytes, setBytes routines for Gob
(en/de)coding