Commit d37e6b50 by Geoffrey Keating Committed by Geoffrey Keating

ggc-common.c (ggc_rlimit_bound): Don't check RSS limit.

	* ggc-common.c (ggc_rlimit_bound): Don't check RSS limit.
	Check DATA limit only if there's no AS limit.  Ignore insanely
	low DATA limits.
	(ggc_min_heapsize_heuristic): Don't divide AS or RSS limits by 8,
	but take care that the AS limit isn't overrun.
	* doc/invoke.texi: Update documentation of min-heapsize parameter.

From-SVN: r85722
parent 56b043c8
2004-08-09 Geoffrey Keating <geoffk@apple.com>
* ggc-common.c (ggc_rlimit_bound): Don't check RSS limit.
Check DATA limit only if there's no AS limit. Ignore insanely
low DATA limits.
(ggc_min_heapsize_heuristic): Don't divide AS or RSS limits by 8,
but take care that the AS limit isn't overrun.
* doc/invoke.texi: Update documentation of min-heapsize parameter.
2004-08-09 Jeff Law <law@redhat.com> 2004-08-09 Jeff Law <law@redhat.com>
* Makefile.in (OBJC-common): Add tree-ssa-threadupdate.c * Makefile.in (OBJC-common): Add tree-ssa-threadupdate.c
......
...@@ -5310,7 +5310,7 @@ generation. ...@@ -5310,7 +5310,7 @@ generation.
The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
RAM >= 1GB. If @code{getrlimit} is available, the notion of "RAM" is RAM >= 1GB. If @code{getrlimit} is available, the notion of "RAM" is
the smallest of actual RAM, RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If the smallest of actual RAM and RLIMIT_DATA or RLIMIT_AS. If
GCC is not able to calculate RAM on a particular platform, the lower GCC is not able to calculate RAM on a particular platform, the lower
bound of 30% is used. Setting this parameter and bound of 30% is used. Setting this parameter and
@option{ggc-min-heapsize} to zero causes a full collection to occur at @option{ggc-min-heapsize} to zero causes a full collection to occur at
...@@ -5325,14 +5325,14 @@ by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, ...@@ -5325,14 +5325,14 @@ by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
tuning this may improve compilation speed, and has no effect on code tuning this may improve compilation speed, and has no effect on code
generation. generation.
The default is RAM/8, with a lower bound of 4096 (four megabytes) and an The default is the smaller of RAM/8, RLIMIT_RSS, or a limit which
upper bound of 131072 (128 megabytes). If @code{getrlimit} is tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
available, the notion of "RAM" is the smallest of actual RAM, with a lower bound of 4096 (four megabytes) and an upper bound of
RLIMIT_RSS, RLIMIT_DATA and RLIMIT_AS. If GCC is not able to calculate 131072 (128 megabytes). If GCC is not able to calculate RAM on a
RAM on a particular platform, the lower bound is used. Setting this particular platform, the lower bound is used. Setting this parameter
parameter very large effectively disables garbage collection. Setting very large effectively disables garbage collection. Setting this
this parameter and @option{ggc-min-expand} to zero causes a full parameter and @option{ggc-min-expand} to zero causes a full collection
collection to occur at every opportunity. to occur at every opportunity.
@item max-reload-search-insns @item max-reload-search-insns
The maximum number of instruction reload should look backward for equivalent The maximum number of instruction reload should look backward for equivalent
......
...@@ -669,30 +669,34 @@ mmap_gt_pch_use_address (void *base, size_t size, int fd, size_t offset) ...@@ -669,30 +669,34 @@ mmap_gt_pch_use_address (void *base, size_t size, int fd, size_t offset)
} }
#endif /* HAVE_MMAP_FILE */ #endif /* HAVE_MMAP_FILE */
/* Modify the bound based on rlimits. Keep the smallest number found. */ /* Modify the bound based on rlimits. */
static double static double
ggc_rlimit_bound (double limit) ggc_rlimit_bound (double limit)
{ {
#if defined(HAVE_GETRLIMIT) #if defined(HAVE_GETRLIMIT)
struct rlimit rlim; struct rlimit rlim;
# ifdef RLIMIT_RSS # if defined (RLIMIT_AS)
if (getrlimit (RLIMIT_RSS, &rlim) == 0 /* RLIMIT_AS is what POSIX says is the limit on mmap. Presumably
any OS which has RLIMIT_AS also has a working mmap that GCC will use. */
if (getrlimit (RLIMIT_AS, &rlim) == 0
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY && rlim.rlim_cur != (rlim_t) RLIM_INFINITY
&& rlim.rlim_cur < limit) && rlim.rlim_cur < limit)
limit = rlim.rlim_cur; limit = rlim.rlim_cur;
# endif # elif defined (RLIMIT_DATA)
# ifdef RLIMIT_DATA /* ... but some older OSs bound mmap based on RLIMIT_DATA, or we
might be on an OS that has a broken mmap. (Others don't bound
mmap at all, apparently.) */
if (getrlimit (RLIMIT_DATA, &rlim) == 0 if (getrlimit (RLIMIT_DATA, &rlim) == 0
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY && rlim.rlim_cur != (rlim_t) RLIM_INFINITY
&& rlim.rlim_cur < limit) && rlim.rlim_cur < limit
limit = rlim.rlim_cur; /* Darwin has this horribly bogus default setting of
# endif RLIMIT_DATA, to 6144Kb. No-one notices because RLIMIT_DATA
# ifdef RLIMIT_AS appears to be ignored. Ignore such silliness. If a limit
if (getrlimit (RLIMIT_AS, &rlim) == 0 this small was actually effective for mmap, GCC wouldn't even
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY start up. */
&& rlim.rlim_cur < limit) && rlim.rlim_cur >= 8 * 1024 * 1024)
limit = rlim.rlim_cur; limit = rlim.rlim_cur;
# endif # endif /* RLIMIT_AS or RLIMIT_DATA */
#endif /* HAVE_GETRLIMIT */ #endif /* HAVE_GETRLIMIT */
return limit; return limit;
...@@ -721,20 +725,39 @@ ggc_min_expand_heuristic (void) ...@@ -721,20 +725,39 @@ ggc_min_expand_heuristic (void)
int int
ggc_min_heapsize_heuristic (void) ggc_min_heapsize_heuristic (void)
{ {
double min_heap_kbytes = physmem_total(); double phys_kbytes = physmem_total();
double limit_kbytes = ggc_rlimit_bound (phys_kbytes * 2);
/* Adjust for rlimits. */
min_heap_kbytes = ggc_rlimit_bound (min_heap_kbytes);
min_heap_kbytes /= 1024; /* Convert to Kbytes. */ phys_kbytes /= 1024; /* Convert to Kbytes. */
limit_kbytes /= 1024;
/* The heuristic is RAM/8, with a lower bound of 4M and an upper /* The heuristic is RAM/8, with a lower bound of 4M and an upper
bound of 128M (when RAM >= 1GB). */ bound of 128M (when RAM >= 1GB). */
min_heap_kbytes /= 8; phys_kbytes /= 8;
min_heap_kbytes = MAX (min_heap_kbytes, 4 * 1024);
min_heap_kbytes = MIN (min_heap_kbytes, 128 * 1024); #if defined(HAVE_GETRLIMIT) && defined (RLIMIT_RSS)
/* Try not to overrun the RSS limit while doing garbage collection.
The RSS limit is only advisory, so no margin is subtracted. */
{
struct rlimit rlim;
if (getrlimit (RLIMIT_RSS, &rlim) == 0
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY)
phys_kbytes = MIN (phys_kbytes, rlim.rlim_cur / 1024);
}
# endif
/* Don't blindly run over our data limit; do GC at least when the
*next* GC would be within 16Mb of the limit. If GCC does hit the
data limit, compilation will fail, so this tries to be
conservative. */
limit_kbytes = MAX (0, limit_kbytes - 16 * 1024);
limit_kbytes = (limit_kbytes * 100) / (110 + ggc_min_expand_heuristic());
phys_kbytes = MIN (phys_kbytes, limit_kbytes);
phys_kbytes = MAX (phys_kbytes, 4 * 1024);
phys_kbytes = MIN (phys_kbytes, 128 * 1024);
return min_heap_kbytes; return phys_kbytes;
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment