NAME
Thread::Benchmark::Size - report size of threads for different code approaches
SYNOPSIS
use Thread::Benchmark::Size times => 5, noexport => <<'E1', export => <<'E2';
use threads::shared ();
E1
use threads::shared;
E2
DESCRIPTION
*** A note of CAUTION ***
This module only functions on Perl versions 5.8.0 and later.
And then only when threads are enabled with -Dusethreads. It
is of no use with any version of Perl before 5.8.0 or without
threads enabled.
*************************
The Thread::Benchmark::Size module allows you to check the effects of different approaches to coding threaded application on the amount of RAM used. One or more approaches can be checked at a time, each tested 5 times by default. Testing is done for 0, 1, 2, 5, 10, 20, 50 and 100 threads. The final report is sent to STDOUT.
This is an example report:
# shared0 shared1 shared2 shared3
0 2296 2304 2336 2340
1 2824 2804 2852 2856
2 3238 3208 3264 3280
5 4428 4416 4492 4516
10 6406 6412 6540 6588
20 10378 10414 10636 10714
50 22264 22404 22906 23098
100 42090 42388 43348 43736
==== shared0 =====================================================
use threads::shared ();
==== shared1 =====================================================
use threads::shared;
==== shared2 =====================================================
use threads::shared ();
my $shared : shared;
lock( $shared );
threads::shared::cond_signal( $shared );
==== shared3 =====================================================
use threads::shared;
my $shared : shared;
lock( $shared );
cond_signal( $shared );
==================================================================
The sizes given are the numbers that were obtained from the system for the size of the process. This is usually in Kbytes but could be anything, depending on how the information about the memory usage is obtained.
SUBROUTINES
There are no subroutines to call: all values need to be specified with the use
command.
WHAT IT DOES
This module started life as just a number of scripts. In order to facilitate distribution I decided to bundle them together into this module. So, what does happen exactly when you execute this module?
- create ramthread
-
This is the main script that does the testing. It collects the data that is written out to STDOUT by ramthread1.
- create ramthread1
-
This is the script that gets called for each seperate test. It creates a special test-script "_test_ramthread" for each test and each number of threads to be checked (to avoid artefacts from previous runs in the same interpreter), then measures the size of memory for each number of threads running simultaneously and writes out the result to STDOUT.
- create files for each piece of code
-
For several (historical) reasons, a seperate file is created for each piece of code given. These files are used by ramthread1 to measure the amount of memory used. The identification of the code is used as the filename, so be sure that this will not overwrite stuff you might need later.
- run ramthread
-
The ramthread script is then run with the appropriate parameters. The output is sent to STDERR (progress indication) and STDOUT (final report).
- remove all files that were created
-
Then all of the files (including the ramthread and ramthread1 script) are removed, so that no files are left behind.
All files are created in the current directory. This may not be the best place, but it was the easiest thing to code.
HOW TO MEASURE SIZE?
Currently the size of the process is measured by doing a:
ps --no-heading -o rss $pid
However, this may not be as portable as I would like. If you would like to use Thread::Benchmark::Size on your system and the above doesn't work, please send me a string for your system that writes out the size of the given process to STDOUT and the condition that should be used to determine that that string should be used instead of the above default.
AUTHOR
Elizabeth Mattijsen, <liz@dijkmat.nl>.
Please report bugs to <perlbugs@dijkmat.nl>.
COPYRIGHT
Copyright (c) 2002 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.