Using Shore with Purify & Quantify

Or, in other words, how to use shore with the Pure Software products.

Yes, Pure Software was purchased by Rational, and then I think IBM either purchased Rational, or the Pure software products from them. I still refer to it as Pure Software since that is how Shore thinks of it!

Note that shore has a long (10 year?) history with these products, and is more or less engineered around how things have been for a long time. There is some adaptation to recent layout and library name changes, which fortunately did not have big effects.

These instructions work for Purify and Quantify here at the CS department. They should be easily adaptable to anyone else who is using these products. If you are at the end of your wits trying to Purify or Quantify with Shore, you can always send an email so I can try to see what is going wrong for you.


Purifying with Shore

Purify works quite well with Shore. When configured to use Purify, Shore will make Pure and Purify specific calls to aide and inform purify (and the user) of its progress and status.

To configure shore to use Purify you will need to do the following:

  1. You need to configure shore to support purify. To do that, edit shore.def and add the following options:
    #define USE_PURIFY
    #define PURIFY_ZERO

    The USE_PURIFY option configures both the shore build and runtime system to know about Purify and to use them appropriately. The PURIFY_ZERO option tells shore to zero holes in its data structures and various data types so that purify will not complain about copying uninitialized data.

  2. After that you will need to make clean and then rebuild (and reinstall) as necessary the shore tree.

Once Shore is configured and built with support for Purify, you would most likely like to see a demo and verify that the base version of Shore that you are using doesn't have any problems in and of itself.

To do this, and to see an example at the Imakefile and Makefile level of what you need to to, please use and examine ssh, the Shore SHell ... and yes before you ask, it predates the other ssh by many years.

cd src/smlayer/sm/ssh
make ssh
make ssh.pure
./ssh.pure

Shore has some nice built-in support for purify; it has its own thread package interface which purify uses to understand Shore's sthread threads. If you run a purified shore executable in a debugger, you can add a breakpoint for purify_stop_here. If purify finds something that generates a warning, it will execute that breakpoint ... and voila, you will be there in the debugger to look at the context in which the purify event occured.


Quantifying with Shore

I mentioned earlier that Purify and Shore work very well together. The good news is that Quantify works correctly with Shore, and does allow you to gather performance numbers which are useful and revealing. The bad news is that you can't use a normal version of Shore to Quantify an executable.

Why you ask? Well, the problem is that Quantify isn't using the Pure threads interface properly, or is doing something hokey ... and it doesn't work correctly with Shore's native sthread thread-cores. Fortunately, you can use the pthread (Posix threads) based sthread thread-core with Quantify and it works. This has not always been the case; it has worked in the past, but is very dependenent upon what version of Quantify is used, and what it does.

What does it mean? You aren't quantifying exactly the same system you are using in production. However, the changes are really quite minimal, basically only involving how the individual threads are switched, and the system will perform almost the same... Except for such oddities as where the thread stacks are located, the size of some thread-package-internal data structures, etc. Thread switching will take longer, but that really doesn't show up much compared to the large overhead that Quantify itself imposes. Let me note that Purify will work OK with the pthread thread-cores, so you can also Purify the same base executable.

This is how you go about setting up shore to use Quantify:

  1. Edit shore.def to prepare the system for Quantify:
    #define USE_QUANTIFY
    #define STHREAD_CORE_PTHREAD
    #define LINK_PTHREAD

    The USE_QUANTIFY option configures both the shore build and runtime system to know about Quantify and to use them appropriately. The STHREAD_CORE_PTHREAD option tells the Shore threads layer to use pthread thread-cores for the saved thread state. The LINK_PTHREAD option links the resulting executables against the Posix threads library. While not needed on some systems, it doesn't hurt.

  2. After that you will need to make clean and then rebuild (and reinstall) as necessary the shore tree.

At this point, you can just Quantify and run an executable to get performance info. Again, I will use ssh as an example:

cd src/smlayer/sm/ssh
make ssh
make ssh.quant
./ssh.quant

As you start the executable, Quantify will display its X-window control console. Once execution completes and Quantify has generated its performance information you will be able to examine it through the graphical interface.

Remember that you can also configure the same system with Purify; the two are orthogonal to each other. The build system will resolve whatever differences are needed. However, the versions of Purify and Quantify should be compatible with each other, since the various data structures and signatures and such that are compiled into shore must work with both.


Random Notes

WARNING If you are purifying or quantifying something besides ssh you will need to copy the purify config files to use. These files have directives about what parts of the system shouldn't be purified, and how other parts of the system should be purified.
If you don't do this, you will need to clean all the purified shore libraries and executables up and re-purify the system. Otherwise, it just won't run because it will have been built incorrectly by purify.

cd /your/directory
cp /path/to/shore/src/smlayer/sm/ssh/.purify* ./

I recommend configuring the various Pure software products with the following options to make their use as effective as possible. Note that these are runtime options to pure software. While some could be specified in the shore build system, it would still be necessary to specify these options at runtime.

Note that I show /bin/sh syntax below, if you use a csh variant you should know what to do...

  1. Provide a private location for the various Purified and Quantified system libraries and such. While the default mechanism works OK, I Strongly recommend doing this to keep chaos to a minimum. Otherwise you are dependent upon the other people using purify, and their config files. What you want to do is:
    PUREOPTIONS=-cache-dir=/some/private/local/dir
    export PUREOPTIONS
  2. For Purify use a longer call-stack chain length than normal. I find that when Purifying c++ programs that if you leave the system at its default number of levels, that you DO NOT receive enough context -- especially around memory and resource allocation -- to be able to determine what is happening from the summaries:
    PURIFYOPTIONS="-chain-length=16"
    export PURIFYOPTIONS

Bolo's Home Page
Last Modified: Mon Nov 17 17:22:50 CST 2003
Bolo (Josef Burger) <bolo@cs.wisc.edu>