1. 23 Mar, 2017 19 commits
  2. 22 Mar, 2017 21 commits
    • Richard Musiol's avatar
      syscall: use CLONE_VFORK and CLONE_VM · 9e6b79a5
      Richard Musiol authored
      This greatly improves the latency of starting a child process when
      the Go process is using a lot of memory. Even though the kernel uses
      copy-on-write, preparation for that can take up to several 100ms under
      certain conditions. All other goroutines are suspended while starting
      a subprocess so this latency directly affects total throughput.
      
      With CLONE_VM the child process shares the same memory with the parent
      process. On its own this would lead to conflicting use of the same
      memory, so CLONE_VFORK is used to suspend the parent process until the
      child releases the memory when switching to to the new program binary
      via the exec syscall. When the parent process continues to run, one
      has to consider the changes to memory that the child process did,
      namely the return address of the syscall function needs to be restored
      from a register.
      
      A simple benchmark has shown a difference in latency of 16ms vs. 0.5ms
      at 10GB memory usage. However, much higher latencies of several 100ms
      have been observed in real world scenarios. For more information see
      comments on #5838.
      
      Fixes #5838
      
      Change-Id: I6377d7bd8dcd00c85ca0c52b6683e70ce2174ba6
      Reviewed-on: https://go-review.googlesource.com/37439Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      9e6b79a5
    • Sarah Adams's avatar
      encoding/xml: unmarshal allow empty, non-string values · 0a0186fb
      Sarah Adams authored
      When unmarshaling, if an element is empty, eg. '<tag></tag>', and
      destination type is int, uint, float or bool, do not attempt to parse
      value (""). Set to its zero value instead.
      
      Fixes #13417
      
      Change-Id: I2d79f6d8f39192bb277b1a9129727d5abbb2dd1f
      Reviewed-on: https://go-review.googlesource.com/38386Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      0a0186fb
    • Kenny Grant's avatar
      net/http: improve speed of default mux · 1295b745
      Kenny Grant authored
      The DefaultServeMux included in net/http uses a map to store routes,
      but iterates all keys for every request to allow longer paths.
      
      This change checks the map for an exact match first.
      
      To check performance was better, BenchmarkServeMux has been added -
      this adds >100 routes and checks the matches.
      
      Exact matches are faster and more predictable on this benchmark
      and on most existing package benchmarks.
      
      https://perf.golang.org/search?q=upload:20170312.1
      
      ServeMux-4  2.02ms ± 2%	0.04ms ± 2%  −98.08%  (p=0.004 n=5+6)
      
      https://perf.golang.org/search?q=upload:20170312.2
      
      ReadRequestChrome-4	184MB/s  ± 8%	186MB/s  ± 1%	~
      ReadRequestCurl-4	45.0MB/s ± 1%	46.2MB/s ± 1%	+2.71%
      Read...Apachebench-4	45.8MB/s ±13%	48.7MB/s ± 1%	~
      ReadRequestSiege-4	63.6MB/s ± 5%	69.2MB/s ± 1%	+8.75%
      ReadRequestWrk-4	30.9MB/s ± 9%	34.4MB/s ± 2%	+11.25%
      
      Change-Id: I8afafcb956f07197419d545a9f1c03ecaa307384
      Reviewed-on: https://go-review.googlesource.com/38057Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1295b745
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: replace inlined statement lists with syntax.BlockStmt · b5f81eae
      Robert Griesemer authored
      This simplifies the code and removes a premature optimization.
      It increases the amount of allocated syntax.Node space by ~0.4%
      for parsing all of std lib, which is negligible.
      
      Before the change (best of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
        allocated 387.086Mb (267B/line, 487.828Mb/s)
      
      After the change (best of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1516911 lines (3392 files) in 805.028655ms (1884294 lines/s)
        allocated 388.466Mb (268B/line, 482.549Mb/s)
      
      Change-Id: Id19d6210fdc62393862ba3b04913352d95c599be
      Reviewed-on: https://go-review.googlesource.com/38439
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      b5f81eae
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: add position info for { and } braces · e0329248
      Robert Griesemer authored
      This change adds position information for { and } braces in the
      source. There's a 1.9% increase in memory use for syntax.Nodes,
      which is negligible relative to overall compiler memory consumption.
      
      Parsing the std library (using syntax package only) and memory
      consumption before this change (fastest of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1516827 lines (3392 files) in 780.612335ms (1943124 lines/s)
        allocated 379.903Mb (486.673Mb/s)
      
      After this change (fastest of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
        allocated 387.086Mb (267B/line, 487.828Mb/s)
      
      While not an exact apples-to-apples comparison (the syntax package
      has changed and is also parsed), the overall impact is small.
      
      Also: Small improvements to nodes_test.go.
      
      Change-Id: Ib8a7f90bbe79de33d83684e33b1bf8dbc32e644a
      Reviewed-on: https://go-review.googlesource.com/38435Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      e0329248
    • Sam Whited's avatar
      encoding/xml: format test output using subtests · ec512340
      Sam Whited authored
      Change-Id: I2d155c838935cd8427abd142a462ff4c56829715
      Reviewed-on: https://go-review.googlesource.com/37948Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ec512340
    • Josselin Costanzi's avatar
      bytes: fix typo in comment · 0d3cd51c
      Josselin Costanzi authored
      Change-Id: Ia739337dc9961422982912cc6a669022559fb991
      Reviewed-on: https://go-review.googlesource.com/38365Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      0d3cd51c
    • Josh Bleecher Snyder's avatar
      cmd/compile: eliminate Gins and Naddr · 352e19c9
      Josh Bleecher Snyder authored
      Preparation for eliminating Prog-related globals.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ia199fcb282cc3a84903a6e92a3ce342c5faba79c
      Reviewed-on: https://go-review.googlesource.com/38409
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      352e19c9
    • Carlos Eduardo Seo's avatar
      cmd/compile/internal/ppc64, cmd/compile/internal/ssa: Remove OldArch checks · c644a76e
      Carlos Eduardo Seo authored
      Starting in go1.9, the minimum processor requirement for ppc64 is POWER8.
      Therefore, the checks for OldArch and the code enabled by it are not necessary
      anymore.
      
      Updates #19074
      
      Change-Id: I33d6a78b2462c80d57c5dbcba2e13424630afab4
      Reviewed-on: https://go-review.googlesource.com/38404
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      c644a76e
    • Carlos Eduardo Seo's avatar
      runtime/internal/atomic: Remove unnecessary checks for GOARCH_ppc64 · 189053ae
      Carlos Eduardo Seo authored
      Starting in go1.9, the minimum processor requirement for ppc64 is POWER8. This
      means the checks for GOARCH_ppc64 in asm_ppc64x.s can be removed, since we can
      assume LBAR and STBCCC instructions (both from ISA 2.06) will always be
      available.
      
      Updates #19074
      
      Change-Id: Ib4418169cd9fc6f871a5ab126b28ee58a2f349e2
      Reviewed-on: https://go-review.googlesource.com/38406Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarLynn Boger <laboger@linux.vnet.ibm.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      189053ae
    • Matthew Dempsky's avatar
      cmd/compile/internal/gc: make SSAGenFPJump a method of SSAGenState · 22ea7fc1
      Matthew Dempsky authored
      Change-Id: Ie22a08c93dfcfd4b336e7b158415448dd55b2c11
      Reviewed-on: https://go-review.googlesource.com/38407
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      22ea7fc1
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate Link.Asmode · cfb3c8df
      Josh Bleecher Snyder authored
      Asmode is always set to p.Mode,
      which is always set based on the arch family.
      Instead, use the arch family directly.
      
      Passes toolstash-check -all.
      
      Change-Id: Id982472dcc8eeb6dd22cac5ad2f116b54a44caee
      Reviewed-on: https://go-review.googlesource.com/38451
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      cfb3c8df
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate Ctxt.Mode · a470e5d4
      Josh Bleecher Snyder authored
      Replace Ctxt.Mode with a method, Ctxt.RegWidth,
      which is calculated directly off the arch info.
      
      I believe that Prog.Mode can also be removed; future CL.
      
      This is a step towards obj.Link immutability.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ifd7f8f6ed0a2fdc032d1dd306fcd695a14aa5bc5
      Reviewed-on: https://go-review.googlesource.com/38446
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      a470e5d4
    • Josh Bleecher Snyder's avatar
      cmd/compile: funnel SSA Prog creation through SSAGenState · 0a94daa3
      Josh Bleecher Snyder authored
      Step one in eliminating Prog-related globals.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: I3b777fb5a7716f2d9da3067fbd94c28ca894a465
      Reviewed-on: https://go-review.googlesource.com/38450
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      0a94daa3
    • Alan Donovan's avatar
      cmd/vet: -lostcancel: fix crash in ill-typed code · 3b39f523
      Alan Donovan authored
      Fixes golang/go#19656
      
      Change-Id: Ied20d3f25b6e147cc693a1dd1aeb9480adc6687e
      Reviewed-on: https://go-review.googlesource.com/38405Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      3b39f523
    • Mikio Hara's avatar
      net/http: fix possible nil pointer dereference in TestOnlyWriteTimeout · b029e943
      Mikio Hara authored
      TestOnlyWriteTimeout assumes wrongly that:
      - the Accept method of trackLastConnListener is called only once
      - the shared variable conn never becomes nil
      and crashes on some circumstances.
      
      Updates #19032.
      
      Change-Id: I61de22618cd90b84a2b6401afdb6e5d9b3336b12
      Reviewed-on: https://go-review.googlesource.com/36735
      Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      b029e943
    • Josh Bleecher Snyder's avatar
      cmd/compile: pass an explicit position to namedAuto · 0b4e8d00
      Josh Bleecher Snyder authored
      To enable this, inline the call to nod and simplify.
      Eliminates a reference to lineno from the backend.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: I9c4bd77d10d727aa8f5e6c6bb16b0e05de165631
      Reviewed-on: https://go-review.googlesource.com/38441
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      0b4e8d00
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: clean up brloop · 2f2cd557
      Josh Bleecher Snyder authored
      Add docs.
      Reduce indentation.
      
      Passes toolstash-check -all.
      
      Change-Id: I968d1af25989886ae9945052e05e211a107dde9c
      Reviewed-on: https://go-review.googlesource.com/38443
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      2f2cd557
    • Aliaksandr Valialkin's avatar
      strconv: optimize decimal ints formatting with smallsString · 4c8023bf
      Aliaksandr Valialkin authored
      Benchmark results for GOARCH=amd64:
      
      name                                     old time/op  new time/op  delta
      FormatInt-4                              2.51µs ± 2%  2.40µs ± 2%   -4.51%  (p=0.000 n=9+10)
      AppendInt-4                              1.67µs ± 2%  1.61µs ± 3%   -3.74%  (p=0.000 n=9+9)
      FormatUint-4                              698ns ± 2%   643ns ± 3%   -7.95%  (p=0.000 n=10+8)
      AppendUint-4                              478ns ± 1%   418ns ± 2%  -12.61%  (p=0.000 n=8+10)
      AppendUintVarlen/1-4                     9.30ns ± 6%  9.15ns ± 1%     ~     (p=0.199 n=9+10)
      AppendUintVarlen/12-4                    9.12ns ± 0%  9.16ns ± 2%     ~     (p=0.307 n=9+9)
      AppendUintVarlen/123-4                   18.6ns ± 2%  18.7ns ± 0%     ~     (p=0.091 n=10+6)
      AppendUintVarlen/1234-4                  19.1ns ± 4%  17.7ns ± 1%   -7.35%  (p=0.000 n=10+9)
      AppendUintVarlen/12345-4                 21.5ns ± 3%  20.7ns ± 3%   -3.78%  (p=0.002 n=9+10)
      AppendUintVarlen/123456-4                23.5ns ± 3%  20.9ns ± 1%  -11.14%  (p=0.000 n=10+9)
      AppendUintVarlen/1234567-4               25.0ns ± 2%  23.6ns ± 7%   -5.48%  (p=0.004 n=9+10)
      AppendUintVarlen/12345678-4              26.8ns ± 2%  23.4ns ± 2%  -12.79%  (p=0.000 n=9+10)
      AppendUintVarlen/123456789-4             29.8ns ± 3%  26.5ns ± 5%  -11.03%  (p=0.000 n=10+10)
      AppendUintVarlen/1234567890-4            31.6ns ± 3%  26.9ns ± 3%  -14.95%  (p=0.000 n=10+9)
      AppendUintVarlen/12345678901-4           33.8ns ± 3%  29.3ns ± 5%  -13.21%  (p=0.000 n=10+10)
      AppendUintVarlen/123456789012-4          35.5ns ± 4%  29.2ns ± 4%  -17.82%  (p=0.000 n=10+10)
      AppendUintVarlen/1234567890123-4         37.6ns ± 4%  31.4ns ± 3%  -16.48%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234-4        39.8ns ± 6%  32.0ns ± 7%  -19.60%  (p=0.000 n=10+10)
      AppendUintVarlen/123456789012345-4       40.7ns ± 0%  34.4ns ± 4%  -15.55%  (p=0.000 n=6+10)
      AppendUintVarlen/1234567890123456-4      45.4ns ± 6%  35.1ns ± 4%  -22.66%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234567-4     45.1ns ± 1%  36.7ns ± 4%  -18.77%  (p=0.000 n=9+10)
      AppendUintVarlen/123456789012345678-4    46.9ns ± 0%  36.4ns ± 3%  -22.49%  (p=0.000 n=9+10)
      AppendUintVarlen/1234567890123456789-4   50.6ns ± 6%  38.8ns ± 3%  -23.28%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234567890-4  51.3ns ± 2%  38.4ns ± 0%  -25.00%  (p=0.000 n=9+8)
      
      Benchmark results for GOARCH=386:
      
      name                                     old time/op  new time/op  delta
      FormatInt-4                              6.21µs ± 0%  6.14µs ± 0%  -1.11%  (p=0.008 n=5+5)
      AppendInt-4                              4.95µs ± 0%  4.85µs ± 0%  -1.99%  (p=0.016 n=5+4)
      FormatUint-4                             1.89µs ± 1%  1.83µs ± 1%  -2.94%  (p=0.008 n=5+5)
      AppendUint-4                             1.59µs ± 0%  1.57µs ± 2%  -1.72%  (p=0.040 n=5+5)
      FormatIntSmall-4                         8.48ns ± 0%  8.48ns ± 0%    ~     (p=0.905 n=5+5)
      AppendIntSmall-4                         12.2ns ± 0%  12.2ns ± 0%    ~     (all equal)
      AppendUintVarlen/1-4                     10.6ns ± 1%  10.7ns ± 0%    ~     (p=0.238 n=5+4)
      AppendUintVarlen/12-4                    10.7ns ± 0%  10.7ns ± 1%    ~     (p=0.333 n=4+5)
      AppendUintVarlen/123-4                   29.9ns ± 1%  30.2ns ± 0%  +1.07%  (p=0.016 n=5+4)
      AppendUintVarlen/1234-4                  32.4ns ± 1%  30.4ns ± 0%  -6.30%  (p=0.008 n=5+5)
      AppendUintVarlen/12345-4                 35.1ns ± 2%  34.9ns ± 0%    ~     (p=0.238 n=5+5)
      AppendUintVarlen/123456-4                36.6ns ± 0%  35.3ns ± 0%  -3.55%  (p=0.029 n=4+4)
      AppendUintVarlen/1234567-4               38.9ns ± 0%  39.6ns ± 0%  +1.80%  (p=0.029 n=4+4)
      AppendUintVarlen/12345678-4              41.3ns ± 0%  40.1ns ± 0%  -2.91%  (p=0.000 n=5+4)
      AppendUintVarlen/123456789-4             44.9ns ± 1%  44.8ns ± 0%    ~     (p=0.667 n=5+5)
      AppendUintVarlen/1234567890-4            65.6ns ± 0%  66.2ns ± 1%  +0.88%  (p=0.016 n=4+5)
      AppendUintVarlen/12345678901-4           77.9ns ± 0%  76.3ns ± 0%  -2.00%  (p=0.000 n=4+5)
      AppendUintVarlen/123456789012-4          80.7ns ± 0%  79.1ns ± 1%  -2.01%  (p=0.008 n=5+5)
      AppendUintVarlen/1234567890123-4         83.6ns ± 0%  80.2ns ± 1%  -4.07%  (p=0.008 n=5+5)
      AppendUintVarlen/12345678901234-4        86.2ns ± 1%  83.3ns ± 0%  -3.39%  (p=0.008 n=5+5)
      AppendUintVarlen/123456789012345-4       88.5ns ± 0%  83.7ns ± 0%  -5.42%  (p=0.008 n=5+5)
      AppendUintVarlen/1234567890123456-4      90.6ns ± 0%  88.3ns ± 0%  -2.54%  (p=0.008 n=5+5)
      AppendUintVarlen/12345678901234567-4     92.7ns ± 0%  89.0ns ± 1%  -4.01%  (p=0.008 n=5+5)
      AppendUintVarlen/123456789012345678-4    95.6ns ± 1%  92.6ns ± 0%  -3.18%  (p=0.016 n=5+4)
      AppendUintVarlen/1234567890123456789-4    118ns ± 0%   114ns ± 0%    ~     (p=0.079 n=4+5)
      AppendUintVarlen/12345678901234567890-4   138ns ± 0%   136ns ± 0%  -1.45%  (p=0.008 n=5+5)
      
      Updates #19445
      
      Change-Id: Iafbe5c074898187c150dc3854e5b9fc19c10be05
      Reviewed-on: https://go-review.googlesource.com/38255
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      4c8023bf
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: clean up checkaddr · 33266df8
      Josh Bleecher Snyder authored
      Coalesce identical cases.
      Give it a proper doc comment.
      Fix comment locations.
      Update/delete old comments.
      
      Passes toolstash-check -all.
      
      Change-Id: I88d9cf20e6e04b0c1c6583e92cd96335831f183f
      Reviewed-on: https://go-review.googlesource.com/38442
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      33266df8
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate AMODE · 3394633d
      Josh Bleecher Snyder authored
      AMODE appears to have been intended to allow
      a Prog to switch between 16 (!), 32, or 64 bit x86.
      It is unused anywhere in the tree.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ic57b257cfe580f29dad81d97e4193bf3c330c598
      Reviewed-on: https://go-review.googlesource.com/38445
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      3394633d