1. 13 Sep, 2018 8 commits
    • erifan01's avatar
      runtime: skip TestGcSys on arm64 · 0ef42f4d
      erifan01 authored
      This failure occurs randomly on arm64.
      
      13:10:32 --- FAIL: TestGcSys (0.06s)
      13:10:32 gc_test.go:30: expected "OK\n", but got "using too much memory: 71401472 bytes\n"
      13:10:32 FAIL
      
      Updates #27636
      
      Change-Id: Ifd4cfce167d8054dc6f037bd34368d63c7f68ed4
      Reviewed-on: https://go-review.googlesource.com/135155
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      0ef42f4d
    • Ian Lance Taylor's avatar
      path/filepath: rewrite walkSymlinks · 7d27e87d
      Ian Lance Taylor authored
      Rather than try to work around Clean and Join on intermediate steps,
      which can remove ".." components unexpectedly, just do everything in
      walkSymlinks. Use a single loop over path components.
      
      Fixes #23444
      
      Change-Id: I4f15e50d0df32349cc4fd55e3d224ec9ab064379
      Reviewed-on: https://go-review.googlesource.com/121676
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
      7d27e87d
    • Alan Donovan's avatar
      regexp: fix incorrect name in Match doc comment · 8c610aa6
      Alan Donovan authored
      Change-Id: I628aad9a3abe9cc0c3233f476960e53bd291eca9
      Reviewed-on: https://go-review.googlesource.com/135235Reviewed-by: 's avatarRalph Corderoy <ralph@inputplus.co.uk>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      8c610aa6
    • erifan01's avatar
      strings, bytes: optimize function Index · 691f5c34
      erifan01 authored
      This change compares the first two characters instead of the first one,
      and if they match, the entire string is compared. Comparing the first two
      characters helps to filter out the case where the first character matches
      but the subsequent characters do not match, thereby improving the substring
      search speed in this case.
      
      Benchmarks with no effect or minimal impact (less than 5%) is not listed,
      the following are improved benchmarks:
      On arm64:
      strings:
      IndexPeriodic/IndexPeriodic16-8   172890.00ns +- 2%   124156.20ns +- 0%  -28.19%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic32-8    78092.80ns +- 0%    65138.60ns +- 0%  -16.59%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic64-8    42322.20ns +- 0%    34661.60ns +- 0%  -18.10%  (p=0.008 n=5+5)
      bytes:
      IndexPeriodic/IndexPeriodic16-8     183468.20ns +- 6%     123759.00ns +- 0%  -32.54%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic32-8      84776.40ns +- 0%      63907.80ns +- 0%  -24.62%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic64-8      45835.60ns +- 0%      34194.20ns +- 0%  -25.40%  (p=0.008 n=5+5)
      
      On amd64:
      strings:
      IndexPeriodic/IndexPeriodic8-16    219499.00ns +- 0%   178123.40ns +- 0%  -18.85%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic16-16   109760.20ns +- 0%    88957.80ns +- 0%  -18.95%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic32-16    54943.00ns +- 0%    44573.80ns +- 0%  -18.87%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic64-16    29804.80ns +- 0%    24417.80ns +- 0%  -18.07%  (p=0.008 n=5+5)
      bytes:
      IndexPeriodic/IndexPeriodic8-16     226592.60ns +- 0%    181183.20ns +- 0%  -20.04%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic16-16    111432.60ns +- 0%     90634.60ns +- 0%  -18.66%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic32-16     55640.60ns +- 0%     45433.00ns +- 0%  -18.35%  (p=0.008 n=5+5)
      IndexPeriodic/IndexPeriodic64-16     30833.00ns +- 0%     24784.20ns +- 0%  -19.62%  (p=0.008 n=5+5)
      
      Change-Id: I2d9e7e138d29e960d20a203eb74dc2ec976a9d71
      Reviewed-on: https://go-review.googlesource.com/131177
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      691f5c34
    • Robert Griesemer's avatar
      cmd/vet: avoid internal error for implicitly declared type switch vars · 77e503a3
      Robert Griesemer authored
      For type switches using a short variable declaration of the form
      
         switch t := x.(type) {
         case T1:
         ...
      
      go/types doesn't declare the symbolic variable (t in this example)
      with the switch; thus such variables are not found in types.Info.Defs.
      
      Instead they are implicitly declared with each type switch case,
      and can be found in types.Info.Implicits.
      
      Adjust the shadowing code accordingly.
      
      Added a test case to verify that the issue is fixed, and a test
      case verifying that the shadowing code now considers implicitly
      declared variables introduces in type switch cases.
      
      While at it, also fixed the (internal) error reporting to provide
      more accurate information.
      
      Fixe #26725.
      
      Change-Id: If408ed9e692bf47c640f81de8f46bf5eb43415b0
      Reviewed-on: https://go-review.googlesource.com/135117
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
      77e503a3
    • erifan01's avatar
      cmd/compile: intrinsify math.RoundToEven and math.Abs on arm64 · 8149db4f
      erifan01 authored
      math.RoundToEven can be done by one arm64 instruction FRINTND, intrinsify it to improve performance.
      The current pure Go implementation of the function Abs is translated into five instructions on arm64:
      str, ldr, and, str, ldr. The intrinsic implementation requires only one instruction, so in terms of
      performance, intrinsify it is worthwhile.
      
      Benchmarks:
      name           old time/op  new time/op  delta
      Abs-8          3.50ns ± 0%  1.50ns ± 0%  -57.14%  (p=0.000 n=10+10)
      RoundToEven-8  9.26ns ± 0%  1.50ns ± 0%  -83.80%  (p=0.000 n=10+10)
      
      Change-Id: I9456b26ab282b544dfac0154fc86f17aed96ac3d
      Reviewed-on: https://go-review.googlesource.com/116535Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      8149db4f
    • Tobias Klauser's avatar
      os: add ModeCharDevice to ModeType · a2a3dd00
      Tobias Klauser authored
      When masking FileInfo.Mode() from a character device with the ModeType
      mask, ModeCharDevice cannot be recovered.
      
      ModeCharDevice was added https://golang.org/cl/5531052, but nothing
      indicates why it was omitted from ModeType. Add it now.
      
      Fixes #27640
      
      Change-Id: I52f56108b88b1b0a5bc6085c66c3c67e10600619
      Reviewed-on: https://go-review.googlesource.com/135075
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      a2a3dd00
    • Emmanuel T Odeke's avatar
      runtime: regression test for semasleep indefinite hang · 1b937445
      Emmanuel T Odeke authored
      A regression test in which: for a program that invokes semasleep,
      we send non-terminal signals such as SIGIO.
      Since the signal wakes up pthread_cond_timedwait_relative_np,
      after CL 133655, we should only re-spin for the amount of
      time left, instead of re-spinning with the original duration
      which would cause an indefinite spin.
      
      Updates #27520
      
      Change-Id: I744a6d04cf8923bc4e13649446aff5e42b7de5d8
      Reviewed-on: https://go-review.googlesource.com/135015
      Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      1b937445
  2. 12 Sep, 2018 10 commits
    • erifan01's avatar
      internal/bytealg: optimize Equal on arm64 · de28555c
      erifan01 authored
      Currently the 16-byte loop chunk16_loop is implemented with NEON instructions LD1, VMOV and VCMEQ.
      Using scalar instructions LDP and CMP to achieve this loop can reduce the number of clock cycles.
      For cases where the length of strings are between 4 to 15 bytes, loading the last 8 or 4 bytes at
      a time to reduce the number of comparisons.
      
      Benchmarks:
      name                 old time/op    new time/op    delta
      Equal/0-8              5.51ns ± 0%    5.84ns ±14%     ~     (p=0.246 n=7+8)
      Equal/1-8              10.5ns ± 0%    10.5ns ± 0%     ~     (all equal)
      Equal/6-8              14.0ns ± 0%    12.5ns ± 0%  -10.71%  (p=0.000 n=8+8)
      Equal/9-8              13.5ns ± 0%    12.5ns ± 0%   -7.41%  (p=0.000 n=8+8)
      Equal/15-8             15.5ns ± 0%    12.5ns ± 0%  -19.35%  (p=0.000 n=8+8)
      Equal/16-8             14.0ns ± 0%    13.0ns ± 0%   -7.14%  (p=0.000 n=8+8)
      Equal/20-8             16.5ns ± 0%    16.0ns ± 0%   -3.03%  (p=0.000 n=8+8)
      Equal/32-8             16.5ns ± 0%    15.3ns ± 0%   -7.27%  (p=0.000 n=8+8)
      Equal/4K-8              552ns ± 0%     553ns ± 0%     ~     (p=0.315 n=8+8)
      Equal/4M-8             1.13ms ±23%    1.20ms ±27%     ~     (p=0.442 n=8+8)
      Equal/64M-8            32.9ms ± 0%    32.6ms ± 0%   -1.15%  (p=0.000 n=8+8)
      CompareBytesEqual-8    12.0ns ± 0%    12.0ns ± 0%     ~     (all equal)
      
      Change-Id: If317ecdcc98e31883d37fd7d42b113b548c5bd2a
      Reviewed-on: https://go-review.googlesource.com/112496Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      de28555c
    • Bryan C. Mills's avatar
      cmd/go: avoid type names in __debug__modinfo__ variable injected in package main · 21f3d581
      Bryan C. Mills authored
      If we use the name 'string' to refer to the built-in type, that name
      can be shadowed by a local declaration. Use a string constant instead,
      but keep the init function to populate it so that //go:linkname will
      still work properly.
      
      Fixes #27584.
      
      Change-Id: I850cad6663e566f70fd123107d2e4e742c93b450
      Reviewed-on: https://go-review.googlesource.com/134915Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      21f3d581
    • Tobias Klauser's avatar
      runtime: use functions from mem_bsd.go on Darwin · b07f60b9
      Tobias Klauser authored
      The implementations of the functions in mem_darwin.go is identical to
      the ones defined in mem_bsd.go for all other BSD-like GOOSes. Also use
      them on Darwin.
      
      Change-Id: Ie7c170c1a50666475e79599471081cd85f0837ad
      Reviewed-on: https://go-review.googlesource.com/134875
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      b07f60b9
    • Tobias Klauser's avatar
      cmd/dist: make raceDetectorSupported an exact copy of cmd/internal/sys.RaceDetectorSupported · c56dcd5f
      Tobias Klauser authored
      The comment states that cmd/internal/sys.RaceDetectorSupported is a copy,
      so make the two identical. No functional difference, since ppce64le is
      only supported on linux anyway.
      
      Change-Id: Id3e4d445fb700b9b3bb53bf15ea05b8911b4f95e
      Reviewed-on: https://go-review.googlesource.com/134595
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      c56dcd5f
    • Emmanuel T Odeke's avatar
      runtime: convert initial timediv quotient increments to bitsets · 178a609f
      Emmanuel T Odeke authored
      At the very beginning of timediv, inside a for loop,
      we reduce the base value by at most (1<<31)-1, while
      incrementing the quotient result by 1<<uint(bit).
      However, since the quotient value was 0 to begin with,
      we are essentially just doing bitsets.
      
      This change is in the hot path of various concurrency and
      scheduling operations that require sleeping, waiting
      on mutexes and futexes etc. On the following OSes:
      * Dragonfly
      * FreeBSD
      * Linux
      * NetBSD
      * OpenBSD
      * Plan9
      * Windows
      
      and paired with architectures that provide the BTS instruction, this
      change shaves off a couple of nanoseconds per invocation of timediv.
      
      Fixes #27529
      
      Change-Id: Ia2fea5022c1109e02d86d1f962a3b0bd70967aa6
      Reviewed-on: https://go-review.googlesource.com/134231
      Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      178a609f
    • Lynn Boger's avatar
      internal/bytealg: implement bytes.Count in asm for ppc64x · a0fad982
      Lynn Boger authored
      This adds an asm implementation for the Count function in ppc64x.
      The Go code that manipulates a byte at a time is especially
      inefficient on ppc64x, so an asm implementation is a significant
      improvement.
      
      bytes:
      name               old time/op   new time/op    delta
      CountSingle/10-8    23.1ns ± 0%    18.6ns ± 0%    -19.48%  (p=1.000 n=1+1)
      CountSingle/32-8    60.4ns ± 0%    19.0ns ± 0%    -68.54%  (p=1.000 n=1+1)
      CountSingle/4K-8    7.29µs ± 0%    0.45µs ± 0%    -93.80%  (p=1.000 n=1+1)
      CountSingle/4M-8    7.49ms ± 0%    0.45ms ± 0%    -93.97%  (p=1.000 n=1+1)
      CountSingle/64M-8    127ms ± 0%       9ms ± 0%    -92.53%  (p=1.000 n=1+1)
      
      html:
      name              old time/op  new time/op  delta
      Escape-8          57.5µs ± 0%  36.1µs ± 0%  -37.13%  (p=1.000 n=1+1)
      EscapeNone-8      20.0µs ± 0%   2.0µs ± 0%  -90.14%  (p=1.000 n=1+1)
      
      Change-Id: Iadbf422c0e9a37b47d2d95fb8c778420f3aabb58
      Reviewed-on: https://go-review.googlesource.com/131695
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMichael Munday <mike.munday@ibm.com>
      a0fad982
    • fanzha02's avatar
      cmd/internal/obj/arm64: add error report for invalid base register · e7f5f3ec
      fanzha02 authored
      The current assembler accepts the non-integer register as the base register,
      which should be an illegal combination.
      
      Add the test cases.
      
      Change-Id: Ia21596bbb5b1e212e34bd3a170748ae788860422
      Reviewed-on: https://go-review.googlesource.com/134575Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      e7f5f3ec
    • fanzha02's avatar
      test: fix the wrong test of math.Copysign(c, -1) for arm64 · d5377c20
      fanzha02 authored
      The CL 132915 added the wrong codegen test for math.Copysign(c, -1),
      it should test that AND is not emitted. This CL fixes this error.
      
      Change-Id: Ida1d3d54ebfc7f238abccbc1f70f914e1b5bfd91
      Reviewed-on: https://go-review.googlesource.com/134815Reviewed-by: 's avatarGiovanni Bajo <rasky@develer.com>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Giovanni Bajo <rasky@develer.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d5377c20
    • Daniel Martí's avatar
      encoding/json: use panics for phase errors · b2fcfc1a
      Daniel Martí authored
      Having these panic-like errors used to be ok, since they were used in
      the internal decoder state instead of passed around via return
      parameters.
      
      Recently, the decoder was rewritten to use explicit error returns
      instead. This error is a terrible fit for error returns; a handful of
      functions must return an error because of it, and their callers must
      check for an error that should never happen.
      
      This is precisely what panics are for, so use them. The test coverage of
      the package goes up from 91.3% to 91.6%, and performance is unaffected.
      We can also get rid of some unnecessary verbosity in the code.
      
      name           old time/op    new time/op    delta
      CodeDecoder-4    27.5ms ± 1%    27.5ms ± 1%   ~     (p=0.937 n=6+6)
      
      Change-Id: I01033b3f5b7c0cf0985082fa272754f96bf6353c
      Reviewed-on: https://go-review.googlesource.com/134835
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      b2fcfc1a
    • Daniel Martí's avatar
      encoding/json: more tests to cover decoding edge cases · dc368086
      Daniel Martí authored
      The overall coverage of the json package goes up from 90.8% to 91.3%.
      
      While at it, apply two minor code simplifications found while inspecting
      the HTML coverage report.
      
      Change-Id: I0fba968afeedc813b1385e4bde72d93b878854d7
      Reviewed-on: https://go-review.googlesource.com/134735
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      dc368086
  3. 11 Sep, 2018 7 commits
    • Ian Lance Taylor's avatar
      cmd/link: don't pass all linker args when testing flag · 023dbb18
      Ian Lance Taylor authored
      Some linker flags can actually be input files, which can cause
      misleading errors when doing the trial link, which can cause the
      linker to incorrectly decide that the flag is not supported, which can
      cause the link to fail.
      
      Fixes #27510
      Updates #27110
      Updates #27293
      
      Change-Id: I70c1e913cee3c813e7b267bf779bcff26d4d194a
      Reviewed-on: https://go-review.googlesource.com/134057
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarLynn Boger <laboger@linux.vnet.ibm.com>
      Reviewed-by: 's avatarDamien Neil <dneil@google.com>
      023dbb18
    • Bryan C. Mills's avatar
      cmd/go/testdata/script: fix typos in test comments · 1a1c45b3
      Bryan C. Mills authored
      Change-Id: I2a55cda76f1074b997349dfd6e001dc7277faade
      Reviewed-on: https://go-review.googlesource.com/134655Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      1a1c45b3
    • Brian Kessler's avatar
      math/bits: add extended precision Add, Sub, Mul, Div · 13de5e7f
      Brian Kessler authored
      Port math/big pure go versions of add-with-carry, subtract-with-borrow,
      full-width multiply, and full-width divide.
      
      Updates #24813
      
      Change-Id: Ifae5d2f6ee4237137c9dcba931f69c91b80a4b1c
      Reviewed-on: https://go-review.googlesource.com/123157Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      13de5e7f
    • Yury Smolsky's avatar
      cmd/compile: use yyerrorl(n.Pos, ...) in typecheckdef · ef7212e2
      Yury Smolsky authored
      n.Pos.IsKnown() is not needed because it is performed in setlineno.
      
      toolstash-check passed.
      
      Updates #19683.
      
      Change-Id: I34d6a0e6dc9970679d99e8f3424f289ebf1e86ba
      Reviewed-on: https://go-review.googlesource.com/114915
      Run-TryBot: Yury Smolsky <yury@smolsky.by>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      ef7212e2
    • Lynn Boger's avatar
      cmd/link,compress/zip,image/png: use binary.{Big,Little}Endian methods · aa4fc0e7
      Lynn Boger authored
      Use the binary.{Big,Little}Endian integer encoding methods rather than
      variations found in local implementations. The functions in
      the binary package have been tested to ensure they inline correctly and
      don't add unnecessary bounds checking.
      
      Change-Id: Ie10111ca6edb7c11e8e5e21c58a5748ae99b7f87
      Reviewed-on: https://go-review.googlesource.com/134375
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMichael Munday <mike.munday@ibm.com>
      aa4fc0e7
    • Ben Shi's avatar
      cmd/compile: optimize arm's bit operation · 9f241189
      Ben Shi authored
      BFC (Bit Field Clear) was introduced in ARMv7, which can simplify
      ANDconst and BICconst. And this CL implements that optimization.
      
      1. The total size of pkg/android_arm decreases about 3KB, excluding
      cmd/compile/.
      
      2. There is no regression in the go1 benchmark result, and some
      cases (FmtFprintfEmpty-4 and RegexpMatchMedium_32-4) even get
      slight improvement.
      
      name                     old time/op    new time/op    delta
      BinaryTree17-4              25.3s ± 1%     25.2s ± 1%    ~     (p=0.072 n=30+29)
      Fannkuch11-4                13.3s ± 0%     13.3s ± 0%  +0.13%  (p=0.000 n=30+26)
      FmtFprintfEmpty-4           407ns ± 0%     394ns ± 0%  -3.19%  (p=0.000 n=26+28)
      FmtFprintfString-4          664ns ± 0%     662ns ± 0%  -0.22%  (p=0.000 n=30+30)
      FmtFprintfInt-4             712ns ± 0%     706ns ± 0%  -0.79%  (p=0.000 n=30+30)
      FmtFprintfIntInt-4         1.06µs ± 0%    1.05µs ± 0%  -0.38%  (p=0.000 n=30+30)
      FmtFprintfPrefixedInt-4    1.16µs ± 0%    1.16µs ± 0%  -0.13%  (p=0.000 n=30+29)
      FmtFprintfFloat-4          2.24µs ± 0%    2.23µs ± 0%  -0.51%  (p=0.000 n=29+21)
      FmtManyArgs-4              4.09µs ± 0%    4.06µs ± 0%  -0.83%  (p=0.000 n=28+30)
      GobDecode-4                55.0ms ± 5%    55.4ms ± 5%    ~     (p=0.307 n=30+30)
      GobEncode-4                51.2ms ± 1%    51.9ms ± 1%  +1.23%  (p=0.000 n=29+30)
      Gzip-4                      2.64s ± 0%     2.60s ± 0%  -1.35%  (p=0.000 n=30+29)
      Gunzip-4                    309ms ± 0%     308ms ± 0%  -0.27%  (p=0.000 n=30+30)
      HTTPClientServer-4         1.03ms ± 5%    1.02ms ± 4%    ~     (p=0.117 n=30+29)
      JSONEncode-4                101ms ± 2%     101ms ± 2%    ~     (p=0.338 n=29+29)
      JSONDecode-4                383ms ± 2%     382ms ± 2%    ~     (p=0.751 n=26+30)
      Mandelbrot200-4            18.4ms ± 0%    18.4ms ± 0%  -0.10%  (p=0.000 n=29+29)
      GoParse-4                  22.6ms ± 0%    22.5ms ± 0%  -0.39%  (p=0.000 n=30+30)
      RegexpMatchEasy0_32-4       761ns ± 0%     750ns ± 0%  -1.47%  (p=0.000 n=26+29)
      RegexpMatchEasy0_1K-4      4.33µs ± 0%    4.34µs ± 0%  +0.27%  (p=0.000 n=25+28)
      RegexpMatchEasy1_32-4       809ns ± 0%     795ns ± 0%  -1.74%  (p=0.000 n=27+25)
      RegexpMatchEasy1_1K-4      5.54µs ± 0%    5.53µs ± 0%  -0.18%  (p=0.000 n=29+29)
      RegexpMatchMedium_32-4     1.11µs ± 0%    1.08µs ± 0%  -2.78%  (p=0.000 n=27+29)
      RegexpMatchMedium_1K-4      255µs ± 0%     255µs ± 0%  -0.02%  (p=0.029 n=30+30)
      RegexpMatchHard_32-4       14.7µs ± 0%    14.7µs ± 0%  -0.28%  (p=0.000 n=30+29)
      RegexpMatchHard_1K-4        439µs ± 0%     439µs ± 0%    ~     (p=0.907 n=23+27)
      Revcomp-4                  41.9ms ± 1%    41.9ms ± 1%    ~     (p=0.230 n=28+30)
      Template-4                  522ms ± 1%     528ms ± 1%  +1.25%  (p=0.000 n=30+30)
      TimeParse-4                3.34µs ± 0%    3.35µs ± 0%  +0.23%  (p=0.000 n=30+27)
      TimeFormat-4               6.06µs ± 0%    6.13µs ± 0%  +1.08%  (p=0.000 n=29+29)
      [Geo mean]                  384µs          382µs       -0.37%
      
      name                     old speed      new speed      delta
      GobDecode-4              14.0MB/s ± 5%  13.9MB/s ± 5%    ~     (p=0.308 n=30+30)
      GobEncode-4              15.0MB/s ± 1%  14.8MB/s ± 1%  -1.22%  (p=0.000 n=29+30)
      Gzip-4                   7.36MB/s ± 0%  7.46MB/s ± 0%  +1.35%  (p=0.000 n=30+30)
      Gunzip-4                 62.8MB/s ± 0%  63.0MB/s ± 0%  +0.27%  (p=0.000 n=30+30)
      JSONEncode-4             19.2MB/s ± 2%  19.2MB/s ± 2%    ~     (p=0.312 n=29+29)
      JSONDecode-4             5.05MB/s ± 3%  5.08MB/s ± 2%    ~     (p=0.356 n=29+30)
      GoParse-4                2.56MB/s ± 0%  2.57MB/s ± 0%  +0.39%  (p=0.000 n=23+27)
      RegexpMatchEasy0_32-4    42.0MB/s ± 0%  42.6MB/s ± 0%  +1.50%  (p=0.000 n=26+28)
      RegexpMatchEasy0_1K-4     236MB/s ± 0%   236MB/s ± 0%  -0.27%  (p=0.000 n=25+28)
      RegexpMatchEasy1_32-4    39.6MB/s ± 0%  40.2MB/s ± 0%  +1.73%  (p=0.000 n=27+27)
      RegexpMatchEasy1_1K-4     185MB/s ± 0%   185MB/s ± 0%  +0.18%  (p=0.000 n=29+29)
      RegexpMatchMedium_32-4    900kB/s ± 0%   920kB/s ± 0%  +2.22%  (p=0.000 n=29+29)
      RegexpMatchMedium_1K-4   4.02MB/s ± 0%  4.02MB/s ± 0%  +0.07%  (p=0.004 n=30+27)
      RegexpMatchHard_32-4     2.17MB/s ± 0%  2.18MB/s ± 0%  +0.46%  (p=0.000 n=30+26)
      RegexpMatchHard_1K-4     2.33MB/s ± 0%  2.33MB/s ± 0%    ~     (all equal)
      Revcomp-4                60.6MB/s ± 1%  60.7MB/s ± 1%    ~     (p=0.207 n=28+30)
      Template-4               3.72MB/s ± 1%  3.67MB/s ± 1%  -1.23%  (p=0.000 n=30+30)
      [Geo mean]               12.9MB/s       12.9MB/s       +0.29%
      
      Change-Id: I07f497f8bb476c950dc555491d00c9066fb64a4e
      Reviewed-on: https://go-review.googlesource.com/134232
      Run-TryBot: Ben Shi <powerman1st@163.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      9f241189
    • Ian Davis's avatar
      net/url: remove an allocation for short strings in escape · 95a11c73
      Ian Davis authored
      Use a 64 byte array to avoid an allocation on the assumption that
      most url escaping is performed on short strings. Also adds a fast
      path for escaping strings whose only replacements are spaces which
      is common in query components.
      
      Adds benchmarks for QueryEscape, PathEscape, QueryUnescape and
      PathUnescape but no optimizations are include for the unescape functions
      so I don't include those benchmark results here.
      
      Reduces allocations by 10% in the existing String benchmark with a
      modest performance increase.
      
      name               old time/op    new time/op    delta
      QueryEscape/#00-8    64.6ns ± 1%    43.8ns ± 0%  -32.14%  (p=0.000 n=9+9)
      QueryEscape/#01-8     276ns ± 3%     249ns ± 0%   -9.62%  (p=0.000 n=10+7)
      QueryEscape/#02-8     176ns ± 2%     155ns ± 3%  -12.21%  (p=0.000 n=10+10)
      QueryEscape/#03-8     388ns ± 1%     362ns ± 0%   -6.55%  (p=0.000 n=10+8)
      QueryEscape/#04-8    2.32µs ± 2%    2.27µs ± 2%   -2.26%  (p=0.001 n=10+10)
      PathEscape/#00-8     78.0ns ± 3%    63.4ns ± 1%  -18.69%  (p=0.000 n=10+10)
      PathEscape/#01-8      276ns ± 2%     260ns ± 0%   -6.01%  (p=0.000 n=10+10)
      PathEscape/#02-8      175ns ± 0%     153ns ± 0%  -12.53%  (p=0.000 n=8+10)
      PathEscape/#03-8      389ns ± 2%     361ns ± 0%   -7.21%  (p=0.000 n=10+9)
      PathEscape/#04-8     2.30µs ± 2%    2.27µs ± 1%   -1.33%  (p=0.001 n=9+10)
      String-8             3.56µs ± 4%    3.42µs ± 7%   -4.00%  (p=0.003 n=10+10)
      
      name               old alloc/op   new alloc/op   delta
      QueryEscape/#00-8     16.0B ± 0%      8.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#01-8      128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#02-8     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#03-8      128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#04-8      832B ± 0%      832B ± 0%     ~     (all equal)
      PathEscape/#00-8      32.0B ± 0%     16.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#01-8       128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#02-8      64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#03-8       128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#04-8       704B ± 0%      704B ± 0%     ~     (all equal)
      String-8             1.84kB ± 0%    1.66kB ± 0%   -9.57%  (p=0.000 n=10+10)
      
      name               old allocs/op  new allocs/op  delta
      QueryEscape/#00-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#01-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#02-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#03-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      QueryEscape/#04-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
      PathEscape/#00-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#01-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#02-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#03-8       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      PathEscape/#04-8       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
      String-8               69.0 ± 0%      61.0 ± 0%  -11.59%  (p=0.000 n=10+10)
      
      Updates #17860
      
      Change-Id: I45c5e9d40b242f874c61f6ccc73bf94c494bb868
      Reviewed-on: https://go-review.googlesource.com/134296
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      95a11c73
  4. 10 Sep, 2018 2 commits
  5. 09 Sep, 2018 3 commits
  6. 08 Sep, 2018 3 commits
  7. 07 Sep, 2018 7 commits