1. 14 May, 2015 1 commit
    • Brad Fitzpatrick's avatar
      net/http: flush request body chunks in Transport · e5febf95
      Brad Fitzpatrick authored
      The Transport's writer to the remote server is wrapped in a
      bufio.Writer to suppress many small writes while writing headers and
      trailers. However, when writing the request body, the buffering may get
      in the way if the request body is arriving slowly.
      
      Because the io.Copy from the Request.Body to the writer is already
      buffered, the outer bufio.Writer is unnecessary and prevents small
      Request.Body.Reads from going to the server right away. (and the
      io.Reader contract does say to return when you've got something,
      instead of blocking waiting for more). After the body is finished, the
      Transport's bufio.Writer is still used for any trailers following.
      
      A previous attempted fix for this made the chunk writer always flush
      if the underlying type was a bufio.Writer, but that is not quite
      correct. This CL instead makes it opt-in by using a private sentinel
      type (wrapping a *bufio.Writer) to the chunk writer that requests
      Flushes after each chunk body (the chunk header & chunk body are still
      buffered together into one write).
      
      Fixes #6574
      
      Change-Id: Icefcdf17130c9e285c80b69af295bfd3e72c3a70
      Reviewed-on: https://go-review.googlesource.com/10021Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      e5febf95
  2. 13 May, 2015 15 commits
    • Brad Fitzpatrick's avatar
      cmd/internal/obj: validate GOARM environment variable's value before use · 5c7f9442
      Brad Fitzpatrick authored
      I was previously setting GOARM=arm5 (due to confusion with previously
      seeing buildall.sh's temporary of "arm5" as a GOARCH and
      misremembernig), but GOARM=arm5 was acting like GOARM=5 only on
      accident. See https://go-review.googlesource.com/#/c/10023/
      
      Instead, fail if GOARM is not a known value.
      
      Change-Id: I9ba4fd7268df233d40b09f0431f37cd85a049847
      Reviewed-on: https://go-review.googlesource.com/10024Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      5c7f9442
    • Robert Griesemer's avatar
      text/scanner: avoid further reads after EOF · fd5b8aa7
      Robert Griesemer authored
      Fixes #10735.
      
      Change-Id: I5c6e424653657c89da176136ac56597c7565abe5
      Reviewed-on: https://go-review.googlesource.com/10039Reviewed-by: 's avatarRob Pike <r@golang.org>
      fd5b8aa7
    • Brad Fitzpatrick's avatar
      math/rand: shorten Float32 test for GOARM=5 · f8fbcefa
      Brad Fitzpatrick authored
      Fixes #10749
      
      Change-Id: I9d5f6f179fd117b0c358d7c8042daf5985b645c0
      Reviewed-on: https://go-review.googlesource.com/10022Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      f8fbcefa
    • Mikio Hara's avatar
      doc: mention net.SocketConn, net.SocketPacketConn in go1.5.txt · f6d10094
      Mikio Hara authored
      Change-Id: I6bda19877ae5148ad349cfb8929f1103740422bb
      Reviewed-on: https://go-review.googlesource.com/10005Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      f6d10094
    • Mikio Hara's avatar
      net/internal/socktest: fix data race · 645e77ef
      Mikio Hara authored
      Fixes #10796.
      
      Change-Id: Ifcd2e771c64114e210fbfc5efaaceb53c534f745
      Reviewed-on: https://go-review.googlesource.com/10007Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      645e77ef
    • Hyang-Ah (Hana) Kim's avatar
      misc/cgo/testcshared: remove use of 'env'. · 647026a1
      Hyang-Ah (Hana) Kim authored
      'env' command is not available on some android devices.
      
      Change-Id: I68b1152ef7ea248c8e80c7f71e97da76e3ec6394
      Reviewed-on: https://go-review.googlesource.com/9999Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      647026a1
    • Rob Pike's avatar
      cmd/doc: print BUGs after package docs · 1e26df40
      Rob Pike authored
      Was otherwise absent unless bound to an exported symbol,
      as in the BUG with strings.Title.
      
      Fixes #10781.
      
      Change-Id: I1543137073a9dee9e546bc9d648ca54fc9632dde
      Reviewed-on: https://go-review.googlesource.com/9899Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      1e26df40
    • Brad Fitzpatrick's avatar
      runtime: add check for malloc in a signal handler · 6f2c0f15
      Brad Fitzpatrick authored
      Change-Id: Ic8ebbe81eb788626c01bfab238d54236e6e5ef2b
      Reviewed-on: https://go-review.googlesource.com/9964
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      6f2c0f15
    • Russ Cox's avatar
      cmd/internal/gc: optimize slice + write barrier · d4472799
      Russ Cox authored
      The code generated for a slice x[i:j] or x[i:j:k] computes the entire
      new slice (base, len, cap) and then uses it as the evaluation of the
      slice expression.
      
      If the slice is part of an update x = x[i:j] or x = x[i:j:k], there are
      opportunities to avoid computing some of these fields.
      
      For x = x[0:i], we know that only the len is changing;
      base can be ignored completely, and cap can be left unmodified.
      
      For x = x[0:i:j], we know that only len and cap are changing;
      base can be ignored completely.
      
      For x = x[i:i], we know that the resulting cap is zero, and we don't
      adjust the base during a slice producing a zero-cap result,
      so again base can be ignored completely.
      
      No write to base, no write barrier.
      
      The old slice code was trying to work at a Go syntax level, mainly
      because that was how you wrote code just once instead of once
      per architecture. Now the compiler is factored a bit better and we
      can implement slice during code generation but still have one copy
      of the code. So the new code is working at that lower level.
      (It must, to update only parts of the result.)
      
      This CL by itself:
      name                   old mean              new mean              delta
      BinaryTree17            5.81s × (0.98,1.03)   5.71s × (0.96,1.05)     ~    (p=0.101)
      Fannkuch11              4.35s × (1.00,1.00)   4.39s × (1.00,1.00)   +0.79% (p=0.000)
      FmtFprintfEmpty        86.0ns × (0.94,1.11)  82.6ns × (0.98,1.04)   -3.86% (p=0.048)
      FmtFprintfString        276ns × (0.98,1.04)   273ns × (0.98,1.02)     ~    (p=0.235)
      FmtFprintfInt           274ns × (0.98,1.06)   270ns × (0.99,1.01)     ~    (p=0.119)
      FmtFprintfIntInt        506ns × (0.99,1.01)   475ns × (0.99,1.01)   -6.02% (p=0.000)
      FmtFprintfPrefixedInt   391ns × (0.99,1.01)   393ns × (1.00,1.01)     ~    (p=0.139)
      FmtFprintfFloat         566ns × (0.99,1.01)   574ns × (1.00,1.01)   +1.33% (p=0.001)
      FmtManyArgs            1.91µs × (0.99,1.01)  1.87µs × (0.99,1.02)   -1.83% (p=0.000)
      GobDecode              15.3ms × (0.99,1.02)  15.0ms × (0.98,1.05)   -1.84% (p=0.042)
      GobEncode              11.5ms × (0.97,1.03)  11.4ms × (0.99,1.03)     ~    (p=0.152)
      Gzip                    645ms × (0.99,1.01)   647ms × (0.99,1.01)     ~    (p=0.265)
      Gunzip                  142ms × (1.00,1.00)   143ms × (1.00,1.01)   +0.90% (p=0.000)
      HTTPClientServer       90.5µs × (0.97,1.04)  88.5µs × (0.99,1.03)   -2.27% (p=0.014)
      JSONEncode             32.0ms × (0.98,1.03)  29.6ms × (0.98,1.01)   -7.51% (p=0.000)
      JSONDecode              114ms × (0.99,1.01)   104ms × (1.00,1.01)   -8.60% (p=0.000)
      Mandelbrot200          6.04ms × (1.00,1.01)  6.02ms × (1.00,1.00)     ~    (p=0.057)
      GoParse                6.47ms × (0.97,1.05)  6.37ms × (0.97,1.04)     ~    (p=0.105)
      RegexpMatchEasy0_32     171ns × (0.93,1.07)   152ns × (0.99,1.01)  -11.09% (p=0.000)
      RegexpMatchEasy0_1K     550ns × (0.98,1.01)   530ns × (1.00,1.00)   -3.78% (p=0.000)
      RegexpMatchEasy1_32     135ns × (0.99,1.02)   134ns × (0.99,1.01)   -1.33% (p=0.002)
      RegexpMatchEasy1_1K     879ns × (1.00,1.01)   865ns × (1.00,1.00)   -1.58% (p=0.000)
      RegexpMatchMedium_32    243ns × (1.00,1.00)   233ns × (1.00,1.00)   -4.30% (p=0.000)
      RegexpMatchMedium_1K   70.3µs × (1.00,1.00)  69.5µs × (1.00,1.00)   -1.13% (p=0.000)
      RegexpMatchHard_32     3.82µs × (1.00,1.01)  3.74µs × (1.00,1.00)   -1.95% (p=0.000)
      RegexpMatchHard_1K      117µs × (1.00,1.00)   115µs × (1.00,1.00)   -1.69% (p=0.000)
      Revcomp                 917ms × (0.97,1.04)   920ms × (0.97,1.04)     ~    (p=0.786)
      Template                114ms × (0.99,1.01)   117ms × (0.99,1.01)   +2.58% (p=0.000)
      TimeParse               622ns × (0.99,1.01)   615ns × (0.99,1.00)   -1.06% (p=0.000)
      TimeFormat              665ns × (0.99,1.01)   654ns × (0.99,1.00)   -1.70% (p=0.000)
      
      This CL and previous CL (append) combined:
      name                   old mean              new mean              delta
      BinaryTree17            5.68s × (0.97,1.04)   5.71s × (0.96,1.05)     ~    (p=0.638)
      Fannkuch11              4.41s × (0.98,1.03)   4.39s × (1.00,1.00)     ~    (p=0.474)
      FmtFprintfEmpty        92.7ns × (0.91,1.16)  82.6ns × (0.98,1.04)  -10.89% (p=0.004)
      FmtFprintfString        281ns × (0.96,1.08)   273ns × (0.98,1.02)     ~    (p=0.078)
      FmtFprintfInt           288ns × (0.97,1.06)   270ns × (0.99,1.01)   -6.37% (p=0.000)
      FmtFprintfIntInt        493ns × (0.97,1.04)   475ns × (0.99,1.01)   -3.53% (p=0.002)
      FmtFprintfPrefixedInt   423ns × (0.97,1.04)   393ns × (1.00,1.01)   -7.07% (p=0.000)
      FmtFprintfFloat         598ns × (0.99,1.01)   574ns × (1.00,1.01)   -4.02% (p=0.000)
      FmtManyArgs            1.89µs × (0.98,1.05)  1.87µs × (0.99,1.02)     ~    (p=0.305)
      GobDecode              14.8ms × (0.98,1.03)  15.0ms × (0.98,1.05)     ~    (p=0.237)
      GobEncode              12.3ms × (0.98,1.01)  11.4ms × (0.99,1.03)   -6.95% (p=0.000)
      Gzip                    656ms × (0.99,1.05)   647ms × (0.99,1.01)     ~    (p=0.101)
      Gunzip                  142ms × (1.00,1.00)   143ms × (1.00,1.01)   +0.58% (p=0.001)
      HTTPClientServer       91.2µs × (0.97,1.04)  88.5µs × (0.99,1.03)   -3.02% (p=0.003)
      JSONEncode             32.6ms × (0.97,1.08)  29.6ms × (0.98,1.01)   -9.10% (p=0.000)
      JSONDecode              114ms × (0.97,1.05)   104ms × (1.00,1.01)   -8.74% (p=0.000)
      Mandelbrot200          6.11ms × (0.98,1.04)  6.02ms × (1.00,1.00)     ~    (p=0.090)
      GoParse                6.66ms × (0.97,1.04)  6.37ms × (0.97,1.04)   -4.41% (p=0.000)
      RegexpMatchEasy0_32     159ns × (0.99,1.00)   152ns × (0.99,1.01)   -4.69% (p=0.000)
      RegexpMatchEasy0_1K     538ns × (1.00,1.01)   530ns × (1.00,1.00)   -1.57% (p=0.000)
      RegexpMatchEasy1_32     138ns × (1.00,1.00)   134ns × (0.99,1.01)   -2.91% (p=0.000)
      RegexpMatchEasy1_1K     869ns × (0.99,1.01)   865ns × (1.00,1.00)   -0.51% (p=0.012)
      RegexpMatchMedium_32    252ns × (0.99,1.01)   233ns × (1.00,1.00)   -7.85% (p=0.000)
      RegexpMatchMedium_1K   72.7µs × (1.00,1.00)  69.5µs × (1.00,1.00)   -4.43% (p=0.000)
      RegexpMatchHard_32     3.85µs × (1.00,1.00)  3.74µs × (1.00,1.00)   -2.74% (p=0.000)
      RegexpMatchHard_1K      118µs × (1.00,1.00)   115µs × (1.00,1.00)   -2.24% (p=0.000)
      Revcomp                 920ms × (0.97,1.07)   920ms × (0.97,1.04)     ~    (p=0.998)
      Template                129ms × (0.98,1.03)   117ms × (0.99,1.01)   -9.79% (p=0.000)
      TimeParse               619ns × (0.99,1.01)   615ns × (0.99,1.00)   -0.57% (p=0.011)
      TimeFormat              661ns × (0.98,1.04)   654ns × (0.99,1.00)     ~    (p=0.223)
      
      Change-Id: If054d81ab2c71d8d62cf54b5b1fac2af66b387fc
      Reviewed-on: https://go-review.googlesource.com/9813Reviewed-by: 's avatarDavid Chase <drchase@google.com>
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d4472799
    • Matthew Dempsky's avatar
      spec: fix binary expression grammar rule · abb818bc
      Matthew Dempsky authored
      The spec explains later in the "Operator precedence" section that *
      has a higher precedence than +, but the current production rule
      requires that "1 + 2 * 3" be parsed as "(1 + 2) * 3", instead of the
      intended "1 + (2 * 3)".
      
      The new production rule better matches cmd/internal/gc/go.y's grammar:
      
          expr:
                  uexpr
          |       expr LOROR expr
          |       expr LANDAND expr
          |       ...
      
      Fixes #10151.
      
      Change-Id: I13c9635d6ddf1263cafe7cc63e68f3e5779e24ba
      Reviewed-on: https://go-review.googlesource.com/9163Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      abb818bc
    • Robert Griesemer's avatar
      cmd/internal/gc: avoid spurious div-zero errors · 99475dfb
      Robert Griesemer authored
      Set overflowing integer constants to 1 rather than 0 to avoid
      spurious div-zero errors in subsequent constant expressions.
      
      Also: Exclude new test case from go/types test since it's
      running too long (go/types doesn't have an upper constant
      size limit at the moment).
      
      Fixes #7746.
      
      Change-Id: I3768488ad9909a3cf995247b81ee78a8eb5a1e41
      Reviewed-on: https://go-review.googlesource.com/9165
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      99475dfb
    • Rick Hudson's avatar
      runtime: reduce thrashing of gs between ps · c4fe5031
      Rick Hudson authored
      One important use case is a pipeline computation that pass values
      from one Goroutine to the next and then exits or is placed in a
      wait state. If GOMAXPROCS > 1 a Goroutine running on P1 will enable
      another Goroutine and then immediately make P1 available to execute
      it. We need to prevent other Ps from stealing the G that P1 is about
      to execute. Otherwise the Gs can thrash between Ps causing unneeded
      synchronization and slowing down throughput.
      
      Fix this by changing the stealing logic so that when a P attempts to
      steal the only G on some other P's run queue, it will pause
      momentarily to allow the victim P to schedule the G.
      
      As part of optimizing stealing we also use a per P victim queue
      move stolen gs. This eliminates the zeroing of a stack local victim
      queue which turned out to be expensive.
      
      This CL is a necessary but not sufficient prerequisite to changing
      the default value of GOMAXPROCS to something > 1 which is another
      CL/discussion.
      
      For highly serialized programs, such as GoroutineRing below this can
      make a large difference. For larger and more parallel programs such
      as the x/benchmarks there is no noticeable detriment.
      
      ~/work/code/src/rsc.io/benchstat/benchstat old.txt new.txt
      name                old mean              new mean              delta
      GoroutineRing       30.2µs × (0.98,1.01)  30.1µs × (0.97,1.04)     ~    (p=0.941)
      GoroutineRing-2      113µs × (0.91,1.07)    30µs × (0.98,1.03)  -73.17% (p=0.004)
      GoroutineRing-4      144µs × (0.98,1.02)    32µs × (0.98,1.01)  -77.69% (p=0.000)
      GoroutineRingBuf    32.7µs × (0.97,1.03)  32.5µs × (0.97,1.02)     ~    (p=0.795)
      GoroutineRingBuf-2   120µs × (0.92,1.08)    33µs × (1.00,1.00)  -72.48% (p=0.004)
      GoroutineRingBuf-4   138µs × (0.92,1.06)    33µs × (1.00,1.00)  -76.21% (p=0.003)
      
      The bench benchmarks show little impact.
          	  	      old  	 new
      garbage	      	      7032879	 7011696
      httpold		        25509	   25301
      splayold	      1022073	 1019499
      jsonold		     28230624   28081433
      
      Change-Id: I228c48fed8d85c9bbef16a7edc53ab7898506f50
      Reviewed-on: https://go-review.googlesource.com/9872Reviewed-by: 's avatarAustin Clements <austin@google.com>
      c4fe5031
    • Mikio Hara's avatar
      net: don't run IP stack required tests on IP stack unimplemented kernels · 3b38626f
      Mikio Hara authored
      Fixes #10787.
      
      Change-Id: I35c96808a713dafb1f0fea301fa3f3528fe6a5bf
      Reviewed-on: https://go-review.googlesource.com/9948Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
      3b38626f
    • Mikio Hara's avatar
      net, internal/syscall/unix: add SocketConn, SocketPacketConn · 6f7961da
      Mikio Hara authored
      FileConn and FilePacketConn APIs accept user-configured socket
      descriptors to make them work together with runtime-integrated network
      poller, but there's a limitation. The APIs reject protocol sockets that
      are not supported by standard library. It's very hard for the net,
      syscall packages to look after all platform, feature-specific sockets.
      
      This change allows various platform, feature-specific socket descriptors
      to use runtime-integrated network poller by using SocketConn,
      SocketPacketConn APIs that bridge between the net, syscall packages and
      platforms.
      
      New exposed APIs:
      pkg net, func SocketConn(*os.File, SocketAddr) (Conn, error)
      pkg net, func SocketPacketConn(*os.File, SocketAddr) (PacketConn, error)
      pkg net, type SocketAddr interface { Addr, Raw }
      pkg net, type SocketAddr interface, Addr([]uint8) Addr
      pkg net, type SocketAddr interface, Raw(Addr) []uint8
      
      Fixes #10565.
      
      Change-Id: Iec57499b3d84bb5cb0bcf3f664330c535eec11e3
      Reviewed-on: https://go-review.googlesource.com/9275Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      6f7961da
    • Ian Lance Taylor's avatar
      syscall: mkerrors.sh: don't define _FILE_OFFSET_BITS if __LP64__ · 08ba7dbd
      Ian Lance Taylor authored
      If __LP64__ is defined then the type "long" is 64-bits, and there is
      no need to explicitly request _FILE_OFFSET_BITS == 64.  This changes
      the definitions of F_GETLK, F_SETLK, and F_SETLKW on PPC to the values
      that the kernel requires.  The values used in C when _FILE_OFFSET_BITS
      == 64 are corrected by the glibc fcntl function before making the
      system call.
      
      With this change, regenerate ppc64le files on Ubuntu trusty.
      
      Change-Id: I8dddbd8a6bae877efff818f5c5dd06291ade3238
      Reviewed-on: https://go-review.googlesource.com/9962Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      08ba7dbd
  3. 12 May, 2015 19 commits
    • Hyang-Ah (Hana) Kim's avatar
      misc/cgo/testcshared: fix test for android. · a4f4a46c
      Hyang-Ah (Hana) Kim authored
      On android the generated header files are located in
      pkg/$(go env GOOS)_$(go env GOARCH)_testcshared.
      The test was broken since https://go-review.googlesource.com/9798.
      
      The installation path differs based on codegenArgs
      (around src/cmd/go/build.go line 389), and the codegenArgs
      is platform dependent.
      
      Change-Id: I01ae9cb957fb7676e399f3b8c067f24c5bd20b9d
      Reviewed-on: https://go-review.googlesource.com/9980Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      a4f4a46c
    • Shenghou Ma's avatar
      testing: fix typo · c06b8565
      Shenghou Ma authored
      Fixes #10794.
      
      Change-Id: Id91485394ddbadc28c800e1d0c3ec281ba6cd098
      Reviewed-on: https://go-review.googlesource.com/9990Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      c06b8565
    • Ian Lance Taylor's avatar
      syscall: mksysnum_linux.pl: run syscall numbers through GCC · 1828d03a
      Ian Lance Taylor authored
      This will skip system call numbers that are ifdef'ed out in unistd.h,
      as occurs on PPC.
      
      Change-Id: I88e640e4621c7a8cc266433f34a7b4be71543ec9
      Reviewed-on: https://go-review.googlesource.com/9966Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      1828d03a
    • Austin Clements's avatar
      runtime: don't run runq tests on the system stack · 350fd548
      Austin Clements authored
      Running these tests on the system stack is problematic because they
      allocate Ps, which are large enough to overflow the system stack if
      they are stack-allocated. It used to be necessary to run these tests
      on the system stack because they were written in C, but since this is
      no longer the case, we can fix this problem by simply not running the
      tests on the system stack.
      
      This also means we no longer need the hack in one of these tests that
      forces the allocated Ps to escape to the heap, so eliminate that as
      well.
      
      Change-Id: I9064f5f8fd7f7b446ff39a22a70b172cfcb2dc57
      Reviewed-on: https://go-review.googlesource.com/9923Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      350fd548
    • Russ Cox's avatar
      cmd/5g: fix build · 5ed4bb6d
      Russ Cox authored
      The line in cgen.go was lost during the ginscmp CL.
      The ggen.go change is not strictly necessary, but
      it makes the 5g -S output for x[0] match what it said
      before the ginscmp CL.
      
      Change-Id: I5890a9ec1ac69a38509416eda5aea13b8b12b94a
      Reviewed-on: https://go-review.googlesource.com/9929Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      5ed4bb6d
    • Andrew Williams's avatar
      syscall: relocate linux death signal code · 9b379d7e
      Andrew Williams authored
      Fix bug on Linux SysProcAttr handling: setting both Pdeathsig and
      Credential caused Pdeathsig to be ignored. This is because the kernel
      clears the deathsignal field when performing a setuid/setgid
      system call.
      
      Avoid this by moving Pdeathsig handling after Credential handling.
      
      Fixes #9686
      
      Change-Id: Id01896ad4e979b8c448e0061f00aa8762ca0ac94
      Reviewed-on: https://go-review.googlesource.com/3290Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      9b379d7e
    • Russ Cox's avatar
      cmd/internal/gc: optimize append + write barrier · 8552047a
      Russ Cox authored
      The code generated for x = append(x, v) is roughly:
      
      	t := x
      	if len(t)+1 > cap(t) {
      		t = grow(t)
      	}
      	t[len(t)] = v
      	len(t)++
      	x = t
      
      We used to generate this code as Go pseudocode during walk.
      Generate it instead as actual instructions during gen.
      
      Doing so lets us apply a few optimizations. The most important
      is that when, as in the above example, the source slice and the
      destination slice are the same, the code can instead do:
      
      	t := x
      	if len(t)+1 > cap(t) {
      		t = grow(t)
      		x = {base(t), len(t)+1, cap(t)}
      	} else {
      		len(x)++
      	}
      	t[len(t)] = v
      
      That is, in the fast path that does not reallocate the array,
      only the updated length needs to be written back to x,
      not the array pointer and not the capacity. This is more like
      what you'd write by hand in C. It's faster in general, since
      the fast path elides two of the three stores, but it's especially
      faster when the form of x is such that the base pointer write
      would turn into a write barrier. No write, no barrier.
      
      name                   old mean              new mean              delta
      BinaryTree17            5.68s × (0.97,1.04)   5.81s × (0.98,1.03)   +2.35% (p=0.023)
      Fannkuch11              4.41s × (0.98,1.03)   4.35s × (1.00,1.00)     ~    (p=0.090)
      FmtFprintfEmpty        92.7ns × (0.91,1.16)  86.0ns × (0.94,1.11)   -7.31% (p=0.038)
      FmtFprintfString        281ns × (0.96,1.08)   276ns × (0.98,1.04)     ~    (p=0.219)
      FmtFprintfInt           288ns × (0.97,1.06)   274ns × (0.98,1.06)   -4.94% (p=0.002)
      FmtFprintfIntInt        493ns × (0.97,1.04)   506ns × (0.99,1.01)   +2.65% (p=0.009)
      FmtFprintfPrefixedInt   423ns × (0.97,1.04)   391ns × (0.99,1.01)   -7.52% (p=0.000)
      FmtFprintfFloat         598ns × (0.99,1.01)   566ns × (0.99,1.01)   -5.27% (p=0.000)
      FmtManyArgs            1.89µs × (0.98,1.05)  1.91µs × (0.99,1.01)     ~    (p=0.231)
      GobDecode              14.8ms × (0.98,1.03)  15.3ms × (0.99,1.02)   +3.01% (p=0.000)
      GobEncode              12.3ms × (0.98,1.01)  11.5ms × (0.97,1.03)   -5.93% (p=0.000)
      Gzip                    656ms × (0.99,1.05)   645ms × (0.99,1.01)     ~    (p=0.055)
      Gunzip                  142ms × (1.00,1.00)   142ms × (1.00,1.00)   -0.32% (p=0.034)
      HTTPClientServer       91.2µs × (0.97,1.04)  90.5µs × (0.97,1.04)     ~    (p=0.468)
      JSONEncode             32.6ms × (0.97,1.08)  32.0ms × (0.98,1.03)     ~    (p=0.190)
      JSONDecode              114ms × (0.97,1.05)   114ms × (0.99,1.01)     ~    (p=0.887)
      Mandelbrot200          6.11ms × (0.98,1.04)  6.04ms × (1.00,1.01)     ~    (p=0.167)
      GoParse                6.66ms × (0.97,1.04)  6.47ms × (0.97,1.05)   -2.81% (p=0.014)
      RegexpMatchEasy0_32     159ns × (0.99,1.00)   171ns × (0.93,1.07)   +7.19% (p=0.002)
      RegexpMatchEasy0_1K     538ns × (1.00,1.01)   550ns × (0.98,1.01)   +2.30% (p=0.000)
      RegexpMatchEasy1_32     138ns × (1.00,1.00)   135ns × (0.99,1.02)   -1.60% (p=0.000)
      RegexpMatchEasy1_1K     869ns × (0.99,1.01)   879ns × (1.00,1.01)   +1.08% (p=0.000)
      RegexpMatchMedium_32    252ns × (0.99,1.01)   243ns × (1.00,1.00)   -3.71% (p=0.000)
      RegexpMatchMedium_1K   72.7µs × (1.00,1.00)  70.3µs × (1.00,1.00)   -3.34% (p=0.000)
      RegexpMatchHard_32     3.85µs × (1.00,1.00)  3.82µs × (1.00,1.01)   -0.81% (p=0.000)
      RegexpMatchHard_1K      118µs × (1.00,1.00)   117µs × (1.00,1.00)   -0.56% (p=0.000)
      Revcomp                 920ms × (0.97,1.07)   917ms × (0.97,1.04)     ~    (p=0.808)
      Template                129ms × (0.98,1.03)   114ms × (0.99,1.01)  -12.06% (p=0.000)
      TimeParse               619ns × (0.99,1.01)   622ns × (0.99,1.01)     ~    (p=0.062)
      TimeFormat              661ns × (0.98,1.04)   665ns × (0.99,1.01)     ~    (p=0.524)
      
      See next CL for combination with a similar optimization for slice.
      The benchmarks that are slower in this CL are still faster overall
      with the combination of the two.
      
      Change-Id: I2a7421658091b2488c64741b4db15ab6c3b4cb7e
      Reviewed-on: https://go-review.googlesource.com/9812Reviewed-by: 's avatarDavid Chase <drchase@google.com>
      8552047a
    • Russ Cox's avatar
      cmd/internal/gc: add backend ginscmp function to emit a comparison · f8d14fc3
      Russ Cox authored
      This lets us abstract away which arguments can be constants and so on
      and lets the back ends reverse the order of arguments if that helps.
      
      Change-Id: I283ec1d694f2dd84eba22e5eb4aad78a2d2d9eb0
      Reviewed-on: https://go-review.googlesource.com/9810Reviewed-by: 's avatarDavid Chase <drchase@google.com>
      f8d14fc3
    • Rob Pike's avatar
      encoding/gob: add "too big" check when writing a message · 6439010e
      Rob Pike authored
      Messages that are too big are rejected when read, so they should
      be rejected when written too.
      
      Fixes #10518.
      
      Change-Id: I96678fbe2d94f51b957fe26faef33cd8df3823dd
      Reviewed-on: https://go-review.googlesource.com/9965Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      6439010e
    • David du Colombier's avatar
      runtime: terminate exit status buffer on Plan 9 · 7de86a1b
      David du Colombier authored
      The status buffer built by the exit function
      was not nil-terminated.
      
      Fixes #10789.
      
      Change-Id: I2d34ac50a19d138176c4b47393497ba7070d5b61
      Reviewed-on: https://go-review.googlesource.com/9953Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      7de86a1b
    • David du Colombier's avatar
      runtime: fix signal handling on Plan 9 · f85a0558
      David du Colombier authored
      Once added to the signal queue, the pointer passed to the
      signal handler could no longer be valid. Instead of passing
      the pointer to the note string, we recopy the value of the
      note string to a static array in the signal queue.
      
      Fixes #10784.
      
      Change-Id: Iddd6837b58a14dfaa16b069308ae28a7b8e0965b
      Reviewed-on: https://go-review.googlesource.com/9950Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      f85a0558
    • Russ Cox's avatar
      cmd/internal/gc: avoid turning 'x = f()' into 'tmp = f(); x = tmp' for simple x · 18d98bc9
      Russ Cox authored
      This slows down more things than I expected, but it also speeds things up,
      and it reduces stack frame sizes and the load on the optimizer, so it's still
      likely a net win.
      
      name                                    old mean                new mean        delta
      BenchmarkBinaryTree17              13.2s × (0.98,1.03)     13.2s × (0.98,1.02)  ~ (p=0.795)
      BenchmarkFannkuch11                4.41s × (1.00,1.00)     4.45s × (0.99,1.01)  +0.88% (p=0.000)
      BenchmarkFmtFprintfEmpty          86.4ns × (0.99,1.01)    90.1ns × (0.95,1.05)  +4.31% (p=0.000)
      BenchmarkFmtFprintfString          318ns × (0.96,1.07)     337ns × (0.98,1.03)  +6.05% (p=0.000)
      BenchmarkFmtFprintfInt             332ns × (0.97,1.04)     320ns × (0.97,1.02)  -3.42% (p=0.000)
      BenchmarkFmtFprintfIntInt          562ns × (0.96,1.04)     574ns × (0.96,1.06)  +2.00% (p=0.013)
      BenchmarkFmtFprintfPrefixedInt     442ns × (0.96,1.06)     450ns × (0.97,1.05)  +1.73% (p=0.039)
      BenchmarkFmtFprintfFloat           640ns × (0.99,1.02)     659ns × (0.99,1.03)  +3.01% (p=0.000)
      BenchmarkFmtManyArgs              2.19µs × (0.97,1.06)    2.21µs × (0.98,1.02)  ~ (p=0.104)
      BenchmarkGobDecode                20.0ms × (0.98,1.03)    19.7ms × (0.97,1.04)  -1.35% (p=0.035)
      BenchmarkGobEncode                17.8ms × (0.96,1.04)    18.0ms × (0.96,1.06)  ~ (p=0.131)
      BenchmarkGzip                      653ms × (0.99,1.02)     652ms × (0.99,1.01)  ~ (p=0.572)
      BenchmarkGunzip                    143ms × (0.99,1.02)     142ms × (1.00,1.01)  -0.52% (p=0.005)
      BenchmarkHTTPClientServer          110µs × (0.98,1.03)     108µs × (0.99,1.02)  -1.90% (p=0.000)
      BenchmarkJSONEncode               40.0ms × (0.98,1.05)    41.5ms × (0.97,1.06)  +3.89% (p=0.000)
      BenchmarkJSONDecode                118ms × (0.99,1.01)     118ms × (0.98,1.01)  +0.69% (p=0.010)
      BenchmarkMandelbrot200            6.03ms × (1.00,1.01)    6.03ms × (1.00,1.01)  ~ (p=0.924)
      BenchmarkGoParse                  8.43ms × (0.92,1.11)    8.56ms × (0.93,1.05)  ~ (p=0.242)
      BenchmarkRegexpMatchEasy0_32       180ns × (0.91,1.07)     163ns × (1.00,1.00)  -9.33% (p=0.000)
      BenchmarkRegexpMatchEasy0_1K       550ns × (0.98,1.02)     558ns × (0.99,1.01)  +1.44% (p=0.000)
      BenchmarkRegexpMatchEasy1_32       152ns × (0.94,1.05)     139ns × (0.98,1.02)  -8.51% (p=0.000)
      BenchmarkRegexpMatchEasy1_1K       909ns × (0.98,1.06)     868ns × (0.99,1.02)  -4.52% (p=0.000)
      BenchmarkRegexpMatchMedium_32      262ns × (0.97,1.03)     253ns × (0.99,1.02)  -3.31% (p=0.000)
      BenchmarkRegexpMatchMedium_1K     73.8µs × (0.98,1.04)    72.7µs × (1.00,1.01)  -1.61% (p=0.001)
      BenchmarkRegexpMatchHard_32       3.87µs × (0.99,1.02)    3.87µs × (1.00,1.01)  ~ (p=0.791)
      BenchmarkRegexpMatchHard_1K        118µs × (0.98,1.04)     117µs × (0.99,1.02)  ~ (p=0.110)
      BenchmarkRevcomp                   1.00s × (0.94,1.10)     0.99s × (0.94,1.09)  ~ (p=0.433)
      BenchmarkTemplate                  140ms × (0.97,1.04)     140ms × (0.99,1.01)  ~ (p=0.303)
      BenchmarkTimeParse                 622ns × (0.99,1.02)     625ns × (0.99,1.01)  +0.51% (p=0.001)
      BenchmarkTimeFormat                731ns × (0.98,1.04)     719ns × (0.99,1.01)  -1.66% (p=0.000)
      
      Change-Id: Ibc3edb59a178adafda50156f46a341f69a17d83f
      Reviewed-on: https://go-review.googlesource.com/9721Reviewed-by: 's avatarDavid Chase <drchase@google.com>
      18d98bc9
    • Russ Cox's avatar
      cmd/internal/gc: detect bad append(f()) during type check · 3f209abb
      Russ Cox authored
      Today's earlier fix can stay, but it's a band-aid over the real problem,
      which is that bad code was slipping through the type checker
      into the back end (and luckily causing a type error there).
      
      I discovered this because my new append does not use the same
      temporaries and failed the test as written.
      
      Fixes #9521.
      
      Change-Id: I7e33e2ea15743406e15c6f3fdf73e1edecda69bd
      Reviewed-on: https://go-review.googlesource.com/9921Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      3f209abb
    • Jens Frederich's avatar
      cmd/go: "go get" don't ignore git default branch · 29dc4b40
      Jens Frederich authored
      Any Git branch can be the default branch not only master. Removing
      hardwired 'checkout master', and using 'checkout {tag}' is the best
      choice. It works with and without a master branch. Furthermore it
      resolves the Github default branch issue. Changing Github default
      branch is effectively changing HEAD.
      
      Fixes #9032
      
      Change-Id: I19a1221bcefe0806e7556c124c6da7ac0c2160b5
      Reviewed-on: https://go-review.googlesource.com/5312Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      29dc4b40
    • Patrick Mezard's avatar
      time: fix registry zone info lookup on Windows · 51021cc8
      Patrick Mezard authored
      registry.ReadSubKeyNames requires QUERY access right in addition to
      ENUMERATE_SUB_KEYS.
      
      This was making TestLocalZoneAbbr fail on Windows 7 in Paris/Madrid
      timezone. It succeeded on Windows 8 because timezone name changed from
      "Paris/Madrid" to "Romance Standard Time", the latter being matched by
      an abbrs entry.
      
      Change-Id: I791287ba9d1b3556246fa4e9e1604a1fbba1f5e6
      Reviewed-on: https://go-review.googlesource.com/9809Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      51021cc8
    • Alex Brainman's avatar
      net: relax error checking in TestAcceptIgnoreSomeErrors · 71bf1820
      Alex Brainman authored
      TestAcceptIgnoreSomeErrors was created to test that network
      accept function ignores some errors. But conditions created
      by the test also affects network reads. Change the test to
      ignore these read errors when acceptable.
      
      Fixes #10785
      
      Change-Id: I3da85cb55bd3e78c1980ad949e53e82391f9b41e
      Reviewed-on: https://go-review.googlesource.com/9942Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      71bf1820
    • Shenghou Ma's avatar
      syscall: fix running mkall.sh on linux/{ppc64,ppc64le} · 7bbd4f78
      Shenghou Ma authored
      Change-Id: I58c6e914d0e977d5748c87d277e30c933ed86f99
      Reviewed-on: https://go-review.googlesource.com/9924Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      7bbd4f78
    • Michael Hudson-Doyle's avatar
      cmd/internal/ld, runtime: abort on shared library ABI mismatch · 77fc03f4
      Michael Hudson-Doyle authored
      This:
      
      1) Defines the ABI hash of a package (as the SHA1 of the __.PKGDEF)
      2) Defines the ABI hash of a shared library (sort the packages by import
         path, concatenate the hashes of the packages and SHA1 that)
      3) When building a shared library, compute the above value and define a
         global symbol that points to a go string that has the hash as its value.
      4) When linking against a shared library, read the abi hash from the
         library and put both the value seen at link time and a reference
         to the global symbol into the moduledata.
      5) During runtime initialization, check that the hash seen at link time
         still matches the hash the global symbol points to.
      
      Change-Id: Iaa54c783790e6dde3057a2feadc35473d49614a5
      Reviewed-on: https://go-review.googlesource.com/8773Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
      77fc03f4
    • Michael Hudson-Doyle's avatar
      runtime: fix addmoduledata to follow the platform ABI · be0cb922
      Michael Hudson-Doyle authored
      addmoduledata is called from a .init_array function and need to follow the
      platform ABI. It contains accesses to global data which are rewritten to use
      R15 by the assembler, and as R15 is callee-save we need to save it.
      
      Change-Id: I03893efb1576aed4f102f2465421f256f3bb0f30
      Reviewed-on: https://go-review.googlesource.com/9941Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      be0cb922
  4. 11 May, 2015 5 commits