Perforce 2001.1 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Daemons and Triggers |
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 clients (such as the p4 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 250M 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 label contents and the list of files opened in client workspaces, and tends to grow the faster 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 clients and labels and reducing the scope of client views can help alleviate the problem.
Perforce uses a TCP 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 the former is fast and the latter is slow, you have a DNS-related problem. (When the Perforce server receives a p4 info request, it does a reverse name lookup in order to send back the client and server hostnames along with other configuration information. When it 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. In releases prior to 99.1, the server always did a reverse name lookup, whether the request was coming from p4 info or P4win |
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 the Perforce superuser 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 100 and "The temporary client trick" on page 101) 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 a useful fail-safe mechanism called maxresults, described in the next section.
To set this limit, fill in the Maxresults: field in the p4 group form. The number in this field specifies the maximum number of rows of data that can be operated on by a single command. If a user is listed in multiple groups, the highest of the maxresults limits (but not including the default "unlimited" setting) for those groups is taken as the user's maxresults value.
As an administrator, you wish members of the group rocketdev to be limited to operations
of 20,000 files or less:
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, like so:
p4 sync //depot/projA/...
p4 sync //depot/projB/...
Either way, she'll get her files, but without tying up the server to process a single extremely
large command.
To leave unlimited the number of result lines processed for a particular group, set the Maxresults: value for that group to unlimited.
Since maxresults values 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.
For more information, including a comparison of Perforce commands and the number of files they affect, type:
p4 help maxresults
from the command line.
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 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 foo bar ola
a more efficient alternative would be:
do
p4 edit ${component}.h
done
for components in foo bar ola
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/foo.h|path/bar.h|path/ola.c"
will impose a lighter load on the Perforce server than either this:
p4 files path/foo.h@label path/bar.h@label path/ola.h@label
or this:
p4 files path/foo.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/bar.h@label
p4 files path/ola.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
Eventually, the tree may become sufficiently unbalanced that performance is negatively affected. The Perforce checkpoint and restore processes re-create the trees in a balanced manner, and consequently, you may see some increase in server performance following a restoration 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 2001.1 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Daemons and Triggers |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and Windows |