1
0
mirror of https://github.com/golang/go synced 2024-11-18 13:54:59 -07:00

[dev.link] cmd/link: free loader memory after LoadFull

After LoadFull, we'll be using sym.Symbols mostly. We still need
the loader information for symbol index mappings and name
lookups, but not much else. Free some memory.

Linking cmd/compile,

name           old time/op    new time/op    delta
Loadlibfull_GC    44.5M ± 0%     35.8M ± 0%    -19.66%  (p=0.008 n=5+5)
Archive_GC        46.4M ± 0%     37.6M ± 0%    -18.89%  (p=0.008 n=5+5)

Linking cmd/compile with external linking,

name           old time/op    new time/op    delta
Loadlibfull_GC    82.5M ± 0%     57.4M ± 0%    -30.41%  (p=0.008 n=5+5)
Archive_GC        86.8M ± 0%     61.7M ± 0%    -28.90%  (p=0.008 n=5+5)

Change-Id: I6859d488172ef8968918b86de527fbfed6832ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/230300
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-04-28 18:59:57 -04:00
parent df2a46f85a
commit f886ff7b41
2 changed files with 33 additions and 1 deletions

View File

@ -1130,7 +1130,7 @@ func addimports(ctxt *Link, datsect *peSection) {
for m := d.ms; m != nil; m = m.next {
m.off = uint64(pefile.nextSectOffset) + uint64(ctxt.Out.Offset()) - uint64(startoff)
ctxt.Out.Write16(0) // hint
strput(ctxt.Out, ldr.SymExtname(m.s))
strput(ctxt.Out, ldr.Syms[m.s].Extname())
}
}

View File

@ -2124,6 +2124,38 @@ func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols, needReloc bool) {
}
}
}
// Free some memory.
// At this point we still need basic index mapping, and some fields of
// external symbol payloads, but not much else.
l.values = nil
l.symSects = nil
l.outdata = nil
l.itablink = nil
l.attrOnList = nil
l.attrLocal = nil
l.attrNotInSymbolTable = nil
l.attrVisibilityHidden = nil
l.attrDuplicateOK = nil
l.attrShared = nil
l.attrExternal = nil
l.attrReadOnly = nil
l.attrTopFrame = nil
l.attrSpecial = nil
l.attrCgoExportDynamic = nil
l.attrCgoExportStatic = nil
l.outer = nil
l.align = nil
l.dynimplib = nil
l.dynimpvers = nil
l.localentry = nil
l.extname = nil
l.elfType = nil
l.plt = nil
l.got = nil
l.dynid = nil
l.relocVariant = nil
l.extRelocs = nil
}
// ResolveABIAlias given a symbol returns the ABI alias target of that