This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Limit LTO output block-size
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Jun 2013 14:36:06 +0200 (CEST)
- Subject: [PATCH] Limit LTO output block-size
This limits the block-size granularity we use for increasing the
output buffer for LTO to 2MB. Previously it grows exponentially
and unlimited. I've increased the first block-size to 4096 bytes
from 1024 as well. Any comments on the particular limit?
Not sure if we could even optimize away the buffer list in
favor of overcommitting memory using anon mmap (probably not
possible on 32-bit hosts).
LTO bootstrap / testing pending.
Thanks,
Richard.
2013-06-12 Richard Biener <rguenther@suse.de>
* lto-section-out.c (FIRST_BLOCK_SIZE): New define.
(MAX_BLOCK_SIZE): Likewise.
(lto_write_stream): Use them, cap maximum block-size at
MAX_BLOCK_SIZE.
(lto_append_block): Likewise.
Index: gcc/lto-section-out.c
===================================================================
*** gcc/lto-section-out.c (revision 199992)
--- gcc/lto-section-out.c (working copy)
*************** lto_end_section (void)
*** 152,164 ****
}
/* Write all of the chars in OBS to the assembler. Recycle the blocks
in obs as this is being done. */
void
lto_write_stream (struct lto_output_stream *obs)
{
! unsigned int block_size = 1024;
struct lto_char_ptr_base *block;
struct lto_char_ptr_base *next_block;
if (!obs->first_block)
--- 152,170 ----
}
+ /* We exponentially grow the size of the blocks as we need to make
+ room for more data to be written. Start with a single page and go up
+ to 2MB pages for this. */
+ #define FIRST_BLOCK_SIZE 4096
+ #define MAX_BLOCK_SIZE (2 * 1024 * 1024)
+
/* Write all of the chars in OBS to the assembler. Recycle the blocks
in obs as this is being done. */
void
lto_write_stream (struct lto_output_stream *obs)
{
! unsigned int block_size = FIRST_BLOCK_SIZE;
struct lto_char_ptr_base *block;
struct lto_char_ptr_base *next_block;
if (!obs->first_block)
*************** lto_write_stream (struct lto_output_stre
*** 188,193 ****
--- 194,200 ----
else
lang_hooks.lto.append_data (base, num_chars, block);
block_size *= 2;
+ block_size = MIN (MAX_BLOCK_SIZE, block_size);
}
}
*************** lto_append_block (struct lto_output_stre
*** 205,211 ****
{
/* This is the first time the stream has been written
into. */
! obs->block_size = 1024;
new_block = (struct lto_char_ptr_base*) xmalloc (obs->block_size);
obs->first_block = new_block;
}
--- 212,218 ----
{
/* This is the first time the stream has been written
into. */
! obs->block_size = FIRST_BLOCK_SIZE;
new_block = (struct lto_char_ptr_base*) xmalloc (obs->block_size);
obs->first_block = new_block;
}
*************** lto_append_block (struct lto_output_stre
*** 215,220 ****
--- 222,228 ----
/* Get a new block that is twice as big as the last block
and link it into the list. */
obs->block_size *= 2;
+ obs->block_size = MIN (MAX_BLOCK_SIZE, obs->block_size);
new_block = (struct lto_char_ptr_base*) xmalloc (obs->block_size);
/* The first bytes of the block are reserved as a pointer to
the next block. Set the chain of the full block to the