1
0
mirror of https://github.com/golang/go synced 2024-10-01 16:18:32 -06:00
go/src
Brad Fitzpatrick 73edd7b208 cmd/link: simplify readSymName, taking advantage of bufio.Reader
Now that cmd/link uses bufio.Reader, take advantage of it.
I find this new version easier to reason about.

Reduces allocations by 1.1% when linking a basic HTTP server.

Numbers are stable with each round measuring using:
rm prof.mem; go tool link -o foo  -memprofile=prof.mem -memprofilerate=1 foo.a

Before:

65.36MB of 74.53MB total (87.70%)
Dropped 157 nodes (cum <= 0.37MB)
Showing top 10 nodes out of 39 (cum >= 1.47MB)
      flat  flat%   sum%        cum   cum%
   21.48MB 28.81% 28.81%    21.48MB 28.81%  cmd/link/internal/ld.Linklookup
   16.04MB 21.52% 50.33%    16.04MB 21.52%  cmd/link/internal/ld.(*objReader).readSlices
    4.61MB  6.19% 56.52%     4.61MB  6.19%  cmd/link/internal/ld.(*objReader).readSymName
    4.51MB  6.05% 62.57%     6.32MB  8.48%  cmd/link/internal/ld.writelines
    4.50MB  6.03% 68.60%     4.50MB  6.03%  cmd/link/internal/ld.Symgrow
    4.02MB  5.39% 73.99%     4.02MB  5.39%  cmd/link/internal/ld.linknew
    3.98MB  5.34% 79.33%     3.98MB  5.34%  cmd/link/internal/ld.setaddrplus
    2.96MB  3.97% 83.30%    28.78MB 38.62%  cmd/link/internal/ld.(*objReader).readRef
    1.81MB  2.43% 85.73%     1.81MB  2.43%  cmd/link/internal/ld.newcfaoffsetattr
    1.47MB  1.97% 87.70%     1.47MB  1.97%  cmd/link/internal/ld.(*objReader).readSym

After:

64.66MB of 73.87MB total (87.53%)
Dropped 156 nodes (cum <= 0.37MB)
Showing top 10 nodes out of 40 (cum >= 1.47MB)
      flat  flat%   sum%        cum   cum%
   21.48MB 29.08% 29.08%    21.48MB 29.08%  cmd/link/internal/ld.Linklookup
   16.04MB 21.71% 50.79%    16.04MB 21.71%  cmd/link/internal/ld.(*objReader).readSlices
    4.51MB  6.10% 56.90%     6.32MB  8.56%  cmd/link/internal/ld.writelines
    4.50MB  6.09% 62.99%     4.50MB  6.09%  cmd/link/internal/ld.Symgrow
    4.02MB  5.44% 68.42%     4.02MB  5.44%  cmd/link/internal/ld.linknew
    3.98MB  5.38% 73.81%     3.98MB  5.38%  cmd/link/internal/ld.setaddrplus
    3.90MB  5.28% 79.09%     3.90MB  5.28%  cmd/link/internal/ld.(*objReader).readSymName
    2.96MB  4.01% 83.09%    28.08MB 38.01%  cmd/link/internal/ld.(*objReader).readRef
    1.81MB  2.45% 85.55%     1.81MB  2.45%  cmd/link/internal/ld.newcfaoffsetattr
    1.47MB  1.99% 87.53%     1.47MB  1.99%  cmd/link/internal/ld.(*objReader).readSym

Also tested locally with asserts that that the calculated length is
always correct and thus the adjName buf never reallocates.

Change-Id: I19e3e8bfa6a12bcd8b5216f6232f42c122e4f80e
Reviewed-on: https://go-review.googlesource.com/21481
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 23:30:43 +00:00
..
archive all: delete dead test code 2016-03-21 07:10:08 +00:00
bufio all: delete dead test code 2016-03-21 07:10:08 +00:00
builtin
bytes all: delete dead test code 2016-03-21 07:10:08 +00:00
cmd cmd/link: simplify readSymName, taking advantage of bufio.Reader 2016-04-03 23:30:43 +00:00
compress compress/gzip: fix Reader.Reset 2016-04-02 23:36:21 +00:00
container all: single space after period. 2016-03-02 00:13:47 +00:00
crypto all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
database/sql all: delete dead non-test code 2016-03-25 06:28:13 +00:00
debug all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
encoding all: use bytes.Equal, bytes.Contains and strings.Contains 2016-04-01 02:05:01 +00:00
errors all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
expvar all: single space after period. 2016-03-02 00:13:47 +00:00
flag all: single space after period. 2016-03-02 00:13:47 +00:00
fmt fmt: hold on to all free buffers, regardless of size 2016-04-03 06:20:37 +00:00
go runtime, syscall: only search for Windows DLLs in the System32 directory 2016-04-01 22:55:36 +00:00
hash hash/crc64: Add tests for ECMA polynomial 2016-03-31 20:42:02 +00:00
html all: use bytes.Equal, bytes.Contains and strings.Contains 2016-04-01 02:05:01 +00:00
image image/jpeg: reconstruct progressive images even if incomplete. 2016-03-31 00:33:24 +00:00
index/suffixarray
internal runtime, syscall: only search for Windows DLLs in the System32 directory 2016-04-01 22:55:36 +00:00
io all: delete dead non-test code 2016-03-25 06:28:13 +00:00
log all: single space after period. 2016-03-02 00:13:47 +00:00
math math/big: much simplified and faster Float rounding 2016-03-22 17:07:34 +00:00
mime mime: fix maximum length of encoded-words 2016-03-29 11:19:31 +00:00
net net: don't do DNS for onion and local addresses 2016-04-02 20:32:36 +00:00
os os: make IsExists also recognize syscall.ENOTEMPTY 2016-04-03 06:22:07 +00:00
path path, path/filepath: add Join example with joined rooted path 2016-04-03 16:55:51 +00:00
reflect reflect: implement StructOf 2016-04-01 14:56:21 +00:00
regexp all: delete dead non-test code 2016-03-25 06:28:13 +00:00
runtime all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
sort all: delete dead non-test code 2016-03-25 06:28:13 +00:00
strconv all: single space after period. 2016-03-02 00:13:47 +00:00
strings all: single space after period. 2016-03-02 00:13:47 +00:00
sync sync: don't assume b.N > 0 2016-03-18 16:37:39 +00:00
syscall syscall: add support for s390x 2016-04-03 22:12:35 +00:00
testing cmd/go: fix proc-count accumulation in benchmark name 2016-03-26 16:44:01 +00:00
text all: delete dead non-test code 2016-03-25 06:28:13 +00:00
time all: delete dead non-test code 2016-03-25 06:28:13 +00:00
unicode all: single space after period. 2016-03-02 00:13:47 +00:00
unsafe all: single space after period. 2016-03-02 00:13:47 +00:00
vendor/golang.org/x/net/http2/hpack all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
iostest.bash
make.bash cmd/dist: redo flag-passing for bootstrap 2016-03-18 19:00:03 +00:00
make.bat
Make.dist
make.rc
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc