1. 11 Sep, 2014 7 commits
    • Russ Cox's avatar
      runtime: move gosched to Go, to add stack frame information · 15a5c35c
      Russ Cox authored
      LGTM=khr
      R=khr
      CC=golang-codereviews
      https://golang.org/cl/134520044
      15a5c35c
    • Robert Griesemer's avatar
      go/printer, gofmt: don't align map entries for irregular inputs · 724fa12f
      Robert Griesemer authored
      Details: Until now, when we saw a key:value pair that fit onto
      a single line, we assumed that it should be formatted with a
      vtab after the ':' for alignment of its value. This leads to
      odd behavior if there are more than one such pair on a line.
      This CL changes the behavior such that alignment is only used
      for the first pair on a line. This preserves existing behavior
      (in the std lib we have composite literals where the last line
      contains multiple entries and the first entry's value is aligned
      with the values on previous lines), and resolves this issue.
      
      No impact on formatting of std lib, go.tools, go.exp, go.net.
      
      Fixes #8685.
      
      LGTM=adonovan
      R=adonovan
      CC=golang-codereviews
      https://golang.org/cl/139430043
      724fa12f
    • Josh Bleecher Snyder's avatar
      test: return errors earlier in run.go · 8cc6cb2f
      Josh Bleecher Snyder authored
      Fixes #8184.
      
      LGTM=bradfitz
      R=bradfitz
      CC=golang-codereviews
      https://golang.org/cl/137510043
      8cc6cb2f
    • Russ Cox's avatar
      cmd/gc: emit write barriers · fcb4cabb
      Russ Cox authored
      A write *p = x that needs a write barrier (not all do)
      now turns into runtime.writebarrierptr(p, x)
      or one of the other variants.
      
      The write barrier implementations are trivial.
      The goal here is to emit the calls in the correct places
      and to incur the cost of those function calls in the Go 1.4 cycle.
      
      Performance on the Go 1 benchmark suite below.
      Remember, the goal is to slow things down (and be correct).
      
      We will look into optimizations in separate CLs, as part of
      the process of comparing Go 1.3 against tip in order to make
      sure Go 1.4 runs at least as fast as Go 1.3.
      
      benchmark                          old ns/op      new ns/op      delta
      BenchmarkBinaryTree17              3118336716     3452876110     +10.73%
      BenchmarkFannkuch11                3184497677     3211552284     +0.85%
      BenchmarkFmtFprintfEmpty           89.9           107            +19.02%
      BenchmarkFmtFprintfString          236            287            +21.61%
      BenchmarkFmtFprintfInt             246            278            +13.01%
      BenchmarkFmtFprintfIntInt          395            458            +15.95%
      BenchmarkFmtFprintfPrefixedInt     343            378            +10.20%
      BenchmarkFmtFprintfFloat           477            525            +10.06%
      BenchmarkFmtManyArgs               1446           1707           +18.05%
      BenchmarkGobDecode                 14398047       14685958       +2.00%
      BenchmarkGobEncode                 12557718       12947104       +3.10%
      BenchmarkGzip                      453462345      472413285      +4.18%
      BenchmarkGunzip                    114226016      115127398      +0.79%
      BenchmarkHTTPClientServer          114689         112122         -2.24%
      BenchmarkJSONEncode                24914536       26135942       +4.90%
      BenchmarkJSONDecode                86832877       103620289      +19.33%
      BenchmarkMandelbrot200             4833452        4898780        +1.35%
      BenchmarkGoParse                   4317976        4835474        +11.98%
      BenchmarkRegexpMatchEasy0_32       150            166            +10.67%
      BenchmarkRegexpMatchEasy0_1K       393            402            +2.29%
      BenchmarkRegexpMatchEasy1_32       125            142            +13.60%
      BenchmarkRegexpMatchEasy1_1K       1010           1236           +22.38%
      BenchmarkRegexpMatchMedium_32      232            301            +29.74%
      BenchmarkRegexpMatchMedium_1K      76963          102721         +33.47%
      BenchmarkRegexpMatchHard_32        3833           5463           +42.53%
      BenchmarkRegexpMatchHard_1K        119668         161614         +35.05%
      BenchmarkRevcomp                   763449047      706768534      -7.42%
      BenchmarkTemplate                  124954724      134834549      +7.91%
      BenchmarkTimeParse                 517            511            -1.16%
      BenchmarkTimeFormat                501            514            +2.59%
      
      benchmark                         old MB/s     new MB/s     speedup
      BenchmarkGobDecode                53.31        52.26        0.98x
      BenchmarkGobEncode                61.12        59.28        0.97x
      BenchmarkGzip                     42.79        41.08        0.96x
      BenchmarkGunzip                   169.88       168.55       0.99x
      BenchmarkJSONEncode               77.89        74.25        0.95x
      BenchmarkJSONDecode               22.35        18.73        0.84x
      BenchmarkGoParse                  13.41        11.98        0.89x
      BenchmarkRegexpMatchEasy0_32      213.30       191.72       0.90x
      BenchmarkRegexpMatchEasy0_1K      2603.92      2542.74      0.98x
      BenchmarkRegexpMatchEasy1_32      254.00       224.93       0.89x
      BenchmarkRegexpMatchEasy1_1K      1013.53      827.98       0.82x
      BenchmarkRegexpMatchMedium_32     4.30         3.31         0.77x
      BenchmarkRegexpMatchMedium_1K     13.30        9.97         0.75x
      BenchmarkRegexpMatchHard_32       8.35         5.86         0.70x
      BenchmarkRegexpMatchHard_1K       8.56         6.34         0.74x
      BenchmarkRevcomp                  332.92       359.62       1.08x
      BenchmarkTemplate                 15.53        14.39        0.93x
      
      LGTM=rlh
      R=rlh
      CC=dvyukov, golang-codereviews, iant, khr, r
      https://golang.org/cl/136380043
      fcb4cabb
    • Russ Cox's avatar
      runtime: allow crash from gsignal stack · 1d550b87
      Russ Cox authored
      The uses of onM in dopanic/startpanic are okay even from the signal stack.
      
      Fixes #8666.
      
      LGTM=khr
      R=khr
      CC=golang-codereviews
      https://golang.org/cl/134710043
      1d550b87
    • Mikio Hara's avatar
      net: fix inconsistent behavior across platforms in SetKeepAlivePeriod · f9567401
      Mikio Hara authored
      The previous implementation used per-socket TCP keepalive options
      wrong. For example, it used another level socket option to control
      TCP and it didn't use TCP_KEEPINTVL option when possible.
      
      Fixes #8683.
      Fixes #8701.
      Update #8679
      
      LGTM=iant
      R=golang-codereviews, iant
      CC=golang-codereviews
      https://golang.org/cl/136480043
      f9567401
    • Keith Randall's avatar
      runtime: add timing test for iterate/delete map idiom. · 689dc60c
      Keith Randall authored
      LGTM=bradfitz, iant
      R=iant, bradfitz
      CC=golang-codereviews
      https://golang.org/cl/140510043
      689dc60c
  2. 10 Sep, 2014 4 commits
    • Keith Randall's avatar
      reflect: use runtime's memmove instead of its own · b78d7b75
      Keith Randall authored
      They will both need write barriers at some point.
      But until then, no reason why we shouldn't share.
      
      LGTM=rsc
      R=golang-codereviews, rsc
      CC=golang-codereviews
      https://golang.org/cl/141330043
      b78d7b75
    • Anthony Martin's avatar
      runtime: stop plan9/amd64 build from crashing · 2302b21b
      Anthony Martin authored
      LGTM=iant
      R=rsc, 0intro, alex.brainman, iant
      CC=golang-codereviews
      https://golang.org/cl/140460044
      2302b21b
    • Matthew Dempsky's avatar
      runtime: cleanup openbsd semasleep implementation · d955dfb0
      Matthew Dempsky authored
      The previous implementation had several subtle issues.  It's not
      clear if any of these could actually be causing the flakiness
      problems on openbsd/386, but fixing them should only help.
      
      1. thrsleep() is implemented internally as unlock, then test *abort
      (if abort != nil), then tsleep().  Under the current code, that makes
      it theoretically possible that semasleep()/thrsleep() could release
      waitsemalock, then a racing semawakeup() could acquire the lock,
      increment waitsemacount, and call thrwakeup()/wakeup() before
      thrsleep() reaches tsleep().  (In practice, OpenBSD's big kernel lock
      seems unlikely to let this actually happen.)
      
      The proper way to avoid this is to pass &waitsemacount as the abort
      pointer to thrsleep so thrsleep knows to re-check it before going to
      sleep, and to wakeup if it's non-zero.  Then we avoid any races.
      (I actually suspect openbsd's sema{sleep,wakeup}() could be further
      simplified using cas/xadd instead of locks, but I don't want to be
      more intrusive than necessary so late in the 1.4 release cycle.)
      
      2. semasleep() takes a relative sleep duration, but thrsleep() needs
      an absolute sleep deadline.  Instead of recomputing the deadline each
      iteration, compute it once up front and use (*Timespec)(nil) to signify
      no deadline.  Ensures we retry properly if there's a spurious wakeup.
      
      3. Instead of assuming if thrsleep() woke up and waitsemacount wasn't
      available that we must have hit the deadline, check that the system
      call returned EWOULDBLOCK.
      
      4. Instead of assuming that 64-bit systems are little-endian, compute
      timediv() using a temporary int32 nsec and then assign it to tv_nsec.
      
      LGTM=iant
      R=jsing, iant
      CC=golang-codereviews
      https://golang.org/cl/137960043
      d955dfb0
    • Anthony Martin's avatar
      runtime: call rfork on scheduler stack on Plan 9 · 9f012e10
      Anthony Martin authored
      A race exists between the parent and child processes after a fork.
      The child needs to access the new M pointer passed as an argument
      but the parent may have already returned and clobbered it.
      
      Previously, we avoided this by saving the necessary data into
      registers before the rfork system call but this isn't guaranteed
      to work because Plan 9 makes no promises about the register state
      after a system call. Only the 386 kernel seems to save them.
      For amd64 and arm, this method won't work.
      
      We eliminate the race by allocating stack space for the scheduler
      goroutines (g0) in the per-process copy-on-write stack segment and
      by only calling rfork on the scheduler stack.
      
      LGTM=aram, 0intro, rsc
      R=aram, 0intro, mischief, rsc
      CC=golang-codereviews
      https://golang.org/cl/110680044
      9f012e10
  3. 09 Sep, 2014 17 commits
  4. 08 Sep, 2014 12 commits
    • Andrew Gerrand's avatar
      A+C: John Olds (individual CLA) · 0133e0a2
      Andrew Gerrand authored
      Generated by a+c.
      
      LGTM=jtolds, jbd
      R=gobot, jbd, jtolds
      CC=golang-codereviews
      https://golang.org/cl/137300043
      0133e0a2
    • Keith Randall's avatar
      runtime: note the double-releasem isn't an error. · 1d88f9dd
      Keith Randall authored
      LGTM=bradfitz
      R=dave, bradfitz
      CC=golang-codereviews
      https://golang.org/cl/136390043
      1d88f9dd
    • Mikio Hara's avatar
      net: don't set wrong option for controlling tcp keepalive on openbsd · 1fadd9e1
      Mikio Hara authored
      Fixes #8679.
      
      LGTM=iant
      R=golang-codereviews, iant
      CC=golang-codereviews
      https://golang.org/cl/141730043
      1fadd9e1
    • Russ Cox's avatar
      runtime: turn off StackCopyAlways · 176020e1
      Russ Cox authored
      windows/amd64 failure:
      http://build.golang.org/log/1ded5e3ef4bd1226f976e3180772f87e6c918255
      
      # ..\misc\cgo\testso
      runtime: copystack: locals size info only for syscall.Syscall
      fatal error: split stack not allowed
      
      runtime stack:
      runtime.throw(0xa64cc7)
              c:/go/src/runtime/panic.go:395 +0xad fp=0x6fde0 sp=0x6fdb0
      runtime.newstack()
              c:/go/src/runtime/stack.c:1001 +0x750 fp=0x6ff20 sp=0x6fde0
      runtime.morestack()
              c:/go/src/runtime/asm_amd64.s:306 +0x73 fp=0x6ff28 sp=0x6ff20
      
      goroutine 1 [stack growth, locked to thread]:
      runtime.freedefer(0xc0820ce120)
              c:/go/src/runtime/panic.go:162 fp=0xc08201b1a0 sp=0xc08201b198
      runtime.deferreturn(0xa69420)
              c:/go/src/runtime/panic.go:211 +0xa8 fp=0xc08201b1e8 sp=0xc08201b1a0
      runtime.cgocall_errno(0x498c00, 0xc08201b228, 0x0)
              c:/go/src/runtime/cgocall.go:134 +0x10e fp=0xc08201b210 sp=0xc08201b1e8
      syscall.Syscall(0x7786b1d0, 0x2, 0xc0820c85b0, 0xc08201b2d8, 0x0, 0x0, 0x0, 0x0)
              c:/go/src/runtime/syscall_windows.c:74 +0x3c fp=0xc08201b260 sp=0xc08201b210
      syscall.findFirstFile1(0xc0820c85b0, 0xc08201b2d8, 0x500000000000000, 0x0, 0x0)
              c:/go/src/syscall/zsyscall_windows.go:340 +0x76 fp=0xc08201b2b0 sp=0xc08201b260
      syscall.FindFirstFile(0xc0820c85b0, 0xc08210c500, 0xc0820c85b0, 0x0, 0x0)
              c:/go/src/syscall/syscall_windows.go:907 +0x6a fp=0xc08201b530 sp=0xc08201b2b0
      os.openDir(0xc0820b2e40, 0x33, 0x0, 0x0, 0x0)
              c:/go/src/os/file_windows.go:96 +0x110 fp=0xc08201b5e0 sp=0xc08201b530
      os.OpenFile(0xc0820b2e40, 0x33, 0x0, 0x0, 0x41, 0x0, 0x0)
              c:/go/src/os/file_windows.go:143 +0x1e9 fp=0xc08201b650 sp=0xc08201b5e0
      
      TBR=khr
      CC=golang-codereviews
      https://golang.org/cl/138230043
      176020e1
    • Russ Cox's avatar
      runtime: mark endcgo go:nosplit · 5103500d
      Russ Cox authored
      Should help windows/amd64.
      
      TBR=khr
      CC=golang-codereviews
      https://golang.org/cl/134660043
      5103500d
    • Robert Griesemer's avatar
      go/parser: fix (pathological) corner case · ec96795b
      Robert Griesemer authored
      Inside a control clause (if ... {}), composite
      literals starting with a type name must be parenthesized.
      A composite literal used in the array length expression
      of an array composite literal is already parenthesized.
      Not a valid program, but syntactically is should
      be accepted.
      
      LGTM=adonovan
      R=adonovan
      CC=golang-codereviews
      https://golang.org/cl/142760043
      ec96795b
    • Russ Cox's avatar
      runtime: mark freedefer and deferclass go:nosplit · 857d55a3
      Russ Cox authored
      This should make deferreturn nosplit all the way down,
      which should fix the current windows/amd64 failure.
      If not, I will change StackCopyAlways back to 0.
      
      TBR=khr
      CC=golang-codereviews
      https://golang.org/cl/135600043
      857d55a3
    • Andrew Gerrand's avatar
      doc: amend installation instructions · dc089574
      Andrew Gerrand authored
      Fixes #8674.
      
      LGTM=r
      R=r
      CC=golang-codereviews
      https://golang.org/cl/139320044
      dc089574
    • Russ Cox's avatar
      runtime: enable StackCopyAlways · 31829428
      Russ Cox authored
      Let's see how close we are to this being ready.
      Will roll back if it breaks any builds in non-trivial ways.
      
      LGTM=r, khr
      R=iant, khr, r
      CC=golang-codereviews
      https://golang.org/cl/138200043
      31829428
    • Russ Cox's avatar
      runtime: undo stray edit from CL 140380043 · 9e7c2293
      Russ Cox authored
      Was having serious editor problems on Windows.
      
      TBR=brainman, iant
      CC=golang-codereviews
      https://golang.org/cl/137370043
      9e7c2293
    • Russ Cox's avatar
      syscall: keep allocated C string live across call to Syscall · cf622d75
      Russ Cox authored
      Given:
      
              p := alloc()
              fn_taking_ptr(p)
      
      p is NOT recorded as live at the call to fn_taking_ptr:
      it's not needed by the code following the call.
      p was passed to fn_taking_ptr, and fn_taking_ptr must keep
      it alive as long as it needs it.
      In practice, fn_taking_ptr will keep its own arguments live
      for as long as the function is executing.
      
      But if instead you have:
      
              p := alloc()
              i := uintptr(unsafe.Pointer(p))
              fn_taking_int(i)
      
      p is STILL NOT recorded as live at the call to fn_taking_int:
      it's not needed by the code following the call.
      fn_taking_int is responsible for keeping its own arguments
      live, but fn_taking_int is written to take an integer, so even
      though fn_taking_int does keep its argument live, that argument
      does not keep the allocated memory live, because the garbage
      collector does not dereference integers.
      
      The shorter form:
      
              p := alloc()
              fn_taking_int(uintptr(unsafe.Pointer(p)))
      
      and the even shorter form:
      
              fn_taking_int(uintptr(unsafe.Pointer(alloc())))
      
      are both the same as the 3-line form above.
      
      syscall.Syscall is like fn_taking_int: it is written to take a list
      of integers, and yet those integers are sometimes pointers.
      If there is no other copy of those pointers being kept live,
      the memory they point at may be garbage collected during
      the call to syscall.Syscall.
      
      This is happening on Solaris: for whatever reason, the timing
      is such that the garbage collector manages to free the string
      argument to the open(2) system call before the system call
      has been invoked.
      
      Change the system call wrappers to insert explicit references
      that will keep the allocations alive in the original frame
      (and therefore preserve the memory) until after syscall.Syscall
      has returned.
      
      Should fix Solaris flakiness.
      
      This is not a problem for cgo, because cgo wrappers have
      correctly typed arguments.
      
      LGTM=iant, khr, aram, rlh
      R=iant, khr, bradfitz, aram, rlh
      CC=dvyukov, golang-codereviews, r
      https://golang.org/cl/139360044
      cf622d75
    • Russ Cox's avatar
      runtime: run sighandler on g0 stack on windows · 201cfe4a
      Russ Cox authored
      The sighander has been run at the bottom of the
      currently executing goroutine stack, but it's in C,
      and we don't want C on our ordinary goroutine stacks.
      Worse, it does a lot of stuff, and it might need more
      stack space. There is scary code in traceback_windows.go
      that talks about stack splits during sighandler.
      Moving sighandler to g0 will eliminate the possibility
      of stack splits and such, and then we can delete
      traceback_windows.go entirely. Win win.
      
      On the builder, all.bat passes with GOARCH=amd64
      and all.bat gets most of the way with GOARCH=386
      except for a DLL-loading test that I think is unrelated.
      
      Fixes windows build.
      
      TBR=brainman, iant
      CC=golang-codereviews
      https://golang.org/cl/140380043
      201cfe4a