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

6492 Commits

Author SHA1 Message Date
Brad Fitzpatrick
13576e3b65 net/http/httptest: mimic the normal HTTP server's ResponseWriter more closely
Also adds tests, which didn't exist before.

Fixes #4188

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6613062
2012-10-07 09:48:14 -07:00
Shenghou Ma
51310d8320 testing: fix extra tabs when t.Log("string")
t.Log("line 1\nline 2\nline 3")

Old output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:25: 	line 1
		line 2
		line 3
		PASS

New output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:24: 	line 1
		line 2
		line 3
PASS

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6613069
2012-10-08 00:21:53 +08:00
Shenghou Ma
f8485954bf syscall: fix Statfs and Fstatfs on Linux/ARM
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6615055
2012-10-08 00:13:28 +08:00
Nigel Tao
d7b7957db1 image/jpeg: move the huffman bit decoder state higher up in the
decoder struct, inside the unmappedzero limit, to eliminate some
TESTB instructions in the inner decoding loop.

benchmark          old ns/op    new ns/op    delta
BenchmarkDecode      2943204      2746360   -6.69%

R=r, dave
CC=golang-dev
https://golang.org/cl/6625058
2012-10-07 19:32:28 +11:00
Nigel Tao
0b9fe6d24e image/jpeg: move the level-shift and clip out of the idct function,
to be consistent with the fdct function, and to ease any future
idct rewrites in assembly.

The BenchmarkIDCT delta is obviously just an accounting change and not
a real saving, but it does give an indication of what proportion of
time was spent in the actual IDCT and what proportion was in shift and
clip. The idct time taken is now comparable to fdct.

The BenchmarkFDCT delta is an estimate of benchmark noise.

benchmark                   old ns/op    new ns/op    delta
BenchmarkFDCT                    3842         3837   -0.13%
BenchmarkIDCT                    5611         3478  -38.01%
BenchmarkDecodeRGBOpaque      2932785      2929751   -0.10%

R=r
CC=golang-dev
https://golang.org/cl/6625057
2012-10-07 11:32:02 +11:00
Nigel Tao
f2444f0bc1 image/jpeg: clean up BenchmarkDecode and BenchmarkEncode to not
refer to opacity. Those references were copy/pasted from the
image/png encoding benchmarks, which cares whether or not the
source image is opaque, but the JPEG encoder does not care.

R=r
CC=golang-dev
https://golang.org/cl/6623052
2012-10-07 11:30:47 +11:00
Nigel Tao
12e343f372 image/jpeg: add DCT tests, do a small optimization (common sub-expression
elimination) in idct.go.

benchmark                   old ns/op    new ns/op    delta
BenchmarkIDCT                    5649         5610   -0.69%
BenchmarkDecodeRGBOpaque      2948607      2941051   -0.26%

The "type block" declaration moved so that idct.go is compilable
as a stand-alone file: "go tool 6g -S idct.go" works.

R=r
CC=golang-dev
https://golang.org/cl/6619056
2012-10-07 10:21:17 +11:00
Rob Pike
bcccad4020 text/template: fix nil crash on Templates
Fixes #3872.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6612060
2012-10-07 09:26:59 +11:00
Rob Pike
421b75c0db text/template: add an unexported method to Node
Protects the package a little against undesirable clients.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6624054
2012-10-07 07:15:11 +11: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
Dmitry Chestnykh
b459afe843 crypto/sha256, crypto/sha512: 1.3x speedup
SHA-256:

benchmark          old ns/op    new ns/op    delta
BenchmarkHash1K        21686        16912  -22.01%
BenchmarkHash8K       173216       135020  -22.05%

benchmark           old MB/s     new MB/s  speedup
BenchmarkHash1K        47.22        60.55    1.28x
BenchmarkHash8K        47.29        60.67    1.28x

SHA-512:

benchmark          old ns/op    new ns/op    delta
BenchmarkHash1K        14323        11163  -22.06%
BenchmarkHash8K       114120        88693  -22.28%

benchmark           old MB/s     new MB/s  speedup
BenchmarkHash1K        71.49        91.73    1.28x
BenchmarkHash8K        71.78        92.36    1.29x

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6584071
2012-10-05 17:04:48 -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
Robert Griesemer
1f6fba2d56 go/printer: don't forget the .0 in 1.0
(use floating-point rather then integer constant division)

gofmt -w src misc

Fixes #3965.

R=r, bsiegert, 0xjnml
CC=bradfitz, golang-dev
https://golang.org/cl/6610051
2012-10-05 08:48:23 -07:00
Robert Griesemer
1065c6f65a go/printer: parenthesize literal function types in conversions
Also: gofmt -w src misc

R=r
CC=golang-dev, iant
https://golang.org/cl/6591071
2012-10-04 21:03:50 -07:00
Robert Griesemer
6c740e769f go/parser: unify parsing of const and var declarations
The AST representation is already identical. Making the
code (nearly) identical in the parser reduces code size
and ensures that the ast.ValueSpec nodes have the same
values (specifically, iota). This in turn permits the
sharing of much of the respective code in the typechecker.

While at it: type functions work now, so use them.

R=r
CC=golang-dev
https://golang.org/cl/6624047
2012-10-04 20:53:43 -07:00
Graham Miller
9f807fcc4a net/mail: make address parsing (more) public
Code for parsing email addresses was already partially part of the public API with "func (Header) AddressList".  This CL adds a trivial implementation for two public methods to parse address and lists from a string. With tests.

R=dsymonds
CC=golang-dev
https://golang.org/cl/5676067
2012-10-05 10:08:54 +10:00
Jeff Wendling
70ab57ea2d crypto/x509: add DecryptBlock function for loading password protected keys
Adds a DecryptBlock function which takes a password and a *pem.Block and
returns the decrypted DER bytes suitable for passing into other crypto/x509
functions.

R=golang-dev, agl, leterip
CC=golang-dev
https://golang.org/cl/6555052
2012-10-04 15:42:57 -04:00
Andrew Gerrand
ce6acefc5d go/doc: add nil to list of predeclared constants
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6601054
2012-10-04 08:37:48 +10:00
Andrew Gerrand
81ae666f16 go/doc: rewrite whole file examples for playground
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6592061
2012-10-04 07:55:24 +10:00
Shenghou Ma
727e5ce95f testing: update package docs to use ResetTimer() instead of StopTimer/StartTimer()
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/6591051
2012-10-03 11:41:18 +08:00
Rob Pike
7f4b4c0c00 text/template: better error messages during execution,
They now show the correct name, the byte offset on the line, and context for the failed evaluation.
Before:
        template: three:7: error calling index: index out of range: 5
After:
        template: top:7:20: executing "three" at <index "hi" $>: error calling index: index out of range: 5
Here top is the template that was parsed to create the set, and the error appears with the action
starting at byte 20 of line 7 of "top", inside the template called "three", evaluating the expression
<index "hi" $>.

Also fix a bug in index: it didn't work on strings. Ouch.

Also fix bug in error for index: was showing type of index not slice.
The real previous error was:
        template: three:7: error calling index: can't index item of type int
The html/template package's errors can be improved by building on this;
I'll do that in a separate pass.

Extends the API for text/template/parse but only by addition of a field and method. The
old API still works.

Fixes #3188.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6576058
2012-10-03 12:02:13 +10:00
Robert Griesemer
1659aef399 go/ast: track position of <- for channel types
This is a backward-compatible API change.

Without the correct <- position information,
certain channel types have incorrect position
information.

R=iant, iant
CC=golang-dev
https://golang.org/cl/6585063
2012-10-02 17:50:36 -07:00
Shivakumar GN
5f7f9062db os/user : use username as fullname if all else fails (on windows)
Fixes #4113.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6545054
2012-10-03 10:33:09 +10:00
Robert Griesemer
05dc3bf572 go/parser: correctly parse <-chan T(x) as <-(chan T)(x)
Fixes #4110.

R=iant
CC=golang-dev
https://golang.org/cl/6597069
2012-10-02 16:48:30 -07:00
Andrew Gerrand
cf513387c3 go/doc: strip example output comment from synthesized main function
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6524047
2012-10-02 08:35:20 +10:00
Jeremy Jackins
b9e423eff3 archive/tar: fix inconsistent namespace usage in example
This fixes some example code in the tar package documentation, which
first refers to tar.NewWriter and then to Header, which is inconsistent
because NewWriter and Header are both in the tar namespace.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6595050
2012-10-02 08:10:42 +10:00
Adam Langley
9070d5759f math/big: avoid some allocation in Exp
benchmark                        old ns/op    new ns/op    delta
BenchmarkRSA1024Decrypt             745686       644964  -13.51%
BenchmarkRSA2048Decrypt            5517318      5049200   -8.48%
Benchmark3PrimeRSA2048Decrypt      3767386      3288048  -12.72%

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6566043
2012-10-01 17:31:35 -04:00
Akshat Kumar
af582674b0 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
This change updates CL 6576057 for exceptional cases where
return values from Syscall/RawSyscall functions are used.

The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6590047
2012-10-01 10:09:08 +10:00
David Symonds
ff2f851af1 exp/types: permit importing packages without available source.
R=gri, iant
CC=golang-dev
https://golang.org/cl/6586051
2012-09-30 15:56:23 +10:00
David Symonds
0b448bdef7 exp/types: better diagnosis for compile failures.
R=gri, dave
CC=golang-dev
https://golang.org/cl/6587046
2012-09-30 15:46:37 +10:00
Mikio Hara
2fee6e3788 syscall: add ipv4 ancillary data for darwin
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6586044
2012-09-29 12:43:05 +09:00
Robert Griesemer
de782dd146 container/list: slightly better code factoring
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6569077
2012-09-28 10:58:46 -07:00
Robert Griesemer
0e9daef2d1 container/list: Correctly maintain internal invariants
The previous implementation was a mess with invariants
maintained inconsistently. Essentially reimplemented
the package:

- used a circular list as internal representation for
  significantly simpler implementation with fewer
  special cases while maintaining the illusion of
  a nil-terminated doubly linked list externally

- more precise documentation

- cleaned up and simplified tests, added test case
  for issue 4103.

No changes to the API or documented semantics.

All this said, I would be in favor of removing
this package eventually. container/ring provides
a faster implementation and a simpler and more
powerful API.

Fixes #4103.

R=r
CC=golang-dev
https://golang.org/cl/6569072
2012-09-28 10:35:32 -07:00
Eric Roshan-Eisner
631a0e71c1 strings: implement a faster single-string Replacer
The string searching is implemented separately so other functions
may make use of it in the future.

benchmark                        old ns/op    new ns/op    delta
BenchmarkSingleMaxSkipping          125889         2474  -98.03%
BenchmarkSingleLongSuffixFail        16252         1996  -87.72%
BenchmarkSingleMatch                260793       136266  -47.75%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkSingleMaxSkipping           79.43      4041.57   50.88x
BenchmarkSingleLongSuffixFail        61.65       501.81    8.14x
BenchmarkSingleMatch                 57.52       110.08    1.91x

R=nigeltao
CC=golang-dev
https://golang.org/cl/6545049
2012-09-28 12:34:18 +10:00
Eric Roshan-Eisner
4bf6249ba5 testing: remove redundant whitespace in output
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6565061
2012-09-28 10:01:09 +10:00
Akshat Kumar
8fdc90acf4 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, rminnich, npe, r
CC=golang-dev
https://golang.org/cl/6576057
2012-09-28 09:56:44 +10:00
Michael Chaten
e289a2b913 bufio: Implement io.WriterTo for (*Reader)
This is part 1 of 2 for issue 4028

benchmark                       old ns/op    new ns/op    delta
BenchmarkReaderCopyOptimal          33495         9849  -70.60%
BenchmarkReaderCopyUnoptimal        70631        27041  -61.72%
BenchmarkReaderCopyOldImpl          51407        52970   +3.04%

Update #4028

R=dave, nigeltao, rsc, bradfitz, rogpeppe
CC=golang-dev
https://golang.org/cl/6548047
2012-09-27 16:31:03 +10:00
Josh Holland
348e31f8f7 text/template: fix typo of errorf as error in comment.
R=r, minux.ma
CC=gobot, golang-dev
https://golang.org/cl/6506120
2012-09-27 15:47:54 +10:00
Nigel Tao
791ac65b82 lzw: fix Write returning the wrong number of bytes written.
Fixes #4160.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6564060
2012-09-27 13:29:39 +10:00
Rob Pike
ffea835b8f fmt: allow # and x together for strings
Silly and small but easy to be consistent.
To make it worthwhile, I eliminated an allocation when using
%x on a byte slice.

Fixes #4149.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6574046
2012-09-27 06:21:38 +10:00
Sébastien Paolacci
7014bc64b1 net: spread fd over several pollservers.
Lighten contention without preventing further improvements on pollservers.
Connections are spread over Min(GOMAXPROCS, NumCPU, 8) pollserver instances.

Median of 10 runs, 4 cores @ 3.4GHz, amd/linux-3.2:

BenchmarkTCPOneShot                171917 ns/op   175194 ns/op      1.91%
BenchmarkTCPOneShot-2              101413 ns/op   109462 ns/op      7.94%
BenchmarkTCPOneShot-4               91796 ns/op    35712 ns/op    -61.10%
BenchmarkTCPOneShot-6               90938 ns/op    30607 ns/op    -66.34%
BenchmarkTCPOneShot-8               90374 ns/op    29150 ns/op    -67.75%
BenchmarkTCPOneShot-16             101089 ns/op   111526 ns/op     10.32%

BenchmarkTCPOneShotTimeout         174986 ns/op   178606 ns/op      2.07%
BenchmarkTCPOneShotTimeout-2       101585 ns/op   110678 ns/op      8.95%
BenchmarkTCPOneShotTimeout-4        91547 ns/op    35931 ns/op    -60.75%
BenchmarkTCPOneShotTimeout-6        91496 ns/op    31019 ns/op    -66.10%
BenchmarkTCPOneShotTimeout-8        90670 ns/op    29531 ns/op    -67.43%
BenchmarkTCPOneShotTimeout-16      101013 ns/op   106026 ns/op      4.96%

BenchmarkTCPPersistent              51731 ns/op    53324 ns/op      3.08%
BenchmarkTCPPersistent-2            32888 ns/op    30678 ns/op     -6.72%
BenchmarkTCPPersistent-4            25751 ns/op    15595 ns/op    -39.44%
BenchmarkTCPPersistent-6            26737 ns/op     9805 ns/op    -63.33%
BenchmarkTCPPersistent-8            26850 ns/op     9730 ns/op    -63.76%
BenchmarkTCPPersistent-16          104449 ns/op   102838 ns/op     -1.54%

BenchmarkTCPPersistentTimeout       51806 ns/op    53281 ns/op      2.85%
BenchmarkTCPPersistentTimeout-2     32956 ns/op    30895 ns/op     -6.25%
BenchmarkTCPPersistentTimeout-4     25994 ns/op    18111 ns/op    -30.33%
BenchmarkTCPPersistentTimeout-6     26679 ns/op     9846 ns/op    -63.09%
BenchmarkTCPPersistentTimeout-8     26810 ns/op     9727 ns/op    -63.72%
BenchmarkTCPPersistentTimeout-16   101652 ns/op   104410 ns/op      2.71%

R=rsc, dvyukov, dave, mikioh.mikioh, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6496054
2012-09-26 15:32:59 -04:00
David du Colombier
cca48f1a57 crypto/x509: add Plan 9 root certificate location
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/6571056
2012-09-26 14:47:47 -04:00
Shenghou Ma
948db4e091 crypto/aes: speed up using AES-NI on amd64
This CL requires CL 5970055.

benchmark           old ns/op    new ns/op    delta
BenchmarkEncrypt          161           23  -85.71%
BenchmarkDecrypt          158           24  -84.24%
BenchmarkExpand           526           62  -88.21%

benchmark            old MB/s     new MB/s  speedup
BenchmarkEncrypt        99.32       696.19    7.01x
BenchmarkDecrypt       100.93       641.56    6.36x

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6549055
2012-09-27 01:54:10 +08:00
Rob Pike
ded94b7222 reflect.DeepEqual: rewrite clarification about nil and empty slice.
The previous version was created by an idiot. This time, Rog Peppe
wrote the text. Thanks, Rog.
(== doesn't work on slices in general, so it makes no sense to
talk about in the context of DeepEqual.)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6566054
2012-09-26 20:46:49 +10:00
Mikio Hara
d6665bc338 net: fix plan 9 build
R=golang-dev, lucio.dere, fshahriar
CC=golang-dev
https://golang.org/cl/6562046
2012-09-26 16:11:49 +09:00
Rob Pike
74a7cc9bf2 reflect.DeepEqual: document that empty and nil are unequal for slices
Update #4133.
Added a sentence of documentation to call out the behavior.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6572051
2012-09-26 15:21:07 +10:00
Robert Griesemer
1785bfca6b exp/types/staging: updated gcimporter
Mostly minor changes to match the new
definitions in types.go and const.go.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6506101
2012-09-25 17:39:02 -07:00
Robert Griesemer
ebf56e086d exp/types/staging: support for typechecking (most) builtins
This code relies on some functions that are not yet in staging,
but it get's harder to keep all this in sync in a piece-meal
fashion.

R=rsc
CC=golang-dev
https://golang.org/cl/6492124
2012-09-25 17:38:43 -07:00
Robert Griesemer
f5483fb801 exp/types/staging: operands, constants, and error handling
More pieces of the typechecker code:

- Operands are temporary objects representing an expressions's
type and value (for constants). An operand is the equivalent of
an "attribute" in attribute grammars except that it's not stored
but only passed around during type checking.

- Constant operations are implemented in const.go. Constants are
represented as bool (booleans), int64 and *big.Int (integers),
*big.Rat (floats), complex (complex numbers), and string (strings).

- Error reporting is consolidated in errors.go. Only the first
dozen of lines is new code, the rest of the file contains the
exprString and typeString functions formerly in two separate
files (which have been removed).

This is a replacement CL for 6492101 (which was created without
proper use of hg).

R=rsc, r
CC=golang-dev
https://golang.org/cl/6500114
2012-09-25 17:38:22 -07:00