[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: perl: 64-bit integers and long doubles



On Sun, May 09, 2010 at 12:17:56PM +0200, Florian Weimer wrote:

> So it boils down to malloc granularity (I don't think Perl's allocator
> is used on Debian).  For that, I wrote this little test program:

While we do use the system malloc(), I think Perl allocates bigger chunks
at a time and thus avoids these granularity problems. From sv.c:

  In all but the most memory-paranoid configuations (ex: PURIFY), heads
  and bodies are allocated out of arenas, which by default are
  approximately 4K chunks of memory parcelled up into N heads or bodies.
  Sv-bodies are allocated by their sv-type, guaranteeing size
  consistency needed to allocate safely from arrays.

> So if this analysis is correct, due to malloc granularity, this change
> should not have a significant space overhead (the IV type is used in
> other places, too, but SVs are the most sensitive place, I guess).

> It's best to double-check all this by compiling Perl with the
> appropriate flags, though.

Testing 5.12.0 with and without use64bitint on x86 shows an approximately
10% increase with scalars and arrays:

 perl -e '${"v$i"} = $i while ($i++ < $ARGV[0]); system("ps -o rss $$")' 1000000
 perl -e '$a[$i++] = $i while ($i++ < $ARGV[0]); system("ps -o rss $$")' 10000000

and a 7-8% increase for hashes:

 perl -e '$h{$i++} = $i while ($i++ < $ARGV[0]); system("ps -o rss $$")' 5000000

Tracing the malloc calls indeed shows that only the allocation of 4k
areas increases significantly.

Somewhat more limited tests on agricola.d.o (5.10.1 without use64bitint vs.
5.12.0 with use64bitint) indicate similar results.

I don't think this gives any definite answer (expect "you can't please
everybody").

I'm partial to enabling use64bitint on all architectures, if only for the
sake of uniformity already mentioned in the uselongdouble discussion: bugs
that only happen on the "smaller" architectures because of differences
like this are not nice to isolate and debug.

And I expect pointers to gigabyte files are not an uncommon thing to
need on arm systems either.
-- 
Niko Tyni   ntyni@debian.org


Reply to: