Adam Langley [Fri, 1 Jul 2011 17:53:12 +0000 (13:53 -0400)]
crypto/openpgp: add ability to reserialize keys.
This changes Signature so that parsed signatures can be reserialized
exactly. With this ability we can add Serialize to Entity and also the
ability to sign other public keys.
Dmitriy Vyukov [Thu, 30 Jun 2011 15:13:29 +0000 (11:13 -0400)]
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%
Julian Phillips [Thu, 30 Jun 2011 08:54:53 +0000 (18:54 +1000)]
goinstall: Add support for generic hosts using special import form
This change extends goinstall to support "magic" package names of the
form:
<host>/<repo>.<vcs>/<path>
Where <host> is the hostname, <repo> the path to the repository, <vcs>
the type of vcs (git, hg, bzr or svn), and <path> is the path inside the
repository that contains the source code for the package.
For example: "example.com/pub/foo.hg/src" means download the Mercurial
repository at either pub/foo.hg or pub/foo from example.com and then
build and install the source files from src inside the repository
checkout.
Repositories on the built-in hostings sites (github, bitbucket,
launchpad and googlecode) must still use the old form (i.e.
github.com/xxx/yyy.git/src will be rejected).
Russ Cox [Wed, 29 Jun 2011 13:52:34 +0000 (09:52 -0400)]
reflect: support for struct tag use by multiple packages
Each package using struct field tags assumes that
it is the only package storing data in the tag.
This CL adds support in package reflect for sharing
tags between multiple packages. In this scheme, the
tags must be of the form
key:"value" key2:"value2"
(raw strings help when writing that tag in Go source).
reflect.StructField's Tag field now has type StructTag
(a string type), which has method Get(key string) string
that returns the associated value.
Clients of json and xml will need to be updated.
Code that says
type T struct {
X int "name"
}
should become
type T struct {
X int `json:"name"` // or `xml:"name"`
}
Use govet to identify struct tags that need to be changed
to use the new syntax.
Russ Cox [Wed, 29 Jun 2011 03:58:35 +0000 (23:58 -0400)]
gc: fix package quoting logic
The decision for when to say "hash/crc32".New instead of
crc32.New in an error was double-counting imports
from different packages or indirect imports, so it was
quoting even when there was no ambiguity.
Gustavo Niemeyer [Tue, 28 Jun 2011 21:28:30 +0000 (22:28 +0100)]
ld: fix ELF strip by removing overlap of sections
The gosymtab and gopclntab sections were pointing to the proper
data, but that data was already owned by the rodata section.
Some ELF references explicitly prohibit multiple sections from
owning the same data, and strip behaves accordingly.
The data for these sections was moved to after rodata, and the
gosymtab and gopclntab sections now own their respective ranges.
This change makes strip happy both with and without -s being
provided at link time. Note that it won't remove these sections
because they are still allocated, and that's by design since
they are necessary at runtime for generating proper backtraces
and similar introspection operations.
Unlike the previous behavior, -s will now maintain zero-sized
gosymtab and gopclntab sections. This makes the implementation
slightly cleaner.
Dmitriy Vyukov [Tue, 28 Jun 2011 19:09:53 +0000 (15:09 -0400)]
runtime: replace Semacquire/Semrelease implementation
1. The implementation uses distributed hash table of waitlists instead of a centralized one.
It significantly improves scalability for uncontended semaphores.
2. The implementation provides wait-free fast-path for signalers.
3. The implementation uses less locks (1 lock/unlock instead of 5 for Semacquire).
4. runtime·ready() call is moved out of critical section.
5. Semacquire() does not call semwake().
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
runtime_test.BenchmarkSemaUncontended 58.20 36.30 -37.63%
runtime_test.BenchmarkSemaUncontended-2 199.00 18.30 -90.80%
runtime_test.BenchmarkSemaUncontended-4 327.00 9.20 -97.19%
runtime_test.BenchmarkSemaUncontended-8 491.00 5.32 -98.92%
runtime_test.BenchmarkSemaUncontended-16 946.00 4.18 -99.56%
Dmitriy Vyukov [Tue, 28 Jun 2011 13:43:01 +0000 (09:43 -0400)]
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%
Rob Pike [Tue, 28 Jun 2011 13:04:08 +0000 (23:04 +1000)]
Add the beginnings of the template execution code. Lots still to do,
including evaluation up the data tree (in this code all fields must be
in dot itself), plus more control structure, but the basics are in place.
R=rsc, r
CC=golang-dev
https://golang.org/cl/4665041
Dmitriy Vyukov [Tue, 28 Jun 2011 12:14:54 +0000 (08:14 -0400)]
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.
Russ Cox [Tue, 28 Jun 2011 02:42:34 +0000 (22:42 -0400)]
cc: add two new #pragma varargck
#pragma varargck countpos f 1
says that the first argument to f is
the count of variadic arguments that follow.
#pragma varargck type f t
says that t is one of the allowed types for
a variadic argument to f.
(can be repeated)
combined, these can be used to check the
runtime.stdcall functions in the windows port
or in any other port that needs a vararg list of
uintptrs even on a 64-bit platform (where it is
very easy to pass a less-than-uintptr in the ...).
demo:
typedef unsigned int uintptr;
#pragma varargck countpos f 1
#pragma varargck type f uintptr
#pragma varargck type f void*
int f(int count, ...);
void *v;
char *p;
void
main(void)
{
f(1, v); // ok
f(1, main); // ok
f(1, p); // ok
f(2, v, v); // ok
f(2, v); // found 1 argument after count 2
f(1, 'a'); // invalid type INT in call to f
f(1, 0); // invalid type INT in call to f
}
Rob Pike [Mon, 27 Jun 2011 23:43:14 +0000 (09:43 +1000)]
strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.
Kyle Lemons [Mon, 27 Jun 2011 23:07:28 +0000 (19:07 -0400)]
xml: add Marshal and MarshalIndent
I have written up a Marshal and MarshalIndent pair that should
closely reflect the way that Unmarshal works. I would love feedback
on making this code more accessible and efficient... I haven't used
reflecton on this scale before, so there is probably a lot of work
that can be done on that.
Some potentially controversial things:
- All tag names are lower-cased by default.
- Zero-valued struct values are skipped.
- No namespace prefix (o:tag, etc) mechanism is supplied.
- You are allowed to marshal non-struct values (even though unmarshal
cannot handle them).
- A tag for a non-XMLName struct field that isn't "attr", "chardata",
or "innerxml" is used as the name of the tag. This could wreak
havoc if you try to marshal a protobuf struct.
- The "innerxml" and "chardata" are inserted verbatim. If you try to
marshal something straight from unmarshal, the results could be
unexpected (remove "innerxml" support from Marshal would be one
possible solution).
Graham Miller [Mon, 27 Jun 2011 20:12:04 +0000 (16:12 -0400)]
bufio: do not cache Read errors
Reader previously had cached an error from the underlying reader
and would return it on every subsequent call to Read. The Reader
will now return the error only once, and subsequent calls will result
in a new Read call to the underlying Reader.
Lucio De Re [Mon, 27 Jun 2011 18:42:18 +0000 (14:42 -0400)]
8a: fixes for Plan 9 build
8a/a.h:
. Removed <u.h> and <libc.h> includes as they work better in "a.y".
. Made definition of EOF conditional as it's defined in the Plan 9
header files, but not elsewhere.
8a/a.y:
. Added <u.h> and <libc.h> because <stdio.h> in Plan 9 needs them.
Sequence <u.h>, <stdio.h>, <libc.h> recommended by RSC.
8a/lex.c:
. Added <u.h> and <libc.h> as now needed by "a.h".
. Dropped <ctype.h>.
Brad Fitzpatrick [Mon, 27 Jun 2011 17:37:33 +0000 (10:37 -0700)]
http: do TLS handshake explicitly before copying TLS state
Previously we were snapshotting the TLS state into *Request
before we did the HTTP ReadRequest, the first Read of which
triggered the TLS handshake implicitly.
Dmitriy Vyukov [Mon, 27 Jun 2011 17:31:40 +0000 (13:31 -0400)]
gotest: add -test.benchtime and -test.cpu flags.
-test.benchtime allows to specify benchmark execution time.
-test.cpu allows to execute tests/benchmarks for several
values of GOMAXPROCS.
Michael T. Jones [Sat, 25 Jun 2011 00:26:45 +0000 (17:26 -0700)]
fmt: Added SkipSpace() function to fmt's ScanState interface.
Users of the Scan() infrastructure that employ ReadRune() rather than
Token() need a way to skip leading spaces and newlines as set by the
the parent, Fscan(), Fscanln, or Fscanf(). As the internal methods and
boolean flags are not exported, this new function was added here and
in the Int and Nat Scan() functions of the big package. (fmt.Rat did
not need change since it uses Token()) Also added Printf style format
code support to int types and tests for same to int_test.go
Brad Fitzpatrick [Fri, 24 Jun 2011 23:46:14 +0000 (16:46 -0700)]
http: better handling of 0-length Request.Body
As rsc suggested after change 58a6bdac3d12 was committed, we
now read the first byte of Request.Body when the
Request.ContentLength is 0 to disambiguate between a truly
zero-length body and a body of unknown length where the user
didn't set the ContentLength field.
This was also causing the reverse proxy problem where incoming
requests (which always have a body, of private type http.body,
even for 0-lengthed requests) were being relayed to the http
Transport for fetching, which was serializing the request as a
chunked request (since ContentLength was 0 and Body was
non-nil)
Gustavo Niemeyer [Fri, 24 Jun 2011 03:29:59 +0000 (00:29 -0300)]
runtime: don't use twice the memory with grsec-like kernels
grsec needs the FIXED flag to be provided to mmap, which
works now. That said, when the allocation fails to be made
in the specific address, we're still given back a writable
page. This change will unmap that page to avoid using
twice the amount of memory needed.
It'd also be pretty easy to avoid the extra system calls
once we detected that the flag is needed, but I'm not sure
if that edge case is worth the effort.