1. 15 Sep, 2017 8 commits
  2. 14 Sep, 2017 8 commits
  3. 13 Sep, 2017 14 commits
  4. 12 Sep, 2017 10 commits
    • Ilya Tocar's avatar
      unicode: speed-up is16/is32 · bc8bb5b2
      Ilya Tocar authored
      Avoid division in common case. There are 5438 ranges in unicode/tables.go
      4110 of them have stride 1.
      Stride 1 case got significantly faster. Other stride is a bit slower.
      Measured by
      
      import (
      	"testing"
      	"unicode"
      )
      
      func BenchmarkDiv1(b *testing.B) {
      	rtb := &unicode.RangeTable{
      		R16: []unicode.Range16{
      			{0xa800, 0xdfff, 1}, // or 3
      		},
      	}
      	for i := 0; i < b.N; i++ {
      		unicode.Is(rtb, rune(0xc700))
      	}
      }
      
      Div1-6  15.6ns ± 1%   9.9ns ± 1%  -36.54%  (p=0.000 n=10+10)
      Div3-6  15.5ns ± 1%  16.1ns ± 1%   +3.67%  (p=0.000 n=10+10)
      
      Helps a bit with xml parsing from issue #21823
      
      XMLsax-6   30.9s ± 0%   29.6s ± 0%  -4.15%  (p=0.000 n=10+9)
      
      Change-Id: Ibac1a91d7b9474d0c134b0add83e56caa62daa20
      Reviewed-on: https://go-review.googlesource.com/63390
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      bc8bb5b2
    • Ilya Tocar's avatar
      unicode/utf8: make FullRune inlinable · 6237ab2c
      Ilya Tocar authored
      This has same readability and allows to inline FullRune for massive
      performance gain:
      
      FullASCIIRune-6                      4.36ns ± 0%  1.25ns ± 0%  -71.33%  (p=0.000 n=8+10)
      FullJapaneseRune-6                   4.70ns ± 0%  1.42ns ± 1%  -69.68%  (p=0.000 n=9+10)
      
      Change-Id: I95edd6292417a28aac244e40afb713596a087d93
      Reviewed-on: https://go-review.googlesource.com/63332
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
      6237ab2c
    • Daniel Martí's avatar
      cmd/compile: remove redundant switch label · 6d33df1d
      Daniel Martí authored
      This label was added automatically by grind to remove gotos. As of
      today, it's completely useless, as none of its uses need a label to
      begin with.
      
      While at it, remove all the redundant breaks too. Leave those that are
      the single statement in a case clause body, as that's the style used
      throughout std and cmd to clarify when cases are empty.
      
      Change-Id: I3e20068b66b759614e903beab1cc9b2709b31063
      Reviewed-on: https://go-review.googlesource.com/62950
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      6d33df1d
    • tbunyk's avatar
      encoding/json: update documentation for MarshalIndent · b86fae04
      tbunyk authored
      Make arguments semantics clear without the need to look for
      json.Indent documentation.
      
      Change-Id: If9adfe9f477a30d426ae83790b0f2578c0a809b7
      Reviewed-on: https://go-review.googlesource.com/61670
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      b86fae04
    • Ilya Tocar's avatar
      crypto: simplify amd64 asm for sha{1,256,512} a bit · 80b2ae58
      Ilya Tocar authored
      Use constants directly, instead of loading address to e. g. AX
      and using (AX). Shouldn't affect performance, but makes code a bit
      nicer.
      
      Change-Id: Ifa138e54d3d2b2f4ad71e4ef4b9368ea79eb30f4
      Reviewed-on: https://go-review.googlesource.com/62010Reviewed-by: default avatarAdam Langley <agl@golang.org>
      80b2ae58
    • Tobias Klauser's avatar
      doc: unify colons and spacing in diagnostics guide · 1a706bbf
      Tobias Klauser authored
      Unify colons (outside of <strong></strong>) and add a missing space in
      the list of groups of diagnostics solutions.
      
      Change-Id: Icbcd94427d4905dd88c4ea82aaa5dbf064c00990
      Reviewed-on: https://go-review.googlesource.com/63111Reviewed-by: default avatarJBD <jbd@google.com>
      1a706bbf
    • Aliaksandr Valialkin's avatar
      runtime: optimize siftupTimer and siftdownTimer a bit · 6a7c63a0
      Aliaksandr Valialkin authored
      Write the moving timer only once, since it is overwritten
      by swapped timers on all the iterations except the last one.
      
      Additionally, explicitly pass timers heap into siftupTimer
      and siftdownTimer in order to make the code more clear.
      
      Relevant benchmark results on linux/amd64:
      
      Stop                      700µs ± 7%   608µs ± 1%  -13.13%  (p=0.000 n=10+10)
      Stop-2                    440µs ± 4%   376µs ± 4%  -14.48%  (p=0.000 n=10+10)
      Stop-4                    339µs ± 2%   330µs ± 3%   -2.66%  (p=0.015 n=10+10)
      SimultaneousAfterFunc     702µs ± 9%   709µs ± 1%     ~     (p=0.436 n=9+9)
      SimultaneousAfterFunc-2   573µs ± 2%   546µs ± 2%   -4.71%  (p=0.000 n=10+10)
      SimultaneousAfterFunc-4   387µs ± 1%   368µs ± 1%   -4.89%  (p=0.000 n=8+10)
      StartStop                 268µs ± 0%   270µs ± 0%   +0.91%  (p=0.000 n=9+9)
      StartStop-2               155µs ± 6%   145µs ± 6%   -6.70%  (p=0.000 n=10+10)
      StartStop-4               125µs ± 1%   124µs ± 1%     ~     (p=0.065 n=10+9)
      
      Change-Id: I3685835b5e3e82844e2e5e73ee03a1e22100bf0e
      Reviewed-on: https://go-review.googlesource.com/63110Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      6a7c63a0
    • Michael Matloob's avatar
      runtime: in cpuProfile.addExtra, set p.lostExtra to 0 after flush · 96b1eff0
      Michael Matloob authored
      After the number of lost extra events are written to the the cpuprof log,
      the number of lost extra events should be set to zero, or else, the next
      time time addExtra is logged, lostExtra will be overcounted. This change
      resets lostExtra after its value is written to the log.
      
      Fixes #21836
      
      Change-Id: I8a6ac9c61e579e7a5ca7bdb0f3463f8ae8b9f863
      Reviewed-on: https://go-review.googlesource.com/63270Reviewed-by: default avatarAustin Clements <austin@google.com>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      96b1eff0
    • Aliaksandr Valialkin's avatar
      runtime: improve timers scalability on multi-CPU systems · 76f4fd8a
      Aliaksandr Valialkin authored
      Use per-P timers, so each P may work with its own timers.
      
      This CL improves performance on multi-CPU systems
      in the following cases:
      
      - When serving high number of concurrent connections
        with read/write deadlines set (for instance, highly loaded
        net/http server).
      
      - When using high number of concurrent timers. These timers
        may be implicitly created via context.WithDeadline
        or context.WithTimeout.
      
      Production servers should usually set timeout on connections
      and external requests in order to prevent from resource leakage.
      See https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
      
      Below are relevant benchmark results for various GOMAXPROCS values
      on linux/amd64:
      
      context package:
      
      name                                     old time/op  new time/op  delta
      WithTimeout/concurrency=40      4.92µs ± 0%  5.17µs ± 1%  +5.07%  (p=0.000 n=9+9)
      WithTimeout/concurrency=4000    6.03µs ± 1%  6.49µs ± 0%  +7.63%  (p=0.000 n=8+10)
      WithTimeout/concurrency=400000  8.58µs ± 7%  9.02µs ± 4%  +5.02%  (p=0.019 n=10+10)
      
      name                                     old time/op  new time/op  delta
      WithTimeout/concurrency=40-2      3.70µs ± 1%  2.78µs ± 4%  -24.90%  (p=0.000 n=8+9)
      WithTimeout/concurrency=4000-2    4.49µs ± 4%  3.67µs ± 5%  -18.26%  (p=0.000 n=10+10)
      WithTimeout/concurrency=400000-2  6.16µs ±10%  5.15µs ±13%  -16.30%  (p=0.000 n=10+10)
      
      name                                     old time/op  new time/op  delta
      WithTimeout/concurrency=40-4      3.58µs ± 1%  2.64µs ± 2%  -26.13%  (p=0.000 n=9+10)
      WithTimeout/concurrency=4000-4    4.17µs ± 0%  3.32µs ± 1%  -20.36%  (p=0.000 n=10+10)
      WithTimeout/concurrency=400000-4  5.57µs ± 9%  4.83µs ±10%  -13.27%  (p=0.001 n=10+10)
      
      time package:
      
      name                     old time/op  new time/op  delta
      AfterFunc                6.15ms ± 3%  6.07ms ± 2%     ~     (p=0.133 n=10+9)
      AfterFunc-2              3.43ms ± 1%  3.56ms ± 1%   +3.91%  (p=0.000 n=10+9)
      AfterFunc-4              5.04ms ± 2%  2.36ms ± 0%  -53.20%  (p=0.000 n=10+9)
      After                    6.54ms ± 2%  6.49ms ± 3%     ~     (p=0.393 n=10+10)
      After-2                  3.68ms ± 1%  3.87ms ± 0%   +5.14%  (p=0.000 n=9+9)
      After-4                  6.66ms ± 1%  2.87ms ± 1%  -56.89%  (p=0.000 n=10+10)
      Stop                      698µs ± 2%   689µs ± 1%   -1.26%  (p=0.011 n=10+10)
      Stop-2                    729µs ± 2%   434µs ± 3%  -40.49%  (p=0.000 n=10+10)
      Stop-4                    837µs ± 3%   333µs ± 2%  -60.20%  (p=0.000 n=10+10)
      SimultaneousAfterFunc     694µs ± 1%   692µs ± 7%     ~     (p=0.481 n=10+10)
      SimultaneousAfterFunc-2   714µs ± 3%   569µs ± 2%  -20.33%  (p=0.000 n=10+10)
      SimultaneousAfterFunc-4   782µs ± 2%   386µs ± 2%  -50.67%  (p=0.000 n=10+10)
      StartStop                 267µs ± 3%   274µs ± 0%   +2.64%  (p=0.000 n=8+9)
      StartStop-2               238µs ± 2%   140µs ± 3%  -40.95%  (p=0.000 n=10+8)
      StartStop-4               320µs ± 1%   125µs ± 1%  -61.02%  (p=0.000 n=9+9)
      Reset                    75.0µs ± 1%  77.5µs ± 2%   +3.38%  (p=0.000 n=10+10)
      Reset-2                   150µs ± 2%    40µs ± 5%  -73.09%  (p=0.000 n=10+9)
      Reset-4                   226µs ± 1%    33µs ± 1%  -85.42%  (p=0.000 n=10+10)
      Sleep                     857µs ± 6%   878µs ± 9%     ~     (p=0.079 n=10+9)
      Sleep-2                   617µs ± 4%   585µs ± 2%   -5.21%  (p=0.000 n=10+10)
      Sleep-4                   689µs ± 3%   465µs ± 4%  -32.53%  (p=0.000 n=10+10)
      Ticker                   55.9ms ± 2%  55.9ms ± 2%     ~     (p=0.971 n=10+10)
      Ticker-2                 28.7ms ± 2%  28.1ms ± 1%   -2.06%  (p=0.000 n=10+10)
      Ticker-4                 14.6ms ± 0%  13.6ms ± 1%   -6.80%  (p=0.000 n=9+10)
      
      Fixes #15133
      
      Change-Id: I6f4b09d2db8c5bec93146db6501b44dbfe5c0ac4
      Reviewed-on: https://go-review.googlesource.com/34784Reviewed-by: default avatarAustin Clements <austin@google.com>
      76f4fd8a
    • Daniel Martí's avatar
      go/*: use sort.Slice to simplify some code · 7377d0c7
      Daniel Martí authored
      Skip the ones that have multiple uses for now. Also had to rename the
      importComment variable as it shadowed the top-level func by the same
      name.
      
      Change-Id: I796285aa7b4fdf2c39e652666390427d37b063ee
      Reviewed-on: https://go-review.googlesource.com/63150
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      7377d0c7