1
0
mirror of https://github.com/golang/go synced 2024-11-12 02:00:23 -07:00

cmd/link: re-use duplicate symbol object

Nothing cares about it.

I did this after looking at the memprof output, but it helps performance a bit:

name       old s/op    new s/op    delta
LinkCmdGo   0.44 ± 3%   0.43 ± 3%  -2.20%   (p=0.000 n=94+90)
LinkJuju    3.98 ± 5%   3.94 ± 5%  -1.19%  (p=0.000 n=100+91)

As well as MaxRSS (i.e. what /usr/bin/time -f '%M' prints):

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   130k ± 0%   120k ± 3%  -7.79%   (p=0.000 n=79+90)
LinkJuju    862k ± 6%   827k ± 8%  -4.01%  (p=0.000 n=100+99)

Change-Id: I6306b7b3369576a688659e2ecdb0815b4152ae96
Reviewed-on: https://go-review.googlesource.com/20972
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2016-03-21 17:29:29 +13:00
parent e451c9025d
commit b6fe2c2c20
2 changed files with 6 additions and 10 deletions

View File

@ -175,6 +175,8 @@ func ldobjfile(ctxt *Link, f *obj.Biobuf, pkg string, length int64, pn string) {
}
}
var dupSym = &LSym{Name: ".dup"}
func readsym(ctxt *Link, f *obj.Biobuf, buf *[]byte, pkg string, pn string) {
if obj.Bgetc(f) != 0xfe {
log.Fatalf("readsym out of sync")
@ -209,7 +211,7 @@ func readsym(ctxt *Link, f *obj.Biobuf, buf *[]byte, pkg string, pn string) {
}
if len(s.P) > 0 {
dup = s
s = linknewsym(ctxt, ".dup", -1)
s = dupSym
}
}
@ -232,17 +234,15 @@ overwrite:
s.Size = int64(size)
}
s.Attr.Set(AttrLocal, local)
if typ != nil { // if bss sym defined multiple times, take type from any one def
if typ != nil {
s.Gotype = typ
}
if dup != nil && typ != nil {
if dup != nil && typ != nil { // if bss sym defined multiple times, take type from any one def
dup.Gotype = typ
}
s.P = data
s.P = s.P[:len(data)]
if nreloc > 0 {
s.R = make([]Reloc, nreloc)
s.R = s.R[:nreloc]
var r *Reloc
for i := 0; i < nreloc; i++ {
r = &s.R[i]

View File

@ -172,12 +172,8 @@ func linknewsym(ctxt *Link, symb string, v int) *LSym {
s.Name = symb
s.Version = int16(v)
ctxt.Nsymbol++
if v != -1 {
ctxt.Allsym = append(ctxt.Allsym, s)
} else if v < -1 {
ctxt.Diag("invalid version %d in linknewsym", v)
}
return s
}