Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reducing memory usage (for threads)

0 views
Skip to first unread message

Elizabeth Mattijsen

unread,
Sep 25, 2002, 1:48:52 PM9/25/02
to perl5-...@perl.org
In order to determine ways of reducing memory usage with perl, and with
threaded perl in particular, I will be annoying p5p with some memory
benchmarks in the coming time. I would like to have these benchmarks give
us an idea of what works and what doesn't work to reduce memory, with
threads in mind particularly (although some finding may be more generally
applicable).

You will see many small numbers, typically between 1/1000 and 1/100 of the
total memory used, or absolutely in the range of 250 bytes to a few K. It
should however be realised that the numbers found usually apply per thread
_and_ per module loaded. So assuming you have 10 modules loaded (which is
about the minimum when you're using threads), and you would be able to save
1K of memory for each module, then you would be saving 10K per
thread. Which quickly grows to 1 Mbyte if you're running with 100 threads.

All of the benchmarks I will be sending to p5p will have the [Memory]
indicator in the subject. So you should be able to ignore them without
having to read them.

All the benchmarks are based on the Benchmark::Thread::Size module,
available from CPAN (renamed from Thread::Benchmark::Size, as suggested by
Arthur Bergman). I can only do these benchmarks on Linux systems. I would
appreciate it if other people could run these benchmarks on the same or
other architectures to really see if they are applicable generally.

Typical source for a test is as easy as:

=== testvars =============================================================
use Benchmark::Thread::Size bare => <<'EOD1', full => <<'EOD2', vars =>
<<'EOD3', our => <<'EOD4', unique => <<'EOD5';
$VERSION = '0.01';
EOD1
$main::VERSION = '0.01';
EOD2
use vars qw($VERSION);
$VERSION = '0.01';
EOD3
our $VERSION = '0.01';
EOD4
our $VERSION : unique = '0.01';
EOD5
==========================================================================

Thank you all for your time! And hopefully we'll be able to make Perl 5 a
meaner and leaner beast.


Liz

0 new messages