Perforce Public Knowledge Base - Local vs Global commands - Using Federated Architecture to Best Advantage
× PRODUCTS SOLUTIONS CUSTOMERS LEARN SUPPORT
Downloads Company Partners Careers Contact Free Trials
Menu Search
Perforce
Reset Search
 

 

Article

Local vs Global commands - Using Federated Architecture to Best Advantage

« Go Back

Information

 
Problem

Overview:

Edge-Commit architecture is a good solution for geographically distributed work groups, and it can offer significant performance advantages whether clients are widely distributed or not. It is made up of a commit server and one or more edge servers that are connected to the commit server:
  • The commit server stores the canonical archives and permanent metadata. 
    It processes write operations and operations that affect global data.
     
  • The edge server contains a replicated copy of the commit server data and a unique, local copy of
    some workspace and work-in-progress information. 
    It can process read-only operations and operations like p4 edit that only write to the local data.
     
This architecture trades off performance and visibility. As much of the work as possible is entrusted to the edge server, thus avoiding the performance degradation that happens over high latency networks or that happens when the commit server is burdened with all the work. However, that also means that local work is not visible to users connected to other edge servers. The only way data can be shared across edge servers, is to make it global, which implies making the data available to the commit server.
This article explains how work is distributed between the edge server and the commit server and provides guidelines that can help you use this architecture to best advantage.
(For detailed information about setting up and managing this architecture, see http://www.perforce.com/perforce/doc.current/manuals/p4dist/chapter.distributed.html)
Solution

Local and Global Commands

Local commands are executed on the edge server to which the client is connected; global commands are executed on the commit server. It might help you to fine tune performance if you understand this difference and know where P4d commands are executed.

Local commands execute faster because they execute locally or, at worst, travel over a local area network.
- All read-only commands are local
- Commands related to workspace state are always local
- A label can be local
- Edge specific shelves are local, until they are promoted.

Global commands execute more slowly than local commands because they must often travel over wide area networks and because the type of work they do tends to be more resource intensive. 

- Commands that update data stored on the commit server are global, for example Submit
- Changelist numbers & description are always global
- Workspace name (and, since 15.2+, its view) are global
- Any change in the state of files of type +l must be global
- A label can be local or global, but its *name* is always global
- Promoted shelves or the act of promoting a shelf is global

For example, 'p4 sync' :

- updates workspace state only (and does not update global data)
- does not modify any changelist specs
- does not modify your workspace spec
- does not change the state of any +l files
- does not create any labels
- does not promote any shelves

Hence “p4 sync” is a local command that can be run on an edge server without any connection to the commit server
In the case of some commands, the specified options might determine whether the command is executed locally or remotely. For example, “branch –o” is a read-only command, hence local; whereas “branch –i” is  an updating command, hence global .
The tables at the end of this article indicate which commands are global and which, local.

Making Local Data Global

Common cases in which you might want to make data global concern shelved changelists, client views, and locks. Be aware that global visibility might degrade performance.
  • Changelists shelved on an edge server, which would normally be inaccessible from other edge servers, can be automatically or explicitly promoted to the commit server. Promoted shelved changelists are available to any edge server. 
     
  • You can use the server.global.client.views configurable to specify whether the view maps of a non-stream client on an edge server are made global when the client is modified. This configurable can be set globally or individually for each server, thus allowing client maps to be global on most edge servers while keeping them local on those edge servers that don't need them to be global. 
     
  • You can use the -g flag of the p4 lock command to lock the files locally and globally. The -g option must be used with the -c changelist option. This lock is removed by the p4 unlock -g command or by any submit command for the specified changelist

Global commands

Commands

Description

Comments

branch -i

Create, modify, or delete a branch view specification. The -i flag causes a branch spec to be read from the standard input. The user's editor is not invoked.

This is  an updating command, hence will work globally

change

Create or edit a changelist description

Add – No

Edit – works locally on Edge, but fails to update Commit server

changelist

Create or edit a changelist description

 

client

Create or edit a client specification and its view

Create – No

Edit – works locally on Edge, but fails to update Commit Server.

counter

set, or delete a counter

 

depot

Create or edit a depot specification

 

fix

Mark jobs as being fixed by named changelists

 

group

Change members of a user group

 

istat

Show integrations needed for a stream

 

job

Create or edit a job (defect) specification

 

key

Display, set, or delete a key/value pair

 

label

Create or edit a label specification and its view

 

labelsync

Synchronize label with the current client contents

Yes, if label exists, and is local to the edge server.

lock

Lock an opened file against changelist submission

New 2015.2 'lock -g' flag will not work.

logger

Report what jobs and changelists have changed

 

login

Login to Perforce by obtaining a session ticket

 

logout

Logout of Perforce by removing or invalidating a ticket

 

passwd

Set the user's password on the server (and Windows client)

 

populate

Populate a branch or stream with files

 

protect

Modify protections in the server namespace

 

prune

Remove unmodified branched files from a stream

 

shelve

Store files from a pending changelist into the depot

May not work: 1) if you are promoting a shelve for global consumption, or 2) unshelving a global shelve

stream

Create or edit a stream specification

 

submit

Submit open files to the depot

 

tag

Tag files with a label

Yes, if label exists, and is local to the edge server.

unlock

Release a locked file but leave it open

New 2015.2 'unlock -g' flag will not work.

user

Create or edit a user specification

 

workspace

Create or edit a client specification and its view

 

 

Local commands:

Commands

Description

Will work?

add

Open a new file to add it to the depot

Will work for files that have an exclusive lock on them

annotate

Print file lines along with their revisions

 

attribute

Set per-revision attributes on revisions

But does not work for submitted files. Not recommended in a Federated architecture

branch -o

Create, modify, or delete a branch view specification. The -o flag writes the branch spec to standard output. The user's editor is not invoked.

This is a read-only command, hence will work locally

branches

Display list of branches

 

changes

Display list of pending and submitted changelists

 

changelists

Display list of pending and submitted changelists

 

clean

Delete or refresh local files to match depot state

 

clients

Display list of known clients

 

copy

Schedule copy of latest rev from one file to another

Will work for files that have an exclusive lock on them

counter

Display a counter

 

counters

Display list of known counters

 

cstat

Dump change/sync status for current client

 

delete

Open an existing file to delete it from the depot

Will not work for files that have an exclusive lock on them

depots

Display list of depots

 

describe

Display a changelist description

 

diff

Display diff of client file with depot file

 

diff2

Display diff of two depot files

 

dirs

List subdirectories of a given depot directory

 

edit

Open an existing file for edit

Will not work for files that have an exclusive lock on them

filelog

List revision history of files

 

files

List files in the depot

 

fixes

List what changelists fix what job

 

flush

Fake a 'p4 sync' by not moving files

 

fstat

Dump file info

 

grep

Print lines from text files matching a pattern

 

groups

List groups (of users)

 

have

List revisions last synced

 

help

Print the requested help message

 

info

Print out client/server information

 

integrate

Schedule integration from one file to another

Will not work for files that has an exclusive lock on them

integrated

Show integrations that have been submitted

 

interchanges

Report changes that have not yet been integrated

 

jobs

Display list of jobs

 

keys

Display list of known keys and their values

 

labels

Display list of labels

 

labelsync

Synchronize label with the current client contents

Yes, if label exists, and is local to the edge server.

list

Create an in-memory (label) list of depot files

 

lock

Lock an opened file against changelist submission

New 2015.2 'lock -g' flag will not work.

merge

Schedule merge (integration) from one file to another

May not work for files that have an exclusive lock on them

move

Moves files from one location to another

 

opened

Display list of files opened for pending changelist

 

print

Retrieve a depot file to the standard output

 

protects

Display protections in place for a given user/path

 

rec

Reconcile client to offline workspace changes

 

reconcile

Reconcile client to offline workspace changes

 

rename

Moves files from one location to another

 

reopen

Change the type or changelist number of an opened file

 

resolve

Merge open files with other revisions or files

 

resolved

Show files that have been merged but not submitted

 

revert

Discard changes from an opened file

If "revert" has to revert an exclusive locked file. It needs to contact the Commit Server, hence in that scenario this won't work

review

List and track changelists (for the review daemon)

But not with -t flag

reviews

Show what users are subscribed to review files

 

set

Set variables in the registry (Windows only)

 

status

Preview reconcile of client to offline workspace changes

 

sizes

Display size information for files in the depot

 

streams

Display list of streams

 

sync

Synchronize the client with its view of the depot

 

tag

Tag files with a label

Yes, if label exists, and is local to the edge server.

tickets

Display list of session tickets for this user

 

unlock

Release a locked file but leave it open

New 2015.2 'unlock -g' flag will not work.

unshelve

Restore shelved files from a pending changelist

May not work for 1) files that have an exclusive lock on them, or 2) unshelving a global shelve

update

Update the client with its view of the depot

 

users

Display list of known users

 

where

Show how file names map through the client view

 

workspaces

Display list of known clients

 

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255