Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: dbf3614df92e720a9536b1cceb915a18ff2b8c08
      
https://github.com/Perl/perl5/commit/dbf3614df92e720a9536b1cceb915a18ff2b8c08
  Author: Richard Leach <richardle...@users.noreply.github.com>
  Date:   2022-11-21 (Mon, 21 Nov 2022)

  Changed paths:
    M av.c
    M perl.h
    M pp_hot.c
    M sv.c

  Log Message:
  -----------
  Extract minimum PV buffer/AV element size to common definitions

In a nutshell, for a long time the minimum PV length (hardcoded
in Perl_sv_grow) has been 10 bytes and the minimum AV array size
(hardcoded in av_extend_guts) has been 4 elements.

These numbers have been used elsewhere for consistency (e.g.
Perl_sv_grow_fresh) in the past couple of development cycles.
Having a standard definition, rather than hardcoding in multiple
places, is more maintainable. This commit therefore introduces
into perl.h:

    PERL_ARRAY_NEW_MIN_KEY
    PERL_STRLEN_NEW_MIN

(Note: Subsequent commit(s) will actually change the values.)


  Commit: 06dbfffcf611d03ad6078d4049e84de53458f9c9
      
https://github.com/Perl/perl5/commit/06dbfffcf611d03ad6078d4049e84de53458f9c9
  Author: Richard Leach <richardle...@users.noreply.github.com>
  Date:   2022-11-21 (Mon, 21 Nov 2022)

  Changed paths:
    M perl.h

  Log Message:
  -----------
  PERL_STRLEN_NEW_MIN - increase to multiple of pointer sizes

Major malloc implementations, including the popular dlmalloc
derivatives all return chunks of memory that are a multiple of
the platform's pointer size. Perl's traditional default string
allocation of 10 bytes will almost certainly result in a larger
allocation than requested. Consequently, the interpreter may try
to Renew() an allocation to increase the PV buffer size when it
does not actually need to do so.

This commit increases the default string size to the nearest
pointer multiple. (12 bytes for 32-bit pointers, 16 bytes for
64-bit pointers). This is almost certainly unnecessarily small
for 64-bit platforms, since most common malloc implementations
seem to return 3*pointer size (i.e. 24 bytes) as the smallest
allocation. However, 16 bytes was chosen to prevent an increase
in memory usage in memory-constrained platforms which might have
a smaller minimum memory allocation.


Compare: https://github.com/Perl/perl5/compare/b17e77fbd875...06dbfffcf611

Reply via email to