Chapter 8. Miscellaneous Commands

This chapter describes SpeedShop commands for exploring memory usage and paging, and for printing data files generated by SpeedShop tools. It contains the following sections:

Using the thrash Command

The thrash command allows you to explore paging behavior by allocating a region of virtual memory and accessing that memory either randomly or sequentially.

thrash Syntax

The syntax for the thrash(1) command is as follows:

thrash args [-n 
count] [-s] [
-w time]
  • args can be one of the following options:

    • -k n : the amount of memory to access in kilobytes, where n is the number of kilobytes. The minimum value for n is the size of one page, or the value will be changed appropriately.

    • -m n: the amount of memory to access in megabytes, where n is the number of megabytes.

    • -p n: the amount of memory to access in pages, where n is the number of pages.

  • -n [count]: the number of references to make before exiting. The default is 10,000.

  • -s: sequential thrashing. The default is random.

  • -w time: an integer amount of time, in seconds, thrash should sleep after thrashing but before exiting. The default is 0 seconds.

Effects of thrash

After the memory is allocated, thrash prints a message on stdout, saying how much memory it is using and then proceeds to access it. The following is an example:

% thrash -m 4

thrashing randomly: 4.00 MB (= 0x00400000 = 4194304 bytes = 1024 pages)

        10000 iterations

You can use thrash in conjunction with ssusage(1) and squeeze(1) to determine the approximate available working memory on a system, as described in “Calculating the Working Set of a Program”.

Using the squeeze Command

The squeeze command lets you specify an amount of virtual memory to lock down into real memory, thus making it unavailable to other processes. This command can be used only in superuser mode.

squeeze Syntax

The syntax for the squeeze(1) command is as follows:

squeeze [unit] 
amount

The following arguments are used:

  • unit: can be one of the following options indicating the unit of measure. If no option is specified, the default is megabytes.

    • -k: kilobytes

    • -m: megabytes

    • -p: pages

    • -%: a percentage of the installed memory

  • amount: the amount of memory to be locked.

Effects of squeeze

The squeeze(1) command performs the following operations:

  • Locks down the amount of virtual memory you supply as an argument to the command.

  • Prints a message to stdout that provides information on how much memory has been locked and how much working memory is available.

  • Sleeps indefinitely, or until interrupted by SIGINT or SIGTERM. At that time, it frees up the memory and exits with an exit message.

Wait until after the exit message is printed before doing any experiments.

Here is an example that locks down 4 megabytes of memory:

% squeeze 4
squeeze: leaving 60.00 MB ( = 0x03c01000 = 62918656 ) available memory;
         pinned 4.00 MB ( = 0x00400000 = 4194304 ) at address 0x1000e000;
         from 64.00 MB ( = 0x04001000 = 67112960 ) installed memory.

Use Ctrl-C to exit squeeze. The following message is printed:

squeeze exiting

Calculating the Working Set of a Program

You can use the thrash, squeeze, and ssusage commands together to determine the approximate working set of a program. For all practical purposes, the working set of your program is the size of memory allocated. The following procedure assumes that you are running on a system that is either stand-alone or where the environment will not change while you are running these tests.

Procedure 8-1. Calculating the Working Set

  1. Determine the working set of the kernel and other applications:

    • Choose a machine that has a large amount of physical memory (enough to allow your target application to run without any paging other than at startup).

    • Make sure that the machine is running a minimal number of applications that will remain fairly consistent for the duration of these steps.

    • Run thrash with ssusage to determine the working set of the kernel and any other applications you have running.

      In this example, the thrash command uses 4 MB of memory:

      % ssusage thrash -m 4

      When the thrash command completes, ssusage prints the resource usage of thrash. The value labeled majf gives the number of major page faults (that is, the number of faults that required a physical I/O). When you run on a machine with a large amount of physical memory, this value is the number of faults needed to start the program, which is the minimum number for any run. For more information on ssusage, see Chapter 5, “Collecting Data on Machine Resource Usage”.

    • As super user in a separate window, run the squeeze command to lock down an amount of memory.

    • Rerun thrash with ssusage, as shown here:

      % ssusage thrash -m 4

    • Repeat the previous two steps, increasing the amount of memory for squeeze, until the majf number begins to rise.

      The amount of working memory available reported by squeeze at the point at which page faults begin to rise for thrash tells you the combined working set of thrash (approximately 4 MB), the kernel, and any other applications you have running.

    • Deduct the 4 MB that thrash uses from the amount of working memory reported by squeeze at the point the page faults began to rise.

      This computation helps you find the approximate base working set of the kernel and any other applications that are running on the machine. You will need this number when you reach the next steps.

  2. Determine the working set of the kernel and other applications:

    • The applications that the machine is running should remain consistent with the machine in the first step.

    • Run ssusage with your program to ensure that the machine has the amount of memory your program needs.

      % ssusage prog_name

      When your program exits, ssusage prints the application's resource usage. The majf field gives the number of major page faults. When run on a machine with a large amount of physical memory, this value is the number of faults needed to start the program, which is the minimum number for any run.

    • In another window, become super user.

    • In this new window, run squeeze to lock down an amount of memory. The following example locks down 15 megabytes of memory:

      % squeeze 15

    • In the first window, rerun your program with ssusage.

    • In the second window running squeeze, enter ctrl-c to cause squeeze to exit.

    • Repeat these steps, using squeeze to lock down increasing amounts of memory until the majf number begins to rise.

    • Deduct the amount squeezed at the point at which the application begins to page fault from the total amount of physical memory in the system. This computation determines the combined working set of your program, the kernel, and any other applications you have running.

  3. Calculate the working set size of your program.

    Deduct the amount of working memory calculated in step 1g from the combined working set size calculated in step 2h. This computation determines the approximate working set of your program.

Converting an MPI Experiment File to Vampir Format

The vampir software product displays and analyzes Message Passing Interface (MPI) experiment files. It is a product of Pallas, a software company specializing in high performance computing. For more information on the company and the vampir software, see the following web site:

http://www.pallas.com

The ssfilter(1) command converts a SpeedShop MPI experiment file into a form in which it can be viewed using vampir. For information on generating MPI experiment files, see “Running Experiments on MPI Programs” in Chapter 6.

The following commands generate a pcsampx experiment file on each of the four processors involved in the MPI program and converts them to a single file in vampir format:

mpirun -np 4 ssrun -pcsampx myprog
ssfilter myprog.mpi.f* -o myprog.vampir

By default, ssfilter periodically returns status information while it is processing. The status tells you what percentage of its job is complete and what percentage remains to be done. You can turn the status messages off by specifying the -noverbose option. For information on all of the options, see the ssfilter (1) man page.