This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch to account for rlimits in GC heuristics


"Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu> writes:

> As noted elsewhere, rlimits need to be accounted for in the GC
> heuristics.  The patch below does this by taking the lesser of actual
> RAM, RLIMIT_RSS and RLIMIT_DATA as input into the algorithm.

Cool.  Another one possibly worth taking into account is RLIMIT_AS
(where present), which is the "address space (virtual memory)" limit.

>  The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
> -RAM >= 1GB.  If GCC is not able to calculate RAM on a particular
> -platform, the lower bound of 30% is used.  Setting this parameter and
> - at option{ggc-min-heapsize} to zero causes a full collection to occur at
> -every opportunity.  This is extremely slow, but can be useful for
> -debugging.
> +RAM >= 1GB.  If @code{getrlimit} is available, the notion of "RAM" is
> +the lesser of actual RAM, RLIMIT_RSS and RLIMIT_DATA.  If GCC is not
> +able to calculate RAM on a particular platform, the lower bound of 30%
> +is used.  Setting this parameter and @option{ggc-min-heapsize} to zero
> +causes a full collection to occur at every opportunity.  This is
> +extremely slow, but can be useful for debugging.

Suggest you say "the smallest of ..." instead of "the lesser of ..."
which is IMO confusing with more than two alternatives.  Also, could
you try to reorganize the text here so that entire paragraphs are not
duplicated in the description of both options?

>  ggc_min_expand_heuristic()
>  {
>    double min_expand = physmem_total();
> +
> +#if defined(HAVE_GETRLIMIT)
> +  struct rlimit rlim;
> +# ifdef RLIMIT_RSS
> +  if (getrlimit (RLIMIT_RSS, &rlim) == 0 && rlim.rlim_cur < min_expand)
> +    min_expand = rlim.rlim_cur;
> +# endif
> +# ifdef RLIMIT_DATA
> +  if (getrlimit (RLIMIT_DATA, &rlim) == 0 && rlim.rlim_cur < min_expand)
> +    min_expand = rlim.rlim_cur;
> +# endif
> +#endif /* HAVE_GETRLIMIT */

This block of code is duplicated in both heuristic functions.  Please
factor it out to a separate subroutine.

OK with those changes.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]