]> Cypherpunks repositories - gostls13.git/commit
[dev.link] cmd/link: reduce memory usage for storing symbol section information
authorCherry Zhang <cherryyz@google.com>
Tue, 21 Apr 2020 22:50:49 +0000 (18:50 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 22 Apr 2020 14:40:35 +0000 (14:40 +0000)
commit9570fc8f7155a668c0e868d5757ac7b0774e8340
tree317b0ecbcfb26921ce3a177dcf71066f00bbe603
parent7a22f11e962a88813f945e227d3d67d94f3dc094
[dev.link] cmd/link: reduce memory usage for storing symbol section information

Currently, we use a dense array to store symbol's sections. The
array element is a *sym.Section, which takes 8 bytes per symbol
on a 64-bit machine. And the array is created upfront.

To reduce memory usage, use a 16-bit index for sections, so we
store 2 bytes per symbol. The array is pointerless, reducing GC
work. Also create the array lazily.

This reduces some memory usage: linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Loadlib_GC       42.1MB ± 0%    36.2MB ± 0%      -14.01%  (p=0.008 n=5+5)

name           old live-B     new live-B     delta
Loadlib_GC        16.8M ± 0%     15.4M ± 0%       -8.36%  (p=0.008 n=5+5)
Archive_GC        98.2M ± 0%     97.2M ± 0%       -1.02%  (p=0.008 n=5+5) # at the end

Change-Id: If8c41eded8859660bca648c5e6fdf5830810fbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/229306
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/dwarf2.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/sym/segment.go