Perforce 2005.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 |
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.
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 only valid for Release 99.1 and newer servers. Perforce Servers prior to 99.1 always perform a reverse name lookup. |
The corresponding UNIX file is /etc/hosts.
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:
//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 123 and "The temporary client workspace trick" on page 124) 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:
Group: rocketdev |
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:
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:
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.
Group: superusers |
(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 example, if your script currently does something like:
Branch: pathA-pathB |
and replacing the three commands with one:
For instance, suppose your script runs these commands:
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.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 |