1. 10 Apr, 2019 3 commits
  2. 09 Apr, 2019 8 commits
    • Cherry Zhang's avatar
      cmd/internal/obj/x86: allow non-zero offset in TLS reference · 68c66414
      Cherry Zhang authored
      An instruction that references TLS, e.g.
      
      MOVQ	0(TLS), AX
      
      on some platforms (e.g. Android), or in shared mode, may be
      translated to (assuming TLS offset already loaded to CX)
      
      MOVQ	0(CX)(TLS*1), AX
      
      which in turns translates to
      
      movq	%fs:(%rcx), %rax
      
      We have rejected non-zero offset for TLS reference, like 16(TLS).
      Actually, the instruction can take offset, i.e. it is a valid
      instruction for, e.g.,
      
      movq	%fs:16(%rcx),%rcx
      
      So, allow offset in TLS reference.
      
      Change-Id: Iaf1996bad7fe874e0c298ea441af5acb136a4028
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171151
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      68c66414
    • Tobias Klauser's avatar
      strings: add TestIndexByte · 016625c2
      Tobias Klauser authored
      Add TestIndexByte to package strings similar to the already existing
      TestIndexByte in package bytes.
      
      Change-Id: Ib60695cb326156a4fe48138c66393ebbd11e4a25
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171197
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      016625c2
    • Tobias Klauser's avatar
      strings: use Go style character range comparison in ToUpper/ToLower · 78175474
      Tobias Klauser authored
      As noted by Brad in CL 170954 for package bytes.
      
      Change-Id: I2772a356299e54ba5b7884d537e6649039adb9be
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171198
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      78175474
    • Andrei Vagin's avatar
      runtime: preempt a goroutine which calls a lot of short system calls · 4166ff42
      Andrei Vagin authored
      A goroutine should be preempted if it runs for 10ms without blocking.
      We found that this doesn't work for goroutines which call short system calls.
      
      For example, the next program can stuck for seconds without this fix:
      
      $ cat main.go
      package main
      
      import (
      	"runtime"
      	"syscall"
      )
      
      func main() {
      	runtime.GOMAXPROCS(1)
      	c := make(chan int)
      	go func() {
      		c <- 1
      		for {
      			t := syscall.Timespec{
      				Nsec: 300,
      			}
      			if true {
      				syscall.Nanosleep(&t, nil)
      			}
      		}
      	}()
      	<-c
      }
      
      $ time go run main.go
      
      real	0m8.796s
      user	0m0.367s
      sys	0m0.893s
      
      Updates #10958
      
      Change-Id: Id3be54d3779cc28bfc8b33fe578f13778f1ae2a2
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170138Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      4166ff42
    • Tobias Klauser's avatar
      bytes: optimize ToLower and ToUpper for ASCII-only case · 08e1823a
      Tobias Klauser authored
      Follow what CL 68370 and CL 76470 did for the respective functions in
      package strings.
      
      Also adjust godoc strings to match the respective strings functions and
      mention the special case for ASCII-only byte slices which don't need
      conversion.
      
      name                                       old time/op  new time/op  delta
      ToUpper/#00-8                              9.35ns ± 3%  6.08ns ± 2%  -35.04%  (p=0.000 n=9+9)
      ToUpper/ONLYUPPER-8                        77.7ns ± 1%  16.9ns ± 2%  -78.22%  (p=0.000 n=10+10)
      ToUpper/abc-8                              36.5ns ± 1%  22.1ns ± 1%  -39.43%  (p=0.000 n=10+8)
      ToUpper/AbC123-8                           56.9ns ± 2%  28.2ns ± 2%  -50.54%  (p=0.000 n=8+10)
      ToUpper/azAZ09_-8                          62.3ns ± 1%  26.9ns ± 1%  -56.82%  (p=0.000 n=9+10)
      ToUpper/longStrinGwitHmixofsmaLLandcAps-8   219ns ± 2%    63ns ± 2%  -71.17%  (p=0.000 n=10+10)
      ToUpper/longɐstringɐwithɐnonasciiⱯchars-8   367ns ± 2%   374ns ± 3%   +2.05%  (p=0.000 n=9+10)
      ToUpper/ɐɐɐɐɐ-8                             200ns ± 1%   206ns ± 1%   +2.49%  (p=0.000 n=10+10)
      ToUpper/a\u0080\U0010ffff-8                90.4ns ± 1%  93.8ns ± 0%   +3.82%  (p=0.000 n=10+7)
      ToLower/#00-8                              9.59ns ± 1%  6.13ns ± 2%  -36.08%  (p=0.000 n=10+10)
      ToLower/abc-8                              36.4ns ± 1%  10.4ns ± 1%  -71.50%  (p=0.000 n=10+10)
      ToLower/AbC123-8                           55.8ns ± 1%  27.5ns ± 1%  -50.61%  (p=0.000 n=10+10)
      ToLower/azAZ09_-8                          61.7ns ± 1%  30.2ns ± 1%  -50.98%  (p=0.000 n=8+10)
      ToLower/longStrinGwitHmixofsmaLLandcAps-8   226ns ± 1%    64ns ± 1%  -71.53%  (p=0.000 n=10+9)
      ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-8   354ns ± 0%   361ns ± 0%   +2.18%  (p=0.000 n=10+10)
      ToLower/ⱭⱭⱭⱭⱭ-8                             180ns ± 1%   186ns ± 0%   +3.45%  (p=0.000 n=10+9)
      ToLower/A\u0080\U0010ffff-8                91.7ns ± 0%  94.5ns ± 0%   +2.99%  (p=0.000 n=10+10)
      
      Change-Id: Ifdb8ae328ff9feacd1c170db8eebbf98c399e204
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170954
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      08e1823a
    • Mikio Hara's avatar
      syscall: gofmt -w -s · 2ab75c0f
      Mikio Hara authored
      Change-Id: Ib46f1a528e16cd0c2617defbf4dcd1f1b582cdc2
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171101
      Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      2ab75c0f
    • Mikio Hara's avatar
      cmd/cover: rename temporary directory prefix for consistency · 7ea4cd3f
      Mikio Hara authored
      This change renames the temporary directory prefix for testing to
      go-testcover from gotestcover. It looks like other packages have the
      "go-" prefix for temporary directories, such as go-build, go-tool-dist
      and go-nettest.
      
      Change-Id: I91ab570d33c4c1bb48e6e01451a811272f6f8b77
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171100Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      7ea4cd3f
    • Neven Sajko's avatar
      all: change the old assembly style AX:CX to CX, AX · 7756a72b
      Neven Sajko authored
      Assembly files with "/vendor/" or "testdata" in their paths were ignored.
      
      Change-Id: I3882ff07eb4426abb9f8ee96f82dff73c81cd61f
      GitHub-Last-Rev: 51ae8c324d72a12a059272fcf8568e670bfaf21b
      GitHub-Pull-Request: golang/go#31166
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170197Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      7756a72b
  3. 08 Apr, 2019 17 commits
  4. 07 Apr, 2019 6 commits
  5. 05 Apr, 2019 6 commits
    • Daniel Martí's avatar
      encoding/json: use SetBytes in UnmarshalReuse benchmark · cb664623
      Daniel Martí authored
      This was the only benchmark missing the SetBytes call, as spotted
      earlier by Bryan.
      
      It's not required to make the benchmark useful, but it can still be a
      good way to see how its speed is affected by the reduced allocations:
      
      name                  time/op
      CodeUnmarshal-8        12.1ms ± 1%
      CodeUnmarshalReuse-8   11.4ms ± 1%
      
      name                  speed
      CodeUnmarshal-8       161MB/s ± 1%
      CodeUnmarshalReuse-8  171MB/s ± 1%
      
      name                  alloc/op
      CodeUnmarshal-8        3.28MB ± 0%
      CodeUnmarshalReuse-8   1.94MB ± 0%
      
      name                  allocs/op
      CodeUnmarshal-8         92.7k ± 0%
      CodeUnmarshalReuse-8    77.6k ± 0%
      
      While at it, remove some unnecessary empty lines.
      
      Change-Id: Ib2bd92d5b3237b8f3092e8c6f863dab548fee2f5
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170938
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      cb664623
    • Keith Randall's avatar
      syscall: use openat instead of dup to make a really new file descriptor · 06cff114
      Keith Randall authored
      Update #31269
      
      Change-Id: I0e7184420055b8dfd23688dab9f9d8cba1fa2485
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170892
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      06cff114
    • Austin Clements's avatar
      runtime: separate stack freeing from stack shrinking · 68d89bb8
      Austin Clements authored
      Currently, shrinkstack will free the stack if the goroutine is dead.
      There are only two places that call shrinkstack: scanstack, which will
      never call it if the goroutine is dead; and markrootFreeGStacks, which
      only calls it on dead goroutines.
      
      Clean this up by separating stack freeing out of shrinkstack.
      
      Change-Id: I7d7891e620550c32a2220833923a025704986681
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170890
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
      68d89bb8
    • Austin Clements's avatar
      runtime: use acquirem/releasem more widely · ea9859f8
      Austin Clements authored
      We've copy-pasted the pattern of releasem in many places. This CL
      replaces almost everywhere that manipulates g.m.locks and g.preempt
      with calls to acquirem/releasem. There are a few where we do something
      more complicated, like where exitsyscall has to restore the stack
      bound differently depending on the preempt flag, which this CL leaves
      alone.
      
      Change-Id: Ia7a46c261daea6e7802b80e7eb9227499f460433
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170064
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      ea9859f8
    • Austin Clements's avatar
      runtime: fix sanity check in notetsleep · ac40a7fb
      Austin Clements authored
      CL 3660 replaced m.gcing with m.preemptoff, but unintentionally
      reversed the sense of part of a sanity check in notetsleep.
      Originally, notetsleep required that it be called from g0 or with
      preemption disabled (specifically from within the garbage collector).
      CL 3660 made it require that it be called from g0 or that preemption
      be *enabled*.
      
      I'm not sure why it had the original exception for being called from a
      user g within the garbage collector, but the current garbage collector
      certainly doesn't need that, and the new condition is completely wrong.
      
      Make the sanity check just require that it's called on g0.
      
      Change-Id: I6980d44f5a4461935e10b1b33a981e32b1b7b0c9
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170063
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      ac40a7fb
    • Austin Clements's avatar
      sync: smooth out Pool behavior over GC with a victim cache · 2dcbf8b3
      Austin Clements authored
      Currently, every Pool is cleared completely at the start of each GC.
      This is a problem for heavy users of Pool because it causes an
      allocation spike immediately after Pools are clear, which impacts both
      throughput and latency.
      
      This CL fixes this by introducing a victim cache mechanism. Instead of
      clearing Pools, the victim cache is dropped and the primary cache is
      moved to the victim cache. As a result, in steady-state, there are
      (roughly) no new allocations, but if Pool usage drops, objects will
      still be collected within two GCs (as opposed to one).
      
      This victim cache approach also improves Pool's impact on GC dynamics.
      The current approach causes all objects in Pools to be short lived.
      However, if an application is in steady state and is just going to
      repopulate its Pools, then these objects impact the live heap size *as
      if* they were long lived. Since Pooled objects count as short lived
      when computing the GC trigger and goal, but act as long lived objects
      in the live heap, this causes GC to trigger too frequently. If Pooled
      objects are a non-trivial portion of an application's heap, this
      increases the CPU overhead of GC. The victim cache lets Pooled objects
      affect the GC trigger and goal as long-lived objects.
      
      This has no impact on Get/Put performance, but substantially reduces
      the impact to the Pool user when a GC happens. PoolExpensiveNew
      demonstrates this in the substantially reduction in the rate at which
      the "New" function is called.
      
      name                 old time/op     new time/op     delta
      Pool-12                 2.21ns ±36%     2.00ns ± 0%     ~     (p=0.070 n=19+16)
      PoolOverflow-12          587ns ± 1%      583ns ± 1%   -0.77%  (p=0.000 n=18+18)
      PoolSTW-12              5.57µs ± 3%     4.52µs ± 4%  -18.82%  (p=0.000 n=20+19)
      PoolExpensiveNew-12     3.69ms ± 7%     1.25ms ± 5%  -66.25%  (p=0.000 n=20+19)
      
      name                 old p50-ns/STW  new p50-ns/STW  delta
      PoolSTW-12               5.48k ± 2%      4.53k ± 2%  -17.32%  (p=0.000 n=20+20)
      
      name                 old p95-ns/STW  new p95-ns/STW  delta
      PoolSTW-12               6.69k ± 4%      5.13k ± 3%  -23.31%  (p=0.000 n=19+18)
      
      name                 old GCs/op      new GCs/op      delta
      PoolExpensiveNew-12       0.39 ± 1%       0.32 ± 2%  -17.95%  (p=0.000 n=18+20)
      
      name                 old New/op      new New/op      delta
      PoolExpensiveNew-12       40.0 ± 6%       12.4 ± 6%  -68.91%  (p=0.000 n=20+19)
      
      (https://perf.golang.org/search?q=upload:20190311.2)
      
      Fixes #22950.
      
      Change-Id: If2e183d948c650417283076aacc20739682cdd70
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166961
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDavid Chase <drchase@google.com>
      2dcbf8b3