diff mbox

[1/2] Add note on MALLOC_MMAP_* environment variables

Message ID 1477318076-22231-2-git-send-email-siddhesh@sourceware.org
State New
Headers show

Commit Message

Siddhesh Poyarekar Oct. 24, 2016, 2:07 p.m. UTC
The mallopt parameters manual does not mention the environment
variables that can be used to set these parameters at program startup.
Mention those environment variables for completeness.

	* manual/memory.texi: Add environment variable alternatives to
	setting mallopt parameters.
---
 manual/memory.texi | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Carlos O'Donell Oct. 26, 2016, 4:15 a.m. UTC | #1
On 10/24/2016 10:07 AM, Siddhesh Poyarekar wrote:
> The mallopt parameters manual does not mention the environment
> variables that can be used to set these parameters at program startup.
> Mention those environment variables for completeness.
> 
> 	* manual/memory.texi: Add environment variable alternatives to
> 	setting mallopt parameters.

Two nits. Otherwise OK.

> ---
>  manual/memory.texi | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/manual/memory.texi b/manual/memory.texi
> index 5383105..6f33455 100644
> --- a/manual/memory.texi
> +++ b/manual/memory.texi
> @@ -1113,12 +1113,25 @@ choices for @var{param}, as defined in @file{malloc.h}, are:
>  @item M_MMAP_MAX
>  The maximum number of chunks to allocate with @code{mmap}.  Setting this
>  to zero disables all use of @code{mmap}.
> +
> +The default value of this parameter is @code{65536}.
> +
> +This parameter can also be set for the process at startup by setting the
> +environment variable @code{MALLOC_MMAP_MAX_} to the desired value.
>  @item M_MMAP_THRESHOLD
>  All chunks larger than this value are allocated outside the normal
>  heap, using the @code{mmap} system call.  This way it is guaranteed
>  that the memory for these chunks can be returned to the system on
>  @code{free}.  Note that requests smaller than this threshold might still
>  be allocated via @code{mmap}.
> +
> +If this parameter is not set, the default value is set as 128 KB and the

Should this be 128KiB?

> +threshold is adjusted dynamically to suit the allocation patterns of the
> +program. If the parameter is set, the dynamic adjustment is disabled and the
> +value is set statically to the input value.
> +
> +This parameter can also be set for the process at startup by setting the
> +environment variable @code{MALLOC_MMAP_THRESHOLD_} to the desired value.
>  @comment TODO: @item M_MXFAST
>  @item M_PERTURB
>  If non-zero, memory blocks are filled with values depending on some
> @@ -1128,16 +1141,34 @@ use of uninitialized or freed heap memory.  Note that this option does not
>  guarantee that the freed block will have any specific values.  It only
>  guarantees that the content the block had before it was freed will be
>  overwritten.
> +
> +The default value of this parameter is @code{0}.
> +
> +This parameter can also be set for the process at startup by setting the
> +environment variable @code{MALLOC_MMAP_PERTURB_} to the desired value.
>  @item M_TOP_PAD
>  This parameter determines the amount of extra memory to obtain from the
>  system when a call to @code{sbrk} is required.  It also specifies the
>  number of bytes to retain when shrinking the heap by calling @code{sbrk}
>  with a negative argument.  This provides the necessary hysteresis in
>  heap size such that excessive amounts of system calls can be avoided.
> +
> +The default value of this parameter is @code{0}.
> +
> +This parameter can also be set for the process at startup by setting the
> +environment variable @code{MALLOC_TOP_PAD_} to the desired value.
>  @item M_TRIM_THRESHOLD
>  This is the minimum size (in bytes) of the top-most, releasable chunk
>  that will cause @code{sbrk} to be called with a negative argument in
>  order to return memory to the system.
> +
> +If this parameter is not set, the default value is set as 128 KB and the

Likewise.

> +threshold is adjusted dynamically to suit the allocation patterns of the
> +program. If the parameter is set, the dynamic adjustment is disabled and the
> +value is set statically to the provided input.
> +
> +This parameter can also be set for the process at startup by setting the
> +environment variable @code{MALLOC_TRIM_THRESHOLD_} to the desired value.
>  @end table
>  
>  @end deftypefun
>
Michael Kerrisk \(man-pages\) Oct. 26, 2016, 7:58 a.m. UTC | #2
I've nothing to add beyond Carlos's comments. I looked this over and
it looks good to me.

Cheers,

Michael


On Wed, Oct 26, 2016 at 6:15 AM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 10/24/2016 10:07 AM, Siddhesh Poyarekar wrote:
>> The mallopt parameters manual does not mention the environment
>> variables that can be used to set these parameters at program startup.
>> Mention those environment variables for completeness.
>>
>>       * manual/memory.texi: Add environment variable alternatives to
>>       setting mallopt parameters.
>
> Two nits. Otherwise OK.
>
>> ---
>>  manual/memory.texi | 31 +++++++++++++++++++++++++++++++
>>  1 file changed, 31 insertions(+)
>>
>> diff --git a/manual/memory.texi b/manual/memory.texi
>> index 5383105..6f33455 100644
>> --- a/manual/memory.texi
>> +++ b/manual/memory.texi
>> @@ -1113,12 +1113,25 @@ choices for @var{param}, as defined in @file{malloc.h}, are:
>>  @item M_MMAP_MAX
>>  The maximum number of chunks to allocate with @code{mmap}.  Setting this
>>  to zero disables all use of @code{mmap}.
>> +
>> +The default value of this parameter is @code{65536}.
>> +
>> +This parameter can also be set for the process at startup by setting the
>> +environment variable @code{MALLOC_MMAP_MAX_} to the desired value.
>>  @item M_MMAP_THRESHOLD
>>  All chunks larger than this value are allocated outside the normal
>>  heap, using the @code{mmap} system call.  This way it is guaranteed
>>  that the memory for these chunks can be returned to the system on
>>  @code{free}.  Note that requests smaller than this threshold might still
>>  be allocated via @code{mmap}.
>> +
>> +If this parameter is not set, the default value is set as 128 KB and the
>
> Should this be 128KiB?
>
>> +threshold is adjusted dynamically to suit the allocation patterns of the
>> +program. If the parameter is set, the dynamic adjustment is disabled and the
>> +value is set statically to the input value.
>> +
>> +This parameter can also be set for the process at startup by setting the
>> +environment variable @code{MALLOC_MMAP_THRESHOLD_} to the desired value.
>>  @comment TODO: @item M_MXFAST
>>  @item M_PERTURB
>>  If non-zero, memory blocks are filled with values depending on some
>> @@ -1128,16 +1141,34 @@ use of uninitialized or freed heap memory.  Note that this option does not
>>  guarantee that the freed block will have any specific values.  It only
>>  guarantees that the content the block had before it was freed will be
>>  overwritten.
>> +
>> +The default value of this parameter is @code{0}.
>> +
>> +This parameter can also be set for the process at startup by setting the
>> +environment variable @code{MALLOC_MMAP_PERTURB_} to the desired value.
>>  @item M_TOP_PAD
>>  This parameter determines the amount of extra memory to obtain from the
>>  system when a call to @code{sbrk} is required.  It also specifies the
>>  number of bytes to retain when shrinking the heap by calling @code{sbrk}
>>  with a negative argument.  This provides the necessary hysteresis in
>>  heap size such that excessive amounts of system calls can be avoided.
>> +
>> +The default value of this parameter is @code{0}.
>> +
>> +This parameter can also be set for the process at startup by setting the
>> +environment variable @code{MALLOC_TOP_PAD_} to the desired value.
>>  @item M_TRIM_THRESHOLD
>>  This is the minimum size (in bytes) of the top-most, releasable chunk
>>  that will cause @code{sbrk} to be called with a negative argument in
>>  order to return memory to the system.
>> +
>> +If this parameter is not set, the default value is set as 128 KB and the
>
> Likewise.
>
>> +threshold is adjusted dynamically to suit the allocation patterns of the
>> +program. If the parameter is set, the dynamic adjustment is disabled and the
>> +value is set statically to the provided input.
>> +
>> +This parameter can also be set for the process at startup by setting the
>> +environment variable @code{MALLOC_TRIM_THRESHOLD_} to the desired value.
>>  @end table
>>
>>  @end deftypefun
>>
>
>
> --
> Cheers,
> Carlos.
Siddhesh Poyarekar Oct. 26, 2016, 9:47 a.m. UTC | #3
On Wednesday 26 October 2016 09:45 AM, Carlos O'Donell wrote:
> On 10/24/2016 10:07 AM, Siddhesh Poyarekar wrote:
>> The mallopt parameters manual does not mention the environment
>> variables that can be used to set these parameters at program startup.
>> Mention those environment variables for completeness.
>>
>> 	* manual/memory.texi: Add environment variable alternatives to
>> 	setting mallopt parameters.
> 
> Two nits. Otherwise OK.

Thanks, pushed.

Siddhesh
Rical Jasan Oct. 26, 2016, 11:26 a.m. UTC | #4
On 10/25/2016 09:15 PM, Carlos O'Donell wrote:
>> > +If this parameter is not set, the default value is set as 128 KB and the
> Should this be 128KiB?

I don't think binary computers count with 10 fingers.  At any rate, we
don't have any ibi's AFAICS:

$ grep -Pi '\d[kmgt]i?b\b' manual/*.texi

So maybe "128kB"?  ;)

Rical
Siddhesh Poyarekar Oct. 26, 2016, 11:30 a.m. UTC | #5
On Wednesday 26 October 2016 04:56 PM, Rical Jasan wrote:
> On 10/25/2016 09:15 PM, Carlos O'Donell wrote:
>>>> +If this parameter is not set, the default value is set as 128 KB and the
>> Should this be 128KiB?
> 
> I don't think binary computers count with 10 fingers.  At any rate, we
> don't have any ibi's AFAICS:
> 
> $ grep -Pi '\d[kmgt]i?b\b' manual/*.texi

It's the other way around AFAIK, i.e. KiB == 1024 and KB == 1000.  Looks
like there are references to kB in code comments, so I'm fine with
changing it to that, or if you want to be absolutely clear, I could just
make it 131072 bytes ;)

Siddhesh
Rical Jasan Oct. 26, 2016, 12:04 p.m. UTC | #6
On 10/26/2016 04:30 AM, Siddhesh Poyarekar wrote:
> On Wednesday 26 October 2016 04:56 PM, Rical Jasan wrote:
>> On 10/25/2016 09:15 PM, Carlos O'Donell wrote:
>>>>> +If this parameter is not set, the default value is set as 128 KB and the
>>> Should this be 128KiB?
>>
>> I don't think binary computers count with 10 fingers.  At any rate, we
>> don't have any ibi's AFAICS:
>>
>> $ grep -Pi '\d[kmgt]i?b\b' manual/*.texi
> 
> It's the other way around AFAIK, i.e. KiB == 1024 and KB == 1000.  Looks
> like there are references to kB in code comments, so I'm fine with
> changing it to that, or if you want to be absolutely clear, I could just
> make it 131072 bytes ;)

As unambiguous as possible is best, so if you could fix the 2147483648-
and 4294967296-byte references too, that'd be great.  lol

Rical
diff mbox

Patch

diff --git a/manual/memory.texi b/manual/memory.texi
index 5383105..6f33455 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1113,12 +1113,25 @@  choices for @var{param}, as defined in @file{malloc.h}, are:
 @item M_MMAP_MAX
 The maximum number of chunks to allocate with @code{mmap}.  Setting this
 to zero disables all use of @code{mmap}.
+
+The default value of this parameter is @code{65536}.
+
+This parameter can also be set for the process at startup by setting the
+environment variable @code{MALLOC_MMAP_MAX_} to the desired value.
 @item M_MMAP_THRESHOLD
 All chunks larger than this value are allocated outside the normal
 heap, using the @code{mmap} system call.  This way it is guaranteed
 that the memory for these chunks can be returned to the system on
 @code{free}.  Note that requests smaller than this threshold might still
 be allocated via @code{mmap}.
+
+If this parameter is not set, the default value is set as 128 KB and the
+threshold is adjusted dynamically to suit the allocation patterns of the
+program. If the parameter is set, the dynamic adjustment is disabled and the
+value is set statically to the input value.
+
+This parameter can also be set for the process at startup by setting the
+environment variable @code{MALLOC_MMAP_THRESHOLD_} to the desired value.
 @comment TODO: @item M_MXFAST
 @item M_PERTURB
 If non-zero, memory blocks are filled with values depending on some
@@ -1128,16 +1141,34 @@  use of uninitialized or freed heap memory.  Note that this option does not
 guarantee that the freed block will have any specific values.  It only
 guarantees that the content the block had before it was freed will be
 overwritten.
+
+The default value of this parameter is @code{0}.
+
+This parameter can also be set for the process at startup by setting the
+environment variable @code{MALLOC_MMAP_PERTURB_} to the desired value.
 @item M_TOP_PAD
 This parameter determines the amount of extra memory to obtain from the
 system when a call to @code{sbrk} is required.  It also specifies the
 number of bytes to retain when shrinking the heap by calling @code{sbrk}
 with a negative argument.  This provides the necessary hysteresis in
 heap size such that excessive amounts of system calls can be avoided.
+
+The default value of this parameter is @code{0}.
+
+This parameter can also be set for the process at startup by setting the
+environment variable @code{MALLOC_TOP_PAD_} to the desired value.
 @item M_TRIM_THRESHOLD
 This is the minimum size (in bytes) of the top-most, releasable chunk
 that will cause @code{sbrk} to be called with a negative argument in
 order to return memory to the system.
+
+If this parameter is not set, the default value is set as 128 KB and the
+threshold is adjusted dynamically to suit the allocation patterns of the
+program. If the parameter is set, the dynamic adjustment is disabled and the
+value is set statically to the provided input.
+
+This parameter can also be set for the process at startup by setting the
+environment variable @code{MALLOC_TRIM_THRESHOLD_} to the desired value.
 @end table
 
 @end deftypefun