This directory contains two scripts of use for monitoring Perforce server
performance specifically as regards database locks.

Please e-mail comments or suggestions to dbloch@google.com.

Dan Bloch
Google
15-May-2007

----------------------------------------------------------------------
locks.pl (2006)
----------------------------------------------------------------------

The locks.pl script was discussed in my presentation at the 2006 Perforce
European User Conference, "Performance and Database Locking at Large
Perforce Sites."

This script reports on p4 commands holding locks on the live server, for
use in diagnosing server hangs while the server is hanging.

Notes:

  - locks.pl must be run on the same machine as the Perforce server.

  - It must either be run as same Unix user as Perforce server, or it
    prompts for a password to run "sudo".  This is a limitation of the
    Linux lsof command.

  - At the beginning of the script there are few constants which may
    need to be changed for your site.

  - locks.pl can be run "as is" with the -d for demo mode.  The reason
    this is considered demo mode is that if the server is hanging, the
    script may hang as well when it tries to execute the "p4 monitor show"
    command.

    "Production mode" involves a tiny separate Perforce server running
    on port 1999.  The setup.sh script will set this up.  You'll need
    to set a few constants before running this script.

  - locks.pl has been tested on Linux and is likely to run on other versions
    of Unix with minor modification.  It will not run on Windows.

usage: locks.pl [-dvk]
    -d  demo mode--doesn't require separate server running
    -v  verbose
    -k  kill long-running "p4 integrated" and "p4 changes -i" commands

The slides for the presentation are available on Perforce's web site as
http://www.perforce.com/perforce/eucon2006/presentations/Google.pdf.

----------------------------------------------------------------------
lockers.pl (2007)
----------------------------------------------------------------------

The lockers.pl script was discussed in my presentation at the 2007
Perforce User Conference, "Life on the Edge: Monitoring and Running a
Very Large Perforce Installation."

This script does error log analysis and is useful for diagnosing server
hangs after they have completed, or for determining significant users of
lock resources over a period of time.

Notes:

  - The only input used by lockers.pl is a log file so it can potentially
    be run on any machine, but it's typically run on the the Perforce
    server machine so that the current log is accessible.

  - The script accepts one or more log file names as arguments.  If the
    filename ends in ".gz", the script runs "zcat" on the file.  With no
    argument, it will process the current log file.

  - At the beginning of the script there are few constants which you will
    probably want to change for your site.  Most useful are the location
    of the current and (if you rotate your log file nightly) the previous
    day's log file.  Another constant is the number of lines to look at in
    "-z" mode.  All of these are commented further in the script.

usage: lockers.pl [-tyzkKw] [<errorlog> ...]
    -t <secs> - lock times greater than <secs> seconds only (default=15)
    -y  use yesterday's errorlog
    -z  use last 100000 lines of today's log
    -k  only show commands killed by the server (MaxScanRows, etc.)
    -K  exclude commands killed by administrator (signal 15)
    -w  include commands with wait time but no time holding locks

The slides and white paper from the presentation are available on Perforce's
web site as
http://www.perforce.com/perforce/conferences/us/2007/presentations/DBloch_Life_on_the_Edge2007.pdf (slides) and
http://www.perforce.com/perforce/conferences/us/2007/presentations/DBloch_Life_on_the_Edge2007_paper.pdf (paper)

----------------------------------------------------------------------