1. 28 Feb, 2016 7 commits
    • Joe Tsai's avatar
      compress/bzip2: fix benchmark to actually measure decompression rate · ff274210
      Joe Tsai authored
      Motivation:
      * Previously, the size of the compressed data was used for metrics,
      rather than the uncompressed size. This causes the library to appear
      to perform poorly relative to C or other implementation. Switch it
      to use the uncompressed size so that it matches how decompression
      benchmarks are usually done (like in compress/flate). This also makes
      it easier to compare bzip2 rates to other algorithms since they measure
      performance in this way.
      * Also, reset the timer after doing initialization work.
      
      Change-Id: I32112c2ee8e7391e658c9cf31039f70a689d9b9d
      Reviewed-on: https://go-review.googlesource.com/17611Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ff274210
    • Joe Tsai's avatar
      compress/bzip2: use correct block size · 47379929
      Joe Tsai authored
      The bzip2 block size is a multiple of 100*1000 not 100*1024.
      Thus, the bzip2 decoder would incorrectly decode files with larger
      block sizes when it should have otherwise failed.
      Fortunately, we can correct this in a backwards compatible way since
      Go has no implementation of a bzip2 encoder to produce bad blocks :)
      
      To confirm that the C bzip2 utlity chokes on this data:
      	$ echo "425a683131415926535936dc55330063ffc0006000200020a40830008b00
      	08b8bb9229c28481b6e2a998" | xxd -r -p | bzip2 -d
      
      	bzip2: Data integrity error when decompressing.
      
      Fixes #13941
      
      Change-Id: I2402e8829a8027ef94dd4fac050b200440a3d4e4
      Reviewed-on: https://go-review.googlesource.com/20011
      Run-TryBot: Joe Tsai <joetsai@digital-static.net>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      47379929
    • Joe Tsai's avatar
      compress/flate: extract LZ77 dictionary logic into seperate struct · 5fc4decd
      Joe Tsai authored
      The LZ77 portion of DEFLATE is relatively self-contained. For the
      decompression side of things, we extract this logic out for the
      following reasons:
      * It is easier to test just the LZ77 portion of the logic.
      * It reduces the noise in the inflate.go
      
      Also, we adjust the way that callbacks are handled in the inflate.
      Instead of using functions to abstract the logical componets of
      huffmanBlock(), use goto statements to jump between the necessary
      sections. This is faster since it avoids a function call and is
      arguably more readable.
      
      benchmark                              old MB/s     new MB/s     speedup
      BenchmarkDecodeDigitsSpeed1e4-4        53.62        60.11        1.12x
      BenchmarkDecodeDigitsSpeed1e5-4        61.90        69.07        1.12x
      BenchmarkDecodeDigitsSpeed1e6-4        63.24        70.58        1.12x
      BenchmarkDecodeDigitsDefault1e4-4      54.10        59.00        1.09x
      BenchmarkDecodeDigitsDefault1e5-4      69.50        74.07        1.07x
      BenchmarkDecodeDigitsDefault1e6-4      71.54        75.85        1.06x
      BenchmarkDecodeDigitsCompress1e4-4     54.39        58.94        1.08x
      BenchmarkDecodeDigitsCompress1e5-4     69.21        73.96        1.07x
      BenchmarkDecodeDigitsCompress1e6-4     71.14        75.75        1.06x
      BenchmarkDecodeTwainSpeed1e4-4         53.15        58.13        1.09x
      BenchmarkDecodeTwainSpeed1e5-4         66.56        72.29        1.09x
      BenchmarkDecodeTwainSpeed1e6-4         69.13        75.11        1.09x
      BenchmarkDecodeTwainDefault1e4-4       56.00        60.23        1.08x
      BenchmarkDecodeTwainDefault1e5-4       77.84        82.27        1.06x
      BenchmarkDecodeTwainDefault1e6-4       82.07        86.85        1.06x
      BenchmarkDecodeTwainCompress1e4-4      56.13        60.38        1.08x
      BenchmarkDecodeTwainCompress1e5-4      78.23        82.62        1.06x
      BenchmarkDecodeTwainCompress1e6-4      82.38        86.73        1.05x
      
      Change-Id: I8c6ae0e6bed652dd0570fc113c999977f5e71636
      Reviewed-on: https://go-review.googlesource.com/16528Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      5fc4decd
    • Caio Marcelo de Oliveira Filho's avatar
      testing: make failure in benchmark cause non-zero exit status · 3cb870d4
      Caio Marcelo de Oliveira Filho authored
      Moves the implementation of RunBenchmarks to a non-exported function
      that returns whether the execution was OK, and uses that to identify
      failure in benchmarks.The exported function is kept for compatibility.
      
      Like before, benchmarks will only be executed if tests and examples
      pass. The PASS message will not be printed if there was a failure in
      a benchmark.
      
      Example output
      
      	BenchmarkThatCallsFatal-8	--- FAIL: BenchmarkThatCallsFatal-8
      		x_test.go:6: called by benchmark
      	FAIL
      	exit status 1
      	FAIL	_/.../src/cmd/go/testdata/src/benchfatal	0.009s
      
      Fixes #14307.
      
      Change-Id: I6f3ddadc7da8a250763168cc099ae8b325a79602
      Reviewed-on: https://go-review.googlesource.com/19889Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      3cb870d4
    • Ian Lance Taylor's avatar
      cmd/cgo: add hooks for thread sanitizer · c8ef0df0
      Ian Lance Taylor authored
      When Go code is used with C code compiled with -fsanitize=thread, adds
      thread sanitizer calls so that correctly synchronized Go code does not
      cause spurious failure reports from the thread sanitizer.  This may
      cause some false negatives, but for the thread sanitizer what is most
      important is avoiding false positives.
      
      Change-Id: If670e4a6f2874c7a2be2ff7db8728c6036340a52
      Reviewed-on: https://go-review.googlesource.com/17421Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      c8ef0df0
    • kortschak's avatar
      misc/cgo/fortran: clean up after successful helloworld.90 build · c86dbbe1
      kortschak authored
      Change-Id: If03185a21e088c9b383a82c14d649805f00c8042
      Reviewed-on: https://go-review.googlesource.com/20000Reviewed-by: default avatarMinux Ma <minux@golang.org>
      c86dbbe1
    • Austin Clements's avatar
      runtime: clean up adjustpointer and eliminate write barrier · d62d8318
      Austin Clements authored
      Commit a5c3bbe0 modified adjustpointers to use *uintptrs instead of
      *unsafe.Pointers for manipulating stack pointers for clarity and to
      eliminate the unnecessary write barrier when writing the updated stack
      pointer.
      
      This commit makes the equivalent change to adjustpointer.
      
      Change-Id: I6dc309590b298bdd86ecdc9737db848d6786c3f7
      Reviewed-on: https://go-review.googlesource.com/17148Reviewed-by: default avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d62d8318
  2. 27 Feb, 2016 11 commits
    • Ian Lance Taylor's avatar
      cmd/cgo: recognize known C typedefs as types · 71cc445c
      Ian Lance Taylor authored
      Fixes #14483.
      
      Change-Id: I0cddfe27fd8d00ba85659d0b618410e39ebf45cb
      Reviewed-on: https://go-review.googlesource.com/19860Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      71cc445c
    • Ian Lance Taylor's avatar
      cmd/compile: change Func.Cvars to the new Nodes type · 922ce58d
      Ian Lance Taylor authored
      Update #14473.
      
      Change-Id: Iba1ecf42d9ab5a93144941439d5cc6b0b4f4a3ac
      Reviewed-on: https://go-review.googlesource.com/19992Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      922ce58d
    • Martin Möhrmann's avatar
      fmt: simplify buffer write methods and adjust calls to them · 7da4cedd
      Martin Möhrmann authored
      Once upon a time fmt did use bytes.Buffer for its buffer.
      The buffer write methods still mimic the bytes.Buffer signatures.
      The current code depends on manipulating the buffer []bytes array directly
      which makes going back to bytes.Buffer by only changing the type of buffer
      impossible. Since type buffer is not exported the methods can be simplified
      to the needs of fmt. This saves space and avoids unnecessary overhead.
      
      Use WriteString instead of Write for known inputs since
      WriteString is faster than Write to append the same data.
      This also saves space in the binary.
      
      Remove the add method from Printer and depending on the data to be written
      use WriteRune or WriteByte directly instead.
      
      In total makes the go binary around 4 kilobyte smaller.
      
      name                  old time/op  new time/op  delta
      SprintfEmpty-2        24.1ns ± 3%  23.8ns ± 1%  -1.14%  (p=0.000 n=20+20)
      SprintfString-2        114ns ± 2%   114ns ± 4%    ~     (p=0.558 n=20+19)
      SprintfInt-2           116ns ± 9%   118ns ± 7%    ~     (p=0.086 n=20+20)
      SprintfIntInt-2        195ns ± 6%   193ns ± 5%    ~     (p=0.345 n=20+19)
      SprintfPrefixedInt-2   251ns ±16%   241ns ± 9%  -3.69%  (p=0.024 n=20+19)
      SprintfFloat-2         203ns ± 4%   205ns ± 5%    ~     (p=0.153 n=20+20)
      SprintfBoolean-2       101ns ± 7%    96ns ±11%  -5.23%  (p=0.005 n=19+20)
      ManyArgs-2             651ns ± 7%   628ns ± 7%  -3.44%  (p=0.002 n=20+20)
      FprintInt-2            164ns ± 2%   158ns ± 2%  -3.62%  (p=0.000 n=20+18)
      FprintfBytes-2         215ns ± 1%   216ns ± 1%  +0.58%  (p=0.000 n=20+20)
      FprintIntNoAlloc-2     115ns ± 0%   112ns ± 0%  -2.61%  (p=0.000 n=20+20)
      ScanInts-2             700µs ± 0%   702µs ± 1%  +0.38%  (p=0.000 n=18+20)
      ScanRecursiveInt-2    82.7ms ± 0%  82.7ms ± 0%    ~     (p=0.820 n=20+20)
      
      Change-Id: I0409eb170b8a26d9f4eb271f6292e5d39faf2d8b
      Reviewed-on: https://go-review.googlesource.com/19955Reviewed-by: default avatarRob Pike <r@golang.org>
      7da4cedd
    • Justin Nuß's avatar
      strconv: Avoid allocation in AppendQuote* · 9d73a6dc
      Justin Nuß authored
      The current implementations of the AppendQuote functions use quoteWith
      (through Quote) for quoting the given value and appends the returned
      string to the dst byte slice. quoteWith internally creates a byte slice
      on each call which gets converted to a string in Quote.
      
      This means the AppendQuote functions always allocates a new byte slice
      and a string only to append them to an existing byte slice. In the case
      of (Append)QuoteRune the string passed to quoteWith will also needs to
      be allocated from a rune first.
      
      Split quoteWith into two functions (quoteWith and appendQuotedWith) and
      replace the call to Quote inside AppendQuote with appendQuotedWith,
      which appends directly to the byte slice passed to AppendQuote and also
      avoids the []byte->string conversion.
      
      Also introduce the 2 functions quoteRuneWith and appendQuotedRuneWith
      that work the same way as quoteWith and appendQuotedWith, but take a
      single rune instead of a string, to avoid allocating a new string when
      appending a single rune, and use them in (Append)QuoteRune.
      
      Also update the ToASCII and ToGraphic variants to use the new functions.
      
      Benchmark results:
      
      benchmark                      old ns/op     new ns/op     delta
      BenchmarkQuote-8               428           503           +17.52%
      BenchmarkQuoteRune-8           148           105           -29.05%
      BenchmarkAppendQuote-8         435           307           -29.43%
      BenchmarkAppendQuoteRune-8     158           23.5          -85.13%
      
      benchmark                      old allocs     new allocs     delta
      BenchmarkQuote-8               3              3              +0.00%
      BenchmarkQuoteRune-8           3              2              -33.33%
      BenchmarkAppendQuote-8         3              0              -100.00%
      BenchmarkAppendQuoteRune-8     3              0              -100.00%
      
      benchmark                      old bytes     new bytes     delta
      BenchmarkQuote-8               144           144           +0.00%
      BenchmarkQuoteRune-8           16            16            +0.00%
      BenchmarkAppendQuote-8         144           0             -100.00%
      BenchmarkAppendQuoteRune-8     16            0             -100.00%
      
      Change-Id: I77c148d5c7242f1b0edbbeeea184878abb51a522
      Reviewed-on: https://go-review.googlesource.com/18962
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      9d73a6dc
    • Mikio Hara's avatar
      crypto/tls: don't send IPv6 literals and absolute FQDNs as SNI values · f3f920ff
      Mikio Hara authored
      This is a followup change to #13111 for filtering out IPv6 literals and
      absolute FQDNs from being as the SNI values.
      
      Updates #13111.
      Fixes #14404.
      
      Change-Id: I09ab8d2a9153d9a92147e57ca141f2e97ddcef6e
      Reviewed-on: https://go-review.googlesource.com/19704Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      f3f920ff
    • Martin Möhrmann's avatar
      fmt: change padding functions to avoid package init · abcad1e5
      Martin Möhrmann authored
      Move the decision if zero padding is allowed to doPrintf
      where the other formatting decisions are made.
      
      Removes some dead code for negative f.wid that was never used
      due to f.wid always being positive and f.minus deciding if left
      or right padding should be used.
      
      New padding code writes directly into the buffer and is as fast
      as the old version but avoids the cost of needing package init.
      
      name              old time/op  new time/op  delta
      SprintfPadding-2   246ns ± 5%   245ns ± 4%   ~     (p=0.345 n=50+47)
      
      Change-Id: I7dfddbac8e328f4ef0cdee8fafc0d06c784b2711
      Reviewed-on: https://go-review.googlesource.com/19957
      Run-TryBot: Rob Pike <r@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRob Pike <r@golang.org>
      abcad1e5
    • Matthew Dempsky's avatar
      cmd/compile: remove unneeded test binary · 8b96bc68
      Matthew Dempsky authored
      Accidentally added in https://golang.org/cl/19968.
      
      Change-Id: Id70917c4d1f69db149688d797c90a19557d16f72
      Reviewed-on: https://go-review.googlesource.com/19985Reviewed-by: default avatarMinux Ma <minux@golang.org>
      8b96bc68
    • David du Colombier's avatar
      debug/gosym: fix TestPCLine on Plan 9 · ccf39a23
      David du Colombier authored
      Plan 9 doesn't define main, so the INITENTRY
      symbol remains with the SXREF type, which leads
      Entryvalue to fail on "entry not text: main".
      
      Fixes #14536.
      
      Change-Id: Id9b7d61e5c2202aba3ec9cd52f5b56e0a38f7c47
      Reviewed-on: https://go-review.googlesource.com/19973
      Run-TryBot: David du Colombier <0intro@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      ccf39a23
    • Brad Fitzpatrick's avatar
      doc: go1.7.txt updates · 31f2ed2c
      Brad Fitzpatrick authored
      Change-Id: I6ac3d11ee8896f636235fe10c2556f93584019b5
      Reviewed-on: https://go-review.googlesource.com/19984Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      31f2ed2c
    • Matthew Dempsky's avatar
      cmd/compile: simplify lexinit and lexfini · 52f099c4
      Matthew Dempsky authored
      Split the syms array into separate basicTypes and builtinFuncs arrays.
      
      Also, in lexfini, instead of duplicating the code from lexinit to
      declare the builtin identifiers in the user package, just import them
      from builtinpkg like how importdot works.
      
      Change-Id: Ic3b3b454627a46f7bd5f290d0e31443e659d431f
      Reviewed-on: https://go-review.googlesource.com/19936
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      52f099c4
    • Ian Lance Taylor's avatar
      cmd/compile: change Func.{Enter,Exit} from NodeList to slice · 188e3d25
      Ian Lance Taylor authored
      Introduces a new types Nodes that can be used to replace NodeList.
      
      Update #14473.
      
      Change-Id: Id77c5dcae0cbeb898ba12dd46bd400aad408871c
      Reviewed-on: https://go-review.googlesource.com/19969Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      188e3d25
  3. 26 Feb, 2016 22 commits