1. 06 Nov, 2015 6 commits
    • Ilya Tocar's avatar
      runtime: optimize indexbytebody on amd64 · 321a4072
      Ilya Tocar authored
      Use avx2 to compare 32 bytes per iteration.
      Results (haswell):
      
      name                    old time/op    new time/op     delta
      IndexByte32-6             15.5ns ± 0%     14.7ns ± 5%   -4.87%        (p=0.000 n=16+20)
      IndexByte4K-6              360ns ± 0%      183ns ± 0%  -49.17%        (p=0.000 n=19+20)
      IndexByte4M-6              384µs ± 0%      256µs ± 1%  -33.41%        (p=0.000 n=20+20)
      IndexByte64M-6            6.20ms ± 0%     4.18ms ± 1%  -32.52%        (p=0.000 n=19+20)
      IndexBytePortable32-6     73.4ns ± 5%     75.8ns ± 3%   +3.35%        (p=0.000 n=20+19)
      IndexBytePortable4K-6     5.15µs ± 0%     5.15µs ± 0%     ~     (all samples are equal)
      IndexBytePortable4M-6     5.26ms ± 0%     5.25ms ± 0%   -0.12%        (p=0.000 n=20+18)
      IndexBytePortable64M-6    84.1ms ± 0%     84.1ms ± 0%   -0.08%        (p=0.012 n=18+20)
      Index32-6                  352ns ± 0%      352ns ± 0%     ~     (all samples are equal)
      Index4K-6                 53.8µs ± 0%     53.8µs ± 0%   -0.03%        (p=0.000 n=16+18)
      Index4M-6                 55.4ms ± 0%     55.4ms ± 0%     ~           (p=0.149 n=20+19)
      Index64M-6                 886ms ± 0%      886ms ± 0%     ~           (p=0.108 n=20+20)
      IndexEasy32-6             80.3ns ± 0%     80.1ns ± 0%   -0.21%        (p=0.000 n=20+20)
      IndexEasy4K-6              426ns ± 0%      215ns ± 0%  -49.53%        (p=0.000 n=20+20)
      IndexEasy4M-6              388µs ± 0%      262µs ± 1%  -32.42%        (p=0.000 n=18+20)
      IndexEasy64M-6            6.20ms ± 0%     4.19ms ± 1%  -32.47%        (p=0.000 n=18+20)
      
      name                    old speed      new speed       delta
      IndexByte32-6           2.06GB/s ± 1%   2.17GB/s ± 5%   +5.19%        (p=0.000 n=18+20)
      IndexByte4K-6           11.4GB/s ± 0%   22.3GB/s ± 0%  +96.45%        (p=0.000 n=17+20)
      IndexByte4M-6           10.9GB/s ± 0%   16.4GB/s ± 1%  +50.17%        (p=0.000 n=20+20)
      IndexByte64M-6          10.8GB/s ± 0%   16.0GB/s ± 1%  +48.19%        (p=0.000 n=19+20)
      IndexBytePortable32-6    436MB/s ± 5%    422MB/s ± 3%   -3.27%        (p=0.000 n=20+19)
      IndexBytePortable4K-6    795MB/s ± 0%    795MB/s ± 0%     ~           (p=0.940 n=17+18)
      IndexBytePortable4M-6    798MB/s ± 0%    799MB/s ± 0%   +0.12%        (p=0.000 n=20+18)
      IndexBytePortable64M-6   798MB/s ± 0%    798MB/s ± 0%   +0.08%        (p=0.011 n=18+20)
      Index32-6               90.9MB/s ± 0%   90.9MB/s ± 0%   -0.00%        (p=0.025 n=20+20)
      Index4K-6               76.1MB/s ± 0%   76.1MB/s ± 0%   +0.03%        (p=0.000 n=14+15)
      Index4M-6               75.7MB/s ± 0%   75.7MB/s ± 0%     ~           (p=0.076 n=20+19)
      Index64M-6              75.7MB/s ± 0%   75.7MB/s ± 0%     ~           (p=0.456 n=20+17)
      IndexEasy32-6            399MB/s ± 0%    399MB/s ± 0%   +0.20%        (p=0.000 n=20+19)
      IndexEasy4K-6           9.60GB/s ± 0%  19.02GB/s ± 0%  +98.19%        (p=0.000 n=20+20)
      IndexEasy4M-6           10.8GB/s ± 0%   16.0GB/s ± 1%  +47.98%        (p=0.000 n=18+20)
      IndexEasy64M-6          10.8GB/s ± 0%   16.0GB/s ± 1%  +48.08%        (p=0.000 n=18+20)
      
      Change-Id: I46075921dde9f3580a89544c0b3a2d8c9181ebc4
      Reviewed-on: https://go-review.googlesource.com/16484Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      Reviewed-by: 's avatarKlaus Post <klauspost@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      321a4072
    • Keith Randall's avatar
      runtime: teach peephole optimizer that duffcopy clobbers X0 · ffb20631
      Keith Randall authored
      Duffcopy now uses X0, as of 5cf281a9.  Teach the peephole
      optimizer that duffcopy clobbers X0 so that it does not
      rename registers use X0 across the duffcopy instruction.
      
      Fixes #13171
      
      Change-Id: I389cbf1982cb6eb2f51e6152ac96736a8589f085
      Reviewed-on: https://go-review.googlesource.com/16715
      Run-TryBot: Keith Randall <khr@golang.org>
      Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      Reviewed-by: 's avatarIlya Tocar <ilya.tocar@intel.com>
      ffb20631
    • Marcel van Lohuizen's avatar
      doc: updated go1.6 with reflect change for unexported embedded structs · 59bac0be
      Marcel van Lohuizen authored
      Change-Id: I53c196925fb86784b31dea799c27e79574d35fcc
      Reviewed-on: https://go-review.googlesource.com/16304Reviewed-by: 's avatarMarcel van Lohuizen <mpvl@golang.org>
      59bac0be
    • Keith Randall's avatar
      Revert "runtime: simplify buffered channels." · e9f90ba2
      Keith Randall authored
      Revert for now until #13169 is understood.
      
      This reverts commit 8e496f1d.
      
      Change-Id: Ib3eb2588824ef47a2b6eb9e377a24e5c817fcc81
      Reviewed-on: https://go-review.googlesource.com/16716Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      e9f90ba2
    • Ian Lance Taylor's avatar
      cmd/link: don't warn about unnamed symbols in .debug_str section · 26263354
      Ian Lance Taylor authored
      They reportedly occur with LLVM 3.7 on FreeBSD ARM.
      
      Fixes #13139.
      
      Change-Id: Ia7d053a8662696b1984e81fbd1d908c951c35a98
      Reviewed-on: https://go-review.googlesource.com/16667
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      26263354
    • Joe Tsai's avatar
      archive/tar: detect truncated files · e3b615fd
      Joe Tsai authored
      Motivation:
      * Reader.skipUnread never reports io.ErrUnexpectedEOF. This is strange
      given that io.ErrUnexpectedEOF is given through Reader.Read if the
      user manually reads the file.
      * Reader.skipUnread fails to detect truncated files since io.Seeker
      is lazy about reporting errors. Thus, the behavior of Reader differs
      whether the input io.Reader also satisfies io.Seeker or not.
      
      To solve this, we seek to one before the end of the data section and
      always rely on at least one call to io.CopyN. If the tr.r satisfies
      io.Seeker, this is guarunteed to never read more than blockSize.
      
      Fixes #12557
      
      Change-Id: I0ddddfc6bed0d74465cb7e7a02b26f1de7a7a279
      Reviewed-on: https://go-review.googlesource.com/15175Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      e3b615fd
  2. 05 Nov, 2015 23 commits
    • David du Colombier's avatar
      cmd/go: skip TestBuildOutputToDevNull on Plan 9 · 6083bd65
      David du Colombier authored
      TestBuildOutputToDevNull was added in CL 16585.
      However, copying to /dev/null couldn't work on Plan 9,
      because /dev/null is a regular file. Since it's not
      different from any other file, the logic in copyFile
      couldn't distinguish it from another, already existing,
      file, that we wouldn't want to overwrite.
      
      Change-Id: Ie8d353f318fedfc7cfb9541fed00a2397e232592
      Reviewed-on: https://go-review.googlesource.com/16691Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: David du Colombier <0intro@gmail.com>
      6083bd65
    • Michael Hudson-Doyle's avatar
      cmd/internal/obj/ppc64: fix assembly of SRADCC with immediate · 10c07537
      Michael Hudson-Doyle authored
      sradi and sradi. hide the top bit of their immediate argument apart from the
      rest of it, but the code only handled the sradi case.
      
      I'm pretty sure this is the only instruction missing (a couple of the rotate
      instructions encode their immediate the same way but their handling looks OK).
      
      This fixes the failure of "GOARCH=amd64 ~/go/bin/go install -v runtime" as
      reported in the bug.
      
      Fixes #11987
      
      Change-Id: I0cdefcd7a04e0e8fce45827e7054ffde9a83f589
      Reviewed-on: https://go-review.googlesource.com/16710Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      10c07537
    • David du Colombier's avatar
      cmd/go: skip TestGoGenerateEnv on Plan 9 · b4447a1e
      David du Colombier authored
      TestGoGenerateEnv was added in CL 16537.
      However, Plan 9 doesn't have the env command.
      
      Change-Id: I5f0c937a1b9b456dcea41ceac7865112f2f65c45
      Reviewed-on: https://go-review.googlesource.com/16690Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: David du Colombier <0intro@gmail.com>
      b4447a1e
    • Austin Clements's avatar
      runtime: remove background GC goroutine and mark barriers · d5ba5821
      Austin Clements authored
      These are now unused.
      
      Updates #11970.
      
      Change-Id: I43e5c4e5bcda9581bacc63364f96bb4855ab779f
      Reviewed-on: https://go-review.googlesource.com/16393Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d5ba5821
    • Austin Clements's avatar
      runtime: remove GC start up/shutdown workaround in mallocgc · bbf2da00
      Austin Clements authored
      Currently mallocgc detects if the GC is in a state where it can't
      assist, but also can't allocate uncontrolled and yields to help out
      the GC. This was a workaround for periods when we were trying to
      schedule the GC coordinator. It is no longer necessary because there
      is no GC coordinator and malloc can always assist with any GC
      transitions that are necessary.
      
      Updates #11970.
      
      Change-Id: I4f7beb7013e85e50ae99a3a8b0bb708ba49cbcd4
      Reviewed-on: https://go-review.googlesource.com/16392Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      bbf2da00
    • Austin Clements's avatar
      runtime: decentralize mark done and mark termination · c99d7f7f
      Austin Clements authored
      This moves all of the mark 1 to mark 2 transition and mark termination
      to the mark done transition function. This means these transitions are
      now handled on the goroutine that detected mark completion. This also
      means that the GC coordinator and the background completion barriers
      are no longer used and various workarounds to yield to the coordinator
      are no longer necessary. These will be removed in follow-up commits.
      
      One consequence of this is that mark workers now need to be
      preemptible when performing the mark done transition. This allows them
      to stop the world and to perform the final clean-up steps of GC after
      restarting the world. They are only made preemptible while performing
      this transition, so if the worker findRunnableGCWorker would schedule
      isn't available, we didn't want to schedule it anyway.
      
      Fixes #11970.
      
      Change-Id: I9203a2d6287eeff62d589ec02ad9cb1e29ddb837
      Reviewed-on: https://go-review.googlesource.com/16391Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c99d7f7f
    • Austin Clements's avatar
      runtime: account mark worker time before gcMarkDone · d986bf27
      Austin Clements authored
      Currently gcMarkDone takes basically no time, so it's okay to account
      the worker time after calling it. However, gcMarkDone is about to take
      potentially *much* longer because it may perform all of mark
      termination. Prepare for this by swapping the order so we account the
      time before calling gcMarkDone.
      
      Change-Id: I90c7df68192acfc4fd02a7254dae739dda4e2fcb
      Reviewed-on: https://go-review.googlesource.com/16390Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d986bf27
    • Austin Clements's avatar
      runtime: factor mark done transition · 171204b5
      Austin Clements authored
      Currently the code for completion of mark 1/mark 2 is duplicated in
      background workers and assists. Factor this in to a single function
      that will serve as the transition function for concurrent mark.
      
      Change-Id: I4d9f697a15da0d349db3b34d56f3a220dd41d41b
      Reviewed-on: https://go-review.googlesource.com/16359Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      171204b5
    • Austin Clements's avatar
      runtime: eliminate mark completion in scheduler · 12e23f05
      Austin Clements authored
      Currently, findRunnableGCWorker will perform mark completion if there
      is no remaining work and no running workers. This used to be necessary
      to resolve a race in the transition from mark 1 to mark 2 where we
      would enter mark 2 with no mark work (and no dedicated workers), so no
      workers would run, so no worker would signal mark completion.
      
      However, we're about to make mark completion also perform the entire
      follow-on process, which includes mark termination. We really don't
      want to do that in the scheduler if it happens to detect completion.
      
      Conveniently, this hack is no longer necessary because we always
      enqueue root scanning work at the beginning of both mark 1 and mark 2,
      so a mark worker will always run. Hence, we can simply eliminate it.
      
      Change-Id: I3fc8f27c8da632f0fb732c9f6425e1f457f5652e
      Reviewed-on: https://go-review.googlesource.com/16358Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      12e23f05
    • Austin Clements's avatar
      runtime: don't start idle mark workers when barriers are cleared · 20f276e2
      Austin Clements authored
      Currently, we don't start dedicated or fractional mark workers unless
      the mark 1 or mark 2 barriers have been cleared. One intended
      consequence of this is that no background workers run between the
      forEachP that disposes all gcWork caches and the beginning of mark 2.
      
      However, we (unintentionally) did not apply this restriction to idle
      mark workers. As a result, these can start in the interim between mark
      1 completion and mark 2 starting. This explains why it was necessary
      to reset the root marking jobs using carefully ordered atomic writes
      when setting up mark 2. It also means that, even though we definitely
      enqueue work before starting mark 2, it may be drained by the time we
      reset the mark 2 barrier. If this happens, currently the only thing
      preventing the runtime from deadlocking is that the scheduler itself
      also checks for mark completion and will signal mark 2 completion.
      Were it not for the odd behavior of idle workers, this check in the
      scheduler would not be necessary.
      
      Clean all of this up and prepare to remove this check in the scheduler
      by applying the same restriction to starting idle mark workers.
      
      Change-Id: Ic1b479e1591bd7773dc27b320ca399a215603b5a
      Reviewed-on: https://go-review.googlesource.com/16631Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      20f276e2
    • Austin Clements's avatar
      runtime: decentralize sweep termination and mark transition · a51905fa
      Austin Clements authored
      This moves all of GC initialization, sweep termination, and the
      transition to concurrent marking in to the off->mark transition
      function. This means it's now handled on the goroutine that detected
      the state exit condition.
      
      As a result, malloc no longer needs to Gosched() at the beginning of
      the GC cycle to prevent over-allocation while the GC is starting up
      because it will now *help* the GC to start up. The Gosched hack is
      still necessary during GC shutdown (this is easy to test by enabling
      gctrace and hitting Ctrl-S to block the gctrace output).
      
      At this point, the GC coordinator still handles later phases. This
      requires a small tweak to how we start the GC coordinator. Currently,
      starting the GC coordinator is best-effort and may fail if the
      coordinator is about to park from the previous cycle but hasn't yet.
      We fix this by replacing the park/ready to wake up the coordinator
      with a semaphore. This is temporary since the coordinator will be
      going away in a few commits.
      
      Updates #11970.
      
      Change-Id: I2c6a11c91e72dfbc59c2d8e7c66146dee9a444fe
      Reviewed-on: https://go-review.googlesource.com/16357Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      a51905fa
    • Austin Clements's avatar
      runtime: decentralize concurrent sweep termination · 9630c47e
      Austin Clements authored
      This moves concurrent sweep termination from the coordinator to the
      off->mark transition. This allows it to be performed by all Gs
      attempting to start the GC.
      
      Updates #11970.
      
      Change-Id: I24428e8599a759398c2ef7ec996ba755a448f947
      Reviewed-on: https://go-review.googlesource.com/16356Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      9630c47e
    • Austin Clements's avatar
      runtime: beginning of decentralized off->mark transition · f54bcedc
      Austin Clements authored
      This begins the conversion of the centralized GC coordinator to a
      decentralized state machine by introducing the internal API that
      triggers the first state transition from _GCoff to _GCmark (or
      _GCmarktermination).
      
      This change introduces the transition lock, the off->mark transition
      condition (which is very similar to shouldtriggergc()), and the
      general structure of a state transition. Since we're doing this
      conversion in stages, it then falls back to the GC coordinator to
      actually execute the cycle. We'll start moving logic out of the GC
      coordinator and in to transition functions next.
      
      This fixes a minor bug in gcstoptheworld debug mode where passing the
      heap trigger once could trigger multiple STW GCs.
      
      Updates #11970.
      
      Change-Id: I964087dd190a639eb5766398f8e1bbf8b352902f
      Reviewed-on: https://go-review.googlesource.com/16355Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      f54bcedc
    • Austin Clements's avatar
      runtime: move concurrent mark setup off system stack · 38425962
      Austin Clements authored
      For historical reasons we currently do a lot of the concurrent mark
      setup on the system stack. In fact, at this point the one and only
      thing that needs to happen on the system stack is the start-the-world.
      
      Clean up this code by lifting everything other than the
      start-the-world off the system stack.
      
      The diff for this change looks large, but the only code change is to
      narrow the systemstack call. Everything else is re-indentation.
      
      Change-Id: I1e03b8afc759fad726f2397b05a17d183c2713ce
      Reviewed-on: https://go-review.googlesource.com/16354Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      38425962
    • Austin Clements's avatar
      runtime: lift state variables from func gc to var work · 19596215
      Austin Clements authored
      We're about to split func gc across several functions, so lift the
      local variables it uses for tracking statistics and state across the
      cycle into the global "work" variable.
      
      Change-Id: Ie955f2f1758c7f5a5543ea1f3f33b222bc4b1d37
      Reviewed-on: https://go-review.googlesource.com/16353Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      19596215
    • Austin Clements's avatar
      runtime: note a minor issue with GODEUG=gcstoptheworld · 16980189
      Austin Clements authored
      Change-Id: I91cda8d88b0852cd0f868d33c594206bcca0c386
      Reviewed-on: https://go-review.googlesource.com/16352Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      16980189
    • Ian Lance Taylor's avatar
      cmd/go: change ar argument to rc · 321cf6f8
      Ian Lance Taylor authored
      Put 'r' first because that is the command, and 'c' is the modifier.
      Keep 'c' because it means to not warn when creating an archive.
      Drop 'u' because it is unnecessary and fails on Arch Linux.
      
      No test because this is only for gccgo (I tested it manually).
      
      Fixes #12310.
      
      Change-Id: Id740257fb1c347dfaa60f7d613af2897dae2c059
      Reviewed-on: https://go-review.googlesource.com/16664
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
      321cf6f8
    • Ilya Tocar's avatar
      runtime: optimize string comparison on amd64 · 967564be
      Ilya Tocar authored
      Use AVX2 if possible.
      Results below (haswell):
      
      name                            old time/op    new time/op     delta
      CompareStringEqual-6              8.77ns ± 0%     8.63ns ± 1%   -1.58%        (p=0.000 n=20+19)
      CompareStringIdentical-6          5.02ns ± 0%     5.02ns ± 0%     ~     (all samples are equal)
      CompareStringSameLength-6         7.51ns ± 0%     7.51ns ± 0%     ~     (all samples are equal)
      CompareStringDifferentLength-6    1.56ns ± 0%     1.56ns ± 0%     ~     (all samples are equal)
      CompareStringBigUnaligned-6        124µs ± 1%      105µs ± 5%  -14.99%        (p=0.000 n=20+18)
      CompareStringBig-6                 112µs ± 1%      103µs ± 0%   -7.87%        (p=0.000 n=20+17)
      
      name                            old speed      new speed       delta
      CompareStringBigUnaligned-6     8.48GB/s ± 1%   9.98GB/s ± 5%  +17.67%        (p=0.000 n=20+18)
      CompareStringBig-6              9.37GB/s ± 1%  10.17GB/s ± 0%   +8.54%        (p=0.000 n=20+17)
      
      Change-Id: I1c949626dd2aaf9f633e3c888a9df71c82eed7e1
      Reviewed-on: https://go-review.googlesource.com/16481Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKlaus Post <klauspost@gmail.com>
      967564be
    • Keith Randall's avatar
      runtime: simplify buffered channels. · 8e496f1d
      Keith Randall authored
      This change removes the retry mechanism we use for buffered channels.
      Instead, any sender waking up a receiver or vice versa completes the
      full protocol with its counterpart.  This means the counterpart does
      not need to relock the channel when it wakes up.  (Currently
      buffered channels need to relock on wakeup.)
      
      For sends on a channel with waiting receivers, this change replaces
      two copies (sender->queue, queue->receiver) with one (sender->receiver).
      For receives on channels with a waiting sender, two copies are still required.
      
      This change unifies to a large degree the algorithm for buffered
      and unbuffered channels, simplifying the overall implementation.
      
      Fixes #11506
      
      benchmark                        old ns/op     new ns/op     delta
      BenchmarkChanProdCons10          125           110           -12.00%
      BenchmarkChanProdCons0           303           284           -6.27%
      BenchmarkChanProdCons100         75.5          71.3          -5.56%
      BenchmarkChanContended           6452          6125          -5.07%
      BenchmarkChanNonblocking         11.5          11.0          -4.35%
      BenchmarkChanCreation            149           143           -4.03%
      BenchmarkChanSem                 63.6          61.6          -3.14%
      BenchmarkChanUncontended         6390          6212          -2.79%
      BenchmarkChanSync                282           276           -2.13%
      BenchmarkChanProdConsWork10      516           506           -1.94%
      BenchmarkChanProdConsWork0       696           685           -1.58%
      BenchmarkChanProdConsWork100     470           469           -0.21%
      BenchmarkChanPopular             660427        660012        -0.06%
      
      Change-Id: I164113a56432fbc7cace0786e49c5a6e6a708ea4
      Reviewed-on: https://go-review.googlesource.com/9345
      Run-TryBot: Keith Randall <khr@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      Reviewed-by: 's avatarDmitry Vyukov <dvyukov@google.com>
      8e496f1d
    • Matthew Dempsky's avatar
      cmd/dist: remove vestigial -s flag · 7bb2a7d6
      Matthew Dempsky authored
      Fixes #12002.
      
      Change-Id: I7262f4520560ac158fc2ee3ce1d2f7a488d40354
      Reviewed-on: https://go-review.googlesource.com/16666
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      7bb2a7d6
    • Shenghou Ma's avatar
      crypto/x509: add /etc/ssl/certs to certificate directories · 61ca7e5c
      Shenghou Ma authored
      Fixes #12139.
      
      Change-Id: Ied760ac37e2fc21ef951ae872136dc3bfd49bf9f
      Reviewed-on: https://go-review.googlesource.com/16671Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      61ca7e5c
    • Ian Lance Taylor's avatar
      cmd/go: put all generate variables in the environment · 94968155
      Ian Lance Taylor authored
      Fixes #13124.
      
      Change-Id: I8a824156c84016504d29dc2dd2d522149b189be8
      Reviewed-on: https://go-review.googlesource.com/16537Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      94968155
    • Matthew Dempsky's avatar
      internal/syscall/unix: eliminate non-trivial randomTrap initializer · b16c6991
      Matthew Dempsky authored
      While here, enable getrandom on arm64 too (using the value found in
      include/uapi/asm-generic/unistd.h, which seems to match up with other
      GOARCH=arm64 syscall numbers).
      
      Updates #10848.
      
      Change-Id: I5ab36ccf6ee8d5cc6f0e1a61d09f0da7410288b9
      Reviewed-on: https://go-review.googlesource.com/16662
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      b16c6991
  3. 04 Nov, 2015 11 commits
    • Austin Clements's avatar
      runtime: make putfull start mark workers · dcd9e5bc
      Austin Clements authored
      Currently we depend on the good graces and timing of the scheduler to
      get opportunities to start dedicated mark workers. In the worst case,
      it may take 10ms to get dedicated mark workers going at the beginning
      of mark 1 and mark 2 or after the amount of available work has dropped
      and gone back up.
      
      Instead of waiting for the regular preemption logic to get around to
      us, make putfull enlist a random P if we're not already running enough
      dedicated workers. This should improve performance stability of the
      garbage collector and is likely to improve the overall performance
      somewhat.
      
      No overall effect on the go1 benchmarks. It speeds up the garbage
      benchmark by 12%, which more than counters the performance loss from
      the previous commit.
      
      name              old time/op  new time/op  delta
      XBenchGarbage-12  6.32ms ± 4%  5.58ms ± 2%  -11.68%  (p=0.000 n=20+16)
      
      name                      old time/op    new time/op    delta
      BinaryTree17-12              3.18s ± 5%     3.12s ± 4%  -1.83%  (p=0.021 n=20+20)
      Fannkuch11-12                2.50s ± 2%     2.46s ± 2%  -1.57%  (p=0.000 n=18+19)
      FmtFprintfEmpty-12          50.8ns ± 3%    50.4ns ± 3%    ~     (p=0.184 n=20+20)
      FmtFprintfString-12          167ns ± 2%     171ns ± 1%  +2.46%  (p=0.000 n=20+19)
      FmtFprintfInt-12             161ns ± 2%     163ns ± 2%  +1.81%  (p=0.000 n=20+20)
      FmtFprintfIntInt-12          269ns ± 1%     266ns ± 1%  -0.81%  (p=0.002 n=19+20)
      FmtFprintfPrefixedInt-12     237ns ± 2%     231ns ± 2%  -2.86%  (p=0.000 n=20+20)
      FmtFprintfFloat-12           313ns ± 2%     313ns ± 1%    ~     (p=0.681 n=20+20)
      FmtManyArgs-12              1.05µs ± 2%    1.03µs ± 1%  -2.26%  (p=0.000 n=20+20)
      GobDecode-12                8.66ms ± 1%    8.67ms ± 1%    ~     (p=0.380 n=19+20)
      GobEncode-12                6.56ms ± 1%    6.56ms ± 2%    ~     (p=0.607 n=19+20)
      Gzip-12                      317ms ± 1%     314ms ± 2%  -1.10%  (p=0.000 n=20+19)
      Gunzip-12                   42.1ms ± 1%    42.2ms ± 1%  +0.27%  (p=0.044 n=20+19)
      HTTPClientServer-12         62.7µs ± 1%    62.0µs ± 1%  -1.04%  (p=0.000 n=19+18)
      JSONEncode-12               16.7ms ± 1%    16.8ms ± 2%  +0.59%  (p=0.021 n=20+20)
      JSONDecode-12               58.2ms ± 1%    61.4ms ± 2%  +5.43%  (p=0.000 n=18+19)
      Mandelbrot200-12            3.84ms ± 1%    3.87ms ± 2%  +0.79%  (p=0.008 n=18+20)
      GoParse-12                  3.86ms ± 2%    3.76ms ± 2%  -2.60%  (p=0.000 n=20+20)
      RegexpMatchEasy0_32-12       100ns ± 2%     100ns ± 1%  -0.68%  (p=0.005 n=18+15)
      RegexpMatchEasy0_1K-12       332ns ± 1%     342ns ± 1%  +3.16%  (p=0.000 n=19+19)
      RegexpMatchEasy1_32-12      82.9ns ± 3%    83.0ns ± 2%    ~     (p=0.906 n=19+20)
      RegexpMatchEasy1_1K-12       487ns ± 1%     494ns ± 1%  +1.50%  (p=0.000 n=17+20)
      RegexpMatchMedium_32-12      131ns ± 2%     130ns ± 1%    ~     (p=0.686 n=19+20)
      RegexpMatchMedium_1K-12     39.6µs ± 1%    39.2µs ± 1%  -1.09%  (p=0.000 n=18+19)
      RegexpMatchHard_32-12       2.04µs ± 1%    2.04µs ± 2%    ~     (p=0.804 n=20+20)
      RegexpMatchHard_1K-12       61.7µs ± 2%    61.3µs ± 2%    ~     (p=0.052 n=18+20)
      Revcomp-12                   529ms ± 2%     533ms ± 1%  +0.83%  (p=0.003 n=20+19)
      Template-12                 70.7ms ± 2%    71.0ms ± 2%    ~     (p=0.065 n=20+19)
      TimeParse-12                 351ns ± 2%     355ns ± 1%  +1.25%  (p=0.000 n=19+20)
      TimeFormat-12                362ns ± 2%     373ns ± 1%  +2.83%  (p=0.000 n=18+20)
      [Geo mean]                  62.2µs         62.3µs       +0.13%
      
      name                      old speed      new speed      delta
      GobDecode-12              88.6MB/s ± 1%  88.5MB/s ± 1%    ~     (p=0.392 n=19+20)
      GobEncode-12               117MB/s ± 1%   117MB/s ± 1%    ~     (p=0.622 n=19+20)
      Gzip-12                   61.1MB/s ± 1%  61.8MB/s ± 2%  +1.11%  (p=0.000 n=20+19)
      Gunzip-12                  461MB/s ± 1%   460MB/s ± 1%  -0.27%  (p=0.044 n=20+19)
      JSONEncode-12              116MB/s ± 1%   115MB/s ± 2%  -0.58%  (p=0.022 n=20+20)
      JSONDecode-12             33.3MB/s ± 1%  31.6MB/s ± 2%  -5.15%  (p=0.000 n=18+19)
      GoParse-12                15.0MB/s ± 2%  15.4MB/s ± 2%  +2.66%  (p=0.000 n=20+20)
      RegexpMatchEasy0_32-12     317MB/s ± 2%   319MB/s ± 2%    ~     (p=0.052 n=20+20)
      RegexpMatchEasy0_1K-12    3.08GB/s ± 1%  2.99GB/s ± 1%  -3.07%  (p=0.000 n=19+19)
      RegexpMatchEasy1_32-12     386MB/s ± 3%   386MB/s ± 2%    ~     (p=0.939 n=19+20)
      RegexpMatchEasy1_1K-12    2.10GB/s ± 1%  2.07GB/s ± 1%  -1.46%  (p=0.000 n=17+20)
      RegexpMatchMedium_32-12   7.62MB/s ± 2%  7.64MB/s ± 1%    ~     (p=0.702 n=19+20)
      RegexpMatchMedium_1K-12   25.9MB/s ± 1%  26.1MB/s ± 2%  +0.99%  (p=0.000 n=18+20)
      RegexpMatchHard_32-12     15.7MB/s ± 1%  15.7MB/s ± 2%    ~     (p=0.723 n=20+20)
      RegexpMatchHard_1K-12     16.6MB/s ± 2%  16.7MB/s ± 2%    ~     (p=0.052 n=18+20)
      Revcomp-12                 481MB/s ± 2%   477MB/s ± 1%  -0.83%  (p=0.003 n=20+19)
      Template-12               27.5MB/s ± 2%  27.3MB/s ± 2%    ~     (p=0.062 n=20+19)
      [Geo mean]                99.4MB/s       99.1MB/s       -0.35%
      
      Change-Id: I914d8cadded5a230509d118164a4c201601afc06
      Reviewed-on: https://go-review.googlesource.com/16298Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      dcd9e5bc
    • Austin Clements's avatar
      runtime: eliminate getfull barrier from concurrent mark · 62ba520b
      Austin Clements authored
      Currently dedicated mark workers participate in the getfull barrier
      during concurrent mark. However, the getfull barrier wasn't designed
      for concurrent work and this causes no end of headaches.
      
      In the concurrent setting, participants come and go. This makes mark
      completion susceptible to live-lock: since dedicated workers are only
      periodically polling for completion, it's possible for the program to
      be in some transient worker each time one of the dedicated workers
      wakes up to check if it can exit the getfull barrier. It also
      complicates reasoning about the system because dedicated workers
      participate directly in the getfull barrier, but transient workers
      must instead use trygetfull because they have exit conditions that
      aren't captured by getfull (e.g., fractional workers exit when
      preempted). The complexity of implementing these exit conditions
      contributed to #11677. Furthermore, the getfull barrier is inefficient
      because we could be running user code instead of spinning on a P. In
      effect, we're dedicating 25% of the CPU to marking even if that means
      we have to spin to make that 25%. It also causes issues on Windows
      because we can't actually sleep for 100µs (#8687).
      
      Fix this by making dedicated workers no longer participate in the
      getfull barrier. Instead, dedicated workers simply return to the
      scheduler when they fail to get more work, regardless of what others
      workers are doing, and the scheduler only starts new dedicated workers
      if there's work available. Everything that needs to be handled by this
      barrier is already handled by detection of mark completion.
      
      This makes the system much more symmetric because all workers and
      assists now use trygetfull during concurrent mark. It also loosens the
      25% CPU target so that we can give some of that 25% back to user code
      if there isn't enough work to keep the mark worker busy. And it
      eliminates the problematic 100µs sleep on Windows during concurrent
      mark (though not during mark termination).
      
      The downside of this is that if we hit a bottleneck in the heap graph
      that then expands back out, the system may shut down dedicated workers
      and take a while to start them back up. We'll address this in the next
      commit.
      
      Updates #12041 and #8687.
      
      No effect on the go1 benchmarks. This slows down the garbage benchmark
      by 9%, but we'll more than make it up in the next commit.
      
      name              old time/op  new time/op  delta
      XBenchGarbage-12  5.80ms ± 2%  6.32ms ± 4%  +9.03%  (p=0.000 n=20+20)
      
      Change-Id: I65100a9ba005a8b5cf97940798918672ea9dd09b
      Reviewed-on: https://go-review.googlesource.com/16297Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      62ba520b
    • David Crawshaw's avatar
      misc/ios: keep whole buffer in go_darwin_arm_exec · afab7716
      David Crawshaw authored
      The existing go_darwin_arm_exec.go script does not work with Xcode 7,
      not due to any significant changes, but just ordering and timing of
      statements from lldb. Unfortunately the current design of
      go_darwin_arm_exec.go makes it not obvious what gets stuck where, so
      this moves from a moving buffer window to a complete buffer of the
      lldb output.
      
      The result is easier code to follow, and it works with Xcode 7.
      
      Updates #12660.
      
      Change-Id: I3b8b890b0bf4474119482e95d84e821a86d1eaed
      Reviewed-on: https://go-review.googlesource.com/16634Reviewed-by: 's avatarMichael Matloob <matloob@golang.org>
      afab7716
    • Brad Fitzpatrick's avatar
      net/http: register HTTP/2 before listening in ListenAndServe · e50a4c69
      Brad Fitzpatrick authored
      Change-Id: Icf9b6802945051aa484fb9ebcce71704f5655474
      Reviewed-on: https://go-review.googlesource.com/16630Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      e50a4c69
    • Brad Fitzpatrick's avatar
      syscall: allow nacl's fake network code to Listen twice on the same address · 8ee90fad
      Brad Fitzpatrick authored
      Noticed from nacl trybot failures on new tests in
      https://golang.org/cl/16630
      
      Related earlier fix of mine to nacl's listen code:
      
        syscall: fix nacl listener to not accept connections once closed
        https://go-review.googlesource.com/15940
      
      Perhaps a better fix (in the future?) would be to remove the listener
      from the map at close, but that didn't seem entirely straightforward
      last time I looked into it. It's not my code, but it seems that the
      map entry continues to have a purpose even after Listener close. (?)
      
      But given that this code is only really used for running tests and the
      playground, this seems fine.
      
      Change-Id: I43bfedc57c07f215f4d79c18f588d3650687a48f
      Reviewed-on: https://go-review.googlesource.com/16650
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      8ee90fad
    • David Crawshaw's avatar
      cmd/vet: use testenv · dc9ad586
      David Crawshaw authored
      Fix for iOS builder.
      
      Change-Id: I5b6c977b187446c848182a9294d5bed6b5f9f6e4
      Reviewed-on: https://go-review.googlesource.com/16633
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      Reviewed-by: 's avatarHyang-Ah Hana Kim <hyangah@gmail.com>
      dc9ad586
    • unknown's avatar
      crypto/md5: uniform Write func · 8c827c04
      unknown authored
      Unification of implementation of existing md5.Write function
      with other implementations (sha1, sha256, sha512).
      
      Change-Id: I58ae02d165b17fc221953a5b4b986048b46c0508
      Reviewed-on: https://go-review.googlesource.com/16621Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      8c827c04
    • Mohit Agarwal's avatar
      cmd/go: check if destination is a regular file · 76811213
      Mohit Agarwal authored
      builder.copyFile ensures that the destination is an object file.  This
      wouldn't be true if we are not writing to a regular file and the copy
      fails.  Check if the destination is an object file only if we are
      writing to a regular file.  While removing the file, ensure that it is a
      regular file so that device files and such aren't removed when running
      as a user with suggicient privileges.
      
      Fixes #12407
      
      Change-Id: Ie86ce9770fa59aa56fc486a5962287859b69db3d
      Reviewed-on: https://go-review.googlesource.com/16585Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      76811213
    • Austin Clements's avatar
      cmd/compile: add go:nowritebarrierrec annotation · 3a765430
      Austin Clements authored
      This introduces a recursive variant of the go:nowritebarrier
      annotation that prohibits write barriers not only in the annotated
      function, but in all functions it calls, recursively. The error
      message gives the shortest call stack from the annotated function to
      the function containing the prohibited write barrier, including the
      names of the functions and the line numbers of the calls.
      
      To demonstrate the annotation, we apply it to gcmarkwb_m, the write
      barrier itself.
      
      This is a new annotation rather than a modification of the existing
      go:nowritebarrier annotation because, for better or worse, there are
      many go:nowritebarrier functions that do call functions with write
      barriers. In most of these cases this is benign because the annotation
      was conservative, but it prohibits simply coopting the existing
      annotation.
      
      Change-Id: I225ca483c8f699e8436373ed96349e80ca2c2479
      Reviewed-on: https://go-review.googlesource.com/16554Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      3a765430
    • Ian Lance Taylor's avatar
      cmd/cgo: add a missing newline in writeExports · 2780abd6
      Ian Lance Taylor authored
      The code works without the newline, but it looks funny:
      
      func _cgoexp_15afe6549f62_GoFn(a unsafe.Pointer, n int32) {	fn := GoFn
      
      This adds a newline after the '{'.
      
      Change-Id: I6c465abe16f47924426d1b22b91004b3a3586ebd
      Reviewed-on: https://go-review.googlesource.com/16612
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarMinux Ma <minux@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2780abd6
    • Brad Fitzpatrick's avatar
      net/http: don't panic after request if Handler sets Request.Body to nil · b1050542
      Brad Fitzpatrick authored
      The Server's server goroutine was panicing (but recovering) when
      cleaning up after handling a request. It was pretty harmless (it just
      closed that one connection and didn't kill the whole process) but it
      was distracting.
      
      Updates #13135
      
      Change-Id: I2a0ce9e8b52c8d364e3f4ce245e05c6f8d62df14
      Reviewed-on: https://go-review.googlesource.com/16572
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
      b1050542