Perforce 2005.1 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Triggers and Daemons |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and Windows |
The following chapter briefly outlines some of the factors that can affect the performance of a Perforce server, provides a few tips on diagnosing network-related difficulties, and offers some suggestions on decreasing server load for larger installations.
For most installations, a system with enough RAM for 1.5KB per file in the depot will suffice.
The only disk-intensive activity is file check-in, where the Perforce server must write and rename files in the archive. Server performance depends heavily upon the operating system's filesystem implementation, and in particular, whether directory updates are synchronous.
Although Perforce does not recommend any specific filesystem, Linux servers are generally fastest (owing to Linux's asynchronous directory updating), but may have poor recovery if power is cut at the wrong time. The BSD filesystem (also used in Solaris) is relatively slow, but much more reliable. NTFS performance falls somewhere in between these two ranges. The filesystems used by IRIX and OSF have demonstrated an excellent combination of both speed and robustness.
Performance in systems where database and versioned files are stored on NFS-mounted volumes is typically dependent on the implementation of NFS in question and/or the underlying storage hardware. Perforce has been tested and is supported under the Solaris implementation of NFS.
Under Linux and FreeBSD, database updates over NFS can be an issue as file locking is relatively slow; if the journal is NFS-mounted on these platforms, all operations will be slower. In general (but in particular on Linux and FreeBSD) we recommend that the Perforce database, depot, and journal files be stored on disks local to the machine running the Perforce server process.
These issues affect only the Perforce Server process (p4d). Perforce client programs, (such as p4, the Perforce Command-Line Client) have always been able to work with client workspaces on NFS-mounted drives (for instance, workspaces in users' home directories).
The client file space required is the size of the files that your users will need in their client workspaces at any one time.
The server's database size can be calculated with a fair level of accuracy; as a rough estimate, it requires 0.5KB per user per file. (For instance, a system with 10,000 files and 50 users will require 250MB of disk space for the database). The database can be expected to grow over time as histories of the individual files grow.
The size of the server's archive of versioned files depends on the sizes of the original files stored and grows as revisions are added. For most sites, allocate space equivalent to at least three times the aggregate size of the original files.
If you anticipate your database growing into the gigabyte range, you should ensure that your platform has adequate support for large filesystems. See "Allocate disk space for anticipated growth" on page 20.
The db.have file holds the list of files opened in client workspaces, and tends to grow more rapidly than other files in the database. If you are experiencing issues related to the size of your db.have file and are unable to quickly switch to a server with adequate support for large files, deleting unused client workspace specifications and reducing the scope of client workspace views can help alleviate the problem.
Perforce uses a TCP/IP connection for each client interaction with the server. The server's port address is defined by P4PORT, but the TCP/IP implementation picks a client port number. After the command completes and the connection is closed, the port is left in a state called TIME_WAIT for two minutes. While the port number ranges from 1025 to 32767, generally only a few hundred or thousand can be in use simultaneously. It is therefore possible to occupy all available ports by invoking a Perforce client command many times in rapid succession, such as with a script.
Before release 99.2, both the server and client side of the connection remained in TIME_WAIT, which meant that a script running on one user's machine could deprive other users of service by tying up all available ports on the server side. As of Release 99.2, only the client side goes into TIME_WAIT, leaving the Perforce server free to handle other clients.
In general, CPU power is not a major consideration when determining the platform on which to install a Perforce server.
P4PORT=host.domain:1666
try using:
P4PORT=1.2.3.4:1666
with your site-specific IP address and port number.
On most systems, you can determine the IP address of a host by invoking:
ping hostname
If p4 info responds immediately when you use the IP address, but not when you use the hostname, the problem is likely related to DNS.
If P4Win returns the information quickly, but p4 info is slow, you have a DNS-related problem. (When the Perforce server receives a p4 info request from either the command line or from P4V, the server performs a reverse name lookup in order to send back both the client and server hostnames along with other configuration information. When the server receives a P4Win"Show Connection Info" request, however, it simply returns the IP addresses.)
Note |
This test is only valid for Release 99.1 and newer servers. Perforce Servers prior to 99.1 always perform a reverse name lookup. |
p4 files //depot/*
can result in a delayed response on Windows. You can prevent the delay by putting double quotes around the file pattern, like so:
p4 files "//depot/*"
The cause of the problem is the p4 command's use of a Windows function to expand wildcards. When quotes are not used, the function interprets //depot as a networked computer path and spends time in a futile search for a machine on the network named depot.
The corresponding UNIX file is /etc/hosts.
p4 -V
This merely prints out the version information, without attempting any network access. If you get a slow response, network access to the p4 executable itself may be the problem. Copying or downloading a copy of p4 onto a local filesystem should improve response times.
The number of files affected by a single command is largely determined by:
At sites with very large depots, unrestricted views and unqualified commands will make a Perforce server work much harder than it needs to. Users and administrators can ease load on their servers by:
In the loose view, the entire depot was mapped into the client workspace; for most users, this can be "tightened" considerably. The following view, for example, is restricted to specific areas of the depot:
Client views, in particular, but also branch views and label views, should also be set up to give users just enough scope to do the work they need to do.
Client, branch, and label views are set by a Perforce administrator or by individual users with the p4 client, p4 branch, and p4 label commands respectively.
Two of the techniques for script optimization (described in "Using branch views" on page 121 and "The temporary client trick" on page 122) rely on similar techniques. By limiting the size of the view available to a command, fewer commands need to be run, and when run, the commands require fewer resources.
Unlike client, branch, and label views, however, the views used by protections can be set only by Perforce superusers. (Protections also control read and write permission to depot files, but the permission levels themselves have no impact on server performance.) By assigning protections in Perforce, a Perforce superuser can effectively limit the size of a user's view, even if the user is using "loose" client specifications.
Protections can be assigned to either users or groups. For example:
write user sam * //depot/admin/... |
Perforce groups are created by superusers with the p4 group command. Not only do they make it easier to assign protections, but they provide useful fail-safe mechanisms in the form of maxresults and maxscanrows, described in the next section.
Users in such groups are unable to run any commands which affect more database rows than the group's maxresults limit. (For most commands, the number of database rows affected is roughly equal to the number of files affected.)
Like maxresults, maxscanrows prevents certain user commands from placing excessive demands on the server. (For most commands, the number of rows that could be scanned is roughly equal to the number of files affected, multiplied by the average number of revisions per file in the depot.)
To set these limits, fill in the Maxresults: or Maxscanrows: field in the p4 group form. If a user is listed in multiple groups, the highest of the maxresults (or maxscanrows) limits (but not including the default "unlimited" setting) for those groups is taken as the user's maxresults (or maxscanrows) value.
As an administrator, you wish members of the group rocketdev to be limited to operations
of 20,000 files or less, and to scan no more than 100,000 revisions:
Suppose that Ruth has an unrestricted ("loose") client view. When she types:
her sync command is rejected if the depot contains more than 20,000 files. She can work
around this limitation either by restricting her client view, or, if she needs all of the files in the
view, by syncing smaller sets of files at a time, as follows:
p4 sync //depot/projA/...
p4 sync //depot/projB/...
Either method enables her to get her files, but without tying up the server to process a single
extremely large command.
If Ruth tries a command that scans every revision of every file, such as:
and there are less than 20,000 files, but more than 100,000 revisions (perhaps the projA
directory contains 8000 files, each of which has 20 revisions), the maxresults limit does not
apply, but the maxscanrows limit does.
To remove any limits on the number of result lines processed (or database rows scanned) for a particular group, set the Maxresults: or Maxscanrows: value for that group to unlimited.
As these limitations can make life difficult for your users, do not use them unless you find that certain operations are slowing down your server. The Maxresults: value should never be less than 10,000, since certain operations performed by P4Win, the Perforce Windows Client, may require a Maxresults: value of between 5,000 and 8,000. Similarly, Maxscanrows should rarely need to be set below 50,000.
For more information, including a comparison of Perforce commands and the number of files they affect, type:
p4 help maxresults
from the command line.
p4 help maxscanrows
A side effect of this is that you can't create a group that assigns "unlimited" maxresults values to superusers, because if any of the users in such a group were to belong to another group, the "unlimited" limit from the superuser group would also apply to them. You can get around this by assigning a very high maxresults limit to your superusers group.
(The largest possible maxresults or maxscanrows limit is platform-dependent; on most platforms, this is a 32-bit integer.)
This section points out some common efficiency problems and solutions.
To this end, scripts should never iterate through files running Perforce commands when they can accomplish the same thing by running one Perforce command on a list of files and iterating through the command results.
For example, try an approach like this:
for i in `p4 diff2 path1/... path2/...`
Instead of this:
do
[process diff output]
done
for i in `p4 files path1/...`
do
p4 diff2 path1/$i path2/$i
[process diff output]
done
For example, if your script currently does something like:
for components in header1 header2 header3
...a more efficient alternative would be:
do
p4 edit ${component}.h
done
for components in header1 header2 header3
The -x flag instructs p4 to read arguments, one per line, from the named file. If the file is specified as "-" (a dash), the standard input is read.
do
echo ${component}.h >> LISTFILE
done
p4 -x LISTFILE edit
p4 diff2 pathA/src/... pathB/src/...
you can make it more efficient by creating a branch view that looks like this:
p4 diff2 pathA/tests/... pathB/tests/...
p4 diff2 pathA/doc/... pathB/doc/...
Branch: pathA-pathB |
and replacing the three commands with one:
p4 files path/...@label | egrep "path/f1.h|path/f2.h|path/f3.h"
will impose a lighter load on the Perforce server than either this:
p4 files path/f1.h@label path/f1.h@label path/f3.h@label
or this:
p4 files path/f1.h@label
The "temporary client" trick described below may also reduce the number of times you have to refer to files by label.
p4 files path/f2.h@label
p4 files path/f3.h@label
For instance, suppose your script runs these commands:
p4 sync pathA/src/...@label
You can combine the command invocations and reduce the three label scans to one by using a client spec that looks like:
p4 sync pathB/tests/...@label
p4 sync pathC/doc/...@label
Client: XY-temp |
Some file formats (for example, .GIF and .JPG images, .MPG and .AVI media content, files compressed with .gz and .ZIP compression) include compression as part of the file format. Attempting to compress such files on the Perforce Server results in the consumption of server CPU resources with little or no savings in disk space.
To disable server storage compression for these file types, specify such files as type binary+F (binary, stored on the server in full, without compression) either from the command line or from the p4 typemap table.
For more about p4 typemap, including a sample typemap table, see "Defining filetypes with p4 typemap" on page 48.
Eventually, the tree may become sufficiently unbalanced that performance is negatively affected. The Perforce checkpoint and restore processes (see "Backup and Recovery Concepts" on page 25) re-create the trees in a balanced manner, and consequently, you may see some increase in server performance following a backup, a removal of the db.* files, and the re-creation of the db.* files from a checkpoint.
Rebalancing the trees is normally only useful if the database files have become more than about 10 times the size of the checkpoint. Given the length of time required for the trees to become unbalanced during normal Perforce use, we expect that the majority of sites will never need to restore the database from a checkpoint (that is, rebalance the trees) for performance reasons.
Perforce 2005.1 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Triggers and Daemons |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and Windows |