diff options
author | Andi Kleen <ak@linux.intel.com> | 2012-09-07 02:56:17 +0000 |
---|---|---|
committer | Andi Kleen <ak@gcc.gnu.org> | 2012-09-07 02:56:17 +0000 |
commit | aed7d7cfbb865025c86bd4ef0164294ae4679923 (patch) | |
tree | 60912414a472f915fe20ebfab483665067066d2a /gcc/lto-streamer.h | |
parent | 6e85a1584edbc575a8f69bec8aa4dd4c4f977a04 (diff) | |
download | gcc-aed7d7cfbb865025c86bd4ef0164294ae4679923.zip gcc-aed7d7cfbb865025c86bd4ef0164294ae4679923.tar.gz gcc-aed7d7cfbb865025c86bd4ef0164294ae4679923.tar.bz2 |
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.
From-SVN: r191051
Diffstat (limited to 'gcc/lto-streamer.h')
-rw-r--r-- | gcc/lto-streamer.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index bed408a..80fc19f 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -513,6 +513,18 @@ typedef struct lto_out_decl_state *lto_out_decl_state_ptr; DEF_VEC_P(lto_out_decl_state_ptr); DEF_VEC_ALLOC_P(lto_out_decl_state_ptr, heap); +/* Compact representation of a index <-> resolution pair. Unpacked to an + vector later. */ +struct res_pair +{ + ld_plugin_symbol_resolution_t res; + unsigned index; +}; +typedef struct res_pair res_pair; + +DEF_VEC_O(res_pair); +DEF_VEC_ALLOC_O(res_pair, heap); + /* One of these is allocated for each object file that being compiled by lto. This structure contains the tables that are needed by the serialized functions and ipa passes to connect themselves to the @@ -548,7 +560,8 @@ struct GTY(()) lto_file_decl_data unsigned HOST_WIDE_INT id; /* Symbol resolutions for this file */ - VEC(ld_plugin_symbol_resolution_t,heap) * GTY((skip)) resolutions; + VEC(res_pair, heap) * GTY((skip)) respairs; + unsigned max_index; struct gcov_ctr_summary GTY((skip)) profile_info; }; |