1. 14 Aug, 2017 32 commits
  2. 13 Aug, 2017 6 commits
    • Austin Clements's avatar
      runtime: support DT_GNU_HASH in VDSO · 9065c3bf
      Austin Clements authored
      Currently we only support finding symbols in the VDSO using the old
      DT_HASH. These days everything uses DT_GNU_HASH instead. To keep up
      with the times and future-proof against DT_HASH disappearing from the
      VDSO in the future, this commit adds support for DT_GNU_HASH and
      prefers it over DT_HASH.
      
      Tested by making sure it found a DT_GNU_HASH section and all of the
      expected symbols in it, and then disabling the DT_GNU_HASH path and
      making sure the old DT_HASH path still found all of the symbols.
      
      Fixes #19649.
      
      Change-Id: I508c8b35a019330d2c32f04f3833b69cb2686f13
      Reviewed-on: https://go-review.googlesource.com/45511
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      9065c3bf
    • Audrey Lim's avatar
      archive/zip: fix Writer to validate file · 816deacc
      Audrey Lim authored
      The ZIP format uses uint16 to contain the length of the file name and
      the length of the Extra section. This change verifies that the length
      of these fields fit in an uint16 prior to writing the ZIP file. If not,
      an error is returned.
      
      Fixes #17402
      
      Change-Id: Ief9a864d2fe16b89ddb9917838283b801a2c58a4
      Reviewed-on: https://go-review.googlesource.com/50250Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      816deacc
    • Martin Möhrmann's avatar
      strconv: avoid truncation of output in parse int tests · 09ed0f68
      Martin Möhrmann authored
      If needed cast the test table values to a higher bit size
      integer type instead of casting the result values of the
      tested function to a lower bit size integer type.
      
      Change-Id: Iaa79742b2b1d90c7c7eac324f54032ebea0b1b41
      Reviewed-on: https://go-review.googlesource.com/55137Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
      09ed0f68
    • Martin Möhrmann's avatar
      strings: speed up FieldsFunc · fee7f2ab
      Martin Möhrmann authored
      Increases performance of FieldsFunc by recording the start and end
      of the fields in an array. The first 32 fields are saved in a pre-allocated
      array on the stack. This avoids the old behavior of iterating over the
      input string two times but uses more allocations when more than 32 fields
      are encountered.
      
      Additionally code for handling non-ASCII containing strings from Fields is
      removed and replaced by a call to the new faster FieldsFunc function.
      
      Overall this still leads to a slowdown for Fields on non-ASCII strings
      while speeding up Fields in general.
      
      name                      old time/op    new time/op     delta
      Fields/ASCII/16              116ns ± 5%      115ns ± 5%       ~     (p=0.480 n=10+10)
      Fields/ASCII/256             765ns ± 1%      761ns ± 2%       ~     (p=0.171 n=10+10)
      Fields/ASCII/4096           12.5µs ± 1%     12.7µs ± 1%     +1.82%  (p=0.000 n=10+10)
      Fields/ASCII/65536           226µs ± 1%      226µs ± 2%       ~     (p=0.739 n=10+10)
      Fields/ASCII/1048576        5.12ms ± 1%     5.12ms ± 1%       ~     (p=0.696 n=8+10)
      Fields/Mixed/16              172ns ± 1%      233ns ± 1%    +35.90%  (p=0.000 n=9+10)
      Fields/Mixed/256            1.18µs ± 2%     2.45µs ± 1%   +107.47%  (p=0.000 n=10+10)
      Fields/Mixed/4096           20.3µs ± 1%     43.1µs ± 2%   +112.41%  (p=0.000 n=10+10)
      Fields/Mixed/65536           364µs ± 1%      704µs ± 1%    +93.56%  (p=0.000 n=9+10)
      Fields/Mixed/1048576        7.07ms ± 2%    13.34ms ± 4%    +88.83%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/16          274ns ± 1%      188ns ± 3%    -31.44%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/256        3.69µs ± 1%     2.06µs ± 2%    -44.26%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/4096       59.9µs ± 1%     35.3µs ± 2%    -41.10%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/65536       958µs ± 1%      567µs ± 1%    -40.82%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/1048576    16.3ms ± 2%     11.0ms ± 3%    -32.52%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16          309ns ± 1%      213ns ± 0%    -30.98%  (p=0.000 n=10+6)
      FieldsFunc/Mixed/256        3.83µs ± 1%     2.14µs ± 1%    -44.01%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/4096       66.2µs ± 2%     37.8µs ± 1%    -42.85%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536      1.09ms ± 1%     0.63ms ± 1%    -42.73%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576    18.6ms ± 3%     12.0ms ± 2%    -35.50%  (p=0.000 n=10+10)
      
      Fixes #17856
      Fixes #19789
      
      Change-Id: I9f5a560e534566fd81963651f342c8f44cfb0469
      Reviewed-on: https://go-review.googlesource.com/42810Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
      fee7f2ab
    • Martin Möhrmann's avatar
      strconv: fix ParseUint return value on range overflow · fc6b74ce
      Martin Möhrmann authored
      If the value corresponding to the input string cannot be
      represented by an unsigned integer of the given size,
      err.Err = ErrRange and the returned value is the maximum
      magnitude unsigned integer of the appropriate bitSize.
      This is consistent with ParseInt's behavior and the documentation.
      
      Expand tests to test 32 bit test value tables with bitsize 32 set.
      These tests fail without the fix in this CL.
      
      Fixes #21278
      
      Change-Id: I8aab39279ec3e31905fcbf582a916cbf6d9b95da
      Reviewed-on: https://go-review.googlesource.com/55134
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
      fc6b74ce
    • Joe Tsai's avatar
      archive/tar: simplify toASCII and parseString · 1d812515
      Joe Tsai authored
      Use a simple []byte instead of bytes.Buffer to create a string.
      Use bytes.IndexByte instead of our own for loop.
      
      Change-Id: Ic4a1161d79017fd3af086a05c53d5f20a5f09326
      Reviewed-on: https://go-review.googlesource.com/54752Reviewed-by: default avatarAvelino <t@avelino.xxx>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      1d812515
  3. 12 Aug, 2017 2 commits
    • Agniva De Sarker's avatar
      archive/tar: optimize formatPAXRecord() call · 23cd87eb
      Agniva De Sarker authored
      By replacing fmt.Sprintf with a simple string concat, we see
      pretty good improvements across the board on time and memory.
      
      name             old time/op    new time/op    delta
      FormatPAXRecord     683ns ± 2%     210ns ± 5%  -69.22%  (p=0.000 n=10+10)
      
      name             old alloc/op   new alloc/op   delta
      FormatPAXRecord      112B ± 0%       32B ± 0%  -71.43%  (p=0.000 n=10+10)
      
      name             old allocs/op  new allocs/op  delta
      FormatPAXRecord      8.00 ± 0%      2.00 ± 0%  -75.00%  (p=0.000 n=10+10)
      
      Ran with - -cpu=1 -count=10 on an AMD64 i5-5200U CPU @ 2.20GHz
      
      Using the following benchmark:
      func BenchmarkFormatPAXRecord(b *testing.B) {
        for n := 0; n < b.N; n++ {
          formatPAXRecord("foo", "bar")
        }
      }
      
      Change-Id: I828ddbafad2e5d937f0cf5f777b512638344acfc
      Reviewed-on: https://go-review.googlesource.com/55210Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
      23cd87eb
    • Joe Tsai's avatar
      archive/tar: implement specialized logic for USTAR format · 0d1a8f6e
      Joe Tsai authored
      Rather than going through the complicated logic of writeHeader,
      implement a writeUSTARHeader that only knows about the USTAR format.
      This makes the logic much easier to reason about since you only
      need to be concerned about USTAR and not all the subtle
      differences between USTAR, PAX, and GNU.
      
      We seperate out the logic in writeUSTARHeader into templateV7Plus
      and writeRawHeader since the planned implementations of
      writePAXHeader and writeGNUHeader will use them.
      
      Change-Id: Ie75a54ac998420ece82686159ae6fa39f8b128e9
      Reviewed-on: https://go-review.googlesource.com/54970Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      0d1a8f6e