Perforce 2007.2 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Triggers and Daemons |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and Windows |
This 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 enough1.5 kilobytes of RAM per file in the depot suffices.
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 on the operating system's filesystem implementation, and in particular, on 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 they 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 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 because 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.5 kilobytes per user per file. (For instance, a system with 10,000 files and 50 users requires 250 MB 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 sufficient disk space for anticipated growth" on page 20.
The db.have file holds the list of files opened in client workspaces. This file 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.
//depot/... 34161 files 277439099 bytes 5429111 blocks |
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. Although 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.
On most systems, you can determine the IP address of a host by invoking:
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 valid only for Release 99.1 and newer servers. Perforce servers prior to 99.1 always perform a reverse name lookup. |
The number of files affected by a single command is largely determined by:
At sites with very large depots, unrestricted views and unqualified commands make a Perforce server work much harder than it needs to. Users and administrators can ease load on their servers by:
//depot/... //workspace/... |
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:
//depot/main/srv/devA/... //workspace/main/srv/devA/... |
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 129 and "The temporary client workspace trick" on page 130) 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, they also 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 that 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.)
Finally, MaxLockTime is used to prevent certain commands from locking the database for prolonged periods of time. Set MaxLockTime to the number of milliseconds for the longest permissible database lock.
To set these limits, fill in the appropriate fields in the p4 group form. If a user is listed in multiple groups, the highest of the MaxResults (or MaxScanRows, or MaxLockTime) limits (but not including the default unlimited setting) for those groups is taken as the user's MaxResults (or MaxScanRows, or MaxLockTime) value.
As an administrator, you want members of the group rocketdev to be limited to operations
of 20,000 files or less, that scan no more than 100,000 revisions, and lock database tables for
no more than 30 seconds:
Group: rocketdev |
Suppose that Ruth has an unrestricted ("loose") client view. 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:
Either method enables her to sync her files to her workspace, but without tying up the server
to process a single extremely large command.
Ruth tries a command that scans every revision of every file, such as:
If there are fewer 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.
Regardless of which limits are in effect, no command she runs will be permitted to lock the
database for more than the MaxLockTime of 30000 milliseconds.
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.
Because 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, because certain operations performed by P4Win, the Perforce Windows Client, can require a MaxResults: value 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:
A side effect of this behavior is that you can't create a group that assigns unlimited values to superusers, because if any of the users in your group of superusers belong to any other group with a numeric limit on MaxResults, the highest of the other groups' numeric limits is the limit that applies. An effective workaround for this situation is to set a very high MaxResults limit for your superusers group.
Group: superusers |
(The largest possible MaxResults, MaxScanRows, or MaxLockTime 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 a more efficient approach like this:
For example, if your script might look something like this:
Branch: pathA-pathB |
...and replacing the three commands with one:
For instance, suppose your script runs these commands:
Client: XY-temp |
Using this workspace specification, you can then run:
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 can 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 might 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 useful only 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 2007.2 System Administrator's Guide | ||
<< Previous Chapter Scripting Perforce: Triggers and Daemons |
Table of Contents Index Perforce on the Web |
Next Chapter >> Perforce and Windows |