Reduce memory usage for storing LTO decl resolutions
commitb5c89d58b6a2f9000afa2471c579cb83ebbd04bb
authorak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Sep 2012 02:56:17 +0000 (7 02:56 +0000)
committerak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Sep 2012 02:56:17 +0000 (7 02:56 +0000)
tree60912414a472f915fe20ebfab483665067066d2a
parent2f20fb38e7991da8fe88986f5d9216aafe8df542
Reduce memory usage for storing LTO decl resolutions

With a LTO build of a large project (>11k subfiles incrementially linked)
storing the LTO resolutions took over 0.5GB memory:

lto/lto.c:1087 (lto_resolution_read)                      0: 0.0%  540398500           15903: 0.0%

The reason is that the declaration indexes are quite sparse, but every subfile
got a full continuous vector for them. Since there are so many of them the
many vectors add up.

This patch instead stores the resolutions initially in a compact (index, resolution)
format. This is only expanded into a sparse vector for fast lookup when
the subfile is actually read, but then immediately freed. This means only one
vector is allocated at a time.

This brings the overhead for this down to less than 3MB for the test case:

lto/lto.c:1087 (lto_resolution_read)                      0: 0.0%    2821456           42186: 0.0%

gcc/:

2012-09-06  Andi Kleen  <ak@linux.intel.com>

* gcc/lto-streamer.h (res_pair): Add.
(lto_file_decl_data): Replace resolutions with respairs.
Add max_index.
* gcc/lto/lto.c (lto_resolution_read): Remove max_index.  Add rp.
Initialize respairs.
(lto_file_finalize): Set up resolutions vector lazily from respairs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191051 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/lto-streamer.h
gcc/lto/lto.c