Perforce 2000.1 System Administrator's Guide (2000.1.sa.3) | ||
<< Previous Chapter Scripting Perforce: Daemons and Triggers |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and NT |
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 is heavily-dependent 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.
Issues with NFS file locking may arise if a Perforce server's database and versioned files are stored on an NFS-mounted volume. Database updates over NFS can be a problem, and file locking is generally slow; if the journal is NFS-mounted, all operations will be slower. Consequently, we strongly recommend that the Perforce database, depot, and journal files be stored on disks local to the machine running the Perforce server process.
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 will require 0.5KB per user per file. (i.e. A system with 10,000 files and 50 users will require 250M of diskspace 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 will depend on the size of the original files stored and will grow as revisions are added. For most sites, allocate at least three times the 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 diskspace for anticipated growth" on page 15.
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 (i.e. "Using branch views" on page 71 and "The temporary client trick" on page 71) rely on similar techniques. By limiting the size of the view available to the command, fewer commands need to be run, and those that are run 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 will be 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, e.g.:
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 GUI, 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 it also belonged to another group, the limit in that group would also apply to them. You can get around this by assigning a very high maxresults limit to your superusers group. For example:
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, consider 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 named "-" (i.e., 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 running this p4 command instead:
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 will re-create the trees in a balanced manner; 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 (i.e. rebalance the trees) for performance reasons.
Perforce 2000.1 System Administrator's Guide (2000.1.sa.3) | ||
<< Previous Chapter Scripting Perforce: Daemons and Triggers |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and NT |