top of page

Proof of Efficiency

 

The XSearch protocol provides the most efficient method for the current owner of the search parameters to broadcast changes in these parameters to all other programs that support the protocol.

 

All properties are stored on two persistent windows:  the version window and the data window.  The ID's of these windows are stored in the XSearchWindows property on the root window so all programs can find the windows once they have been created.  Storing XsearchVersion on its own window minimizes the number of PropertyNotify events received because each program only needs to listen to the version window.  Storing XsearchDataV* on a separate window avoids sending unnecessary PropertyNotify events to programs that are forced to listen to other properties on the root window.

 

Storing XsearchVersion separately from the data also allows each receiver to retrieve only two window properties:  XsearchVersion and then a single XsearchDataVN, as explained in the Procedures section.

 

XsearchSelection is used to reduce the network traffic and improve performance.  Since the server is grabbed when the search parameters are updated, each program is guaranteed to receive a SelectionClear message for XsearchSelection before it receives any PropertyNotify events that were generated by other programs.  Thus, if a program thinks that it currently owns the selection, then that program can ignore PropertyNotify events because they must result either from the program's own changes or from changes made by other programs before this program last took ownership of the selection (i.e. events still in transit from the server or in the Xlib queue when the server was grabbed).  The latter reason obviously reduces network traffic.  The former reason eliminates the four packets required to retrieve XsearchVersion and XsearchDataVN, at a cost of three packets to obtain ownership of XsearchSelection and one packet to notify the previous owner.  Even though there is no net change in traffic in this case, it does reduce the delay required to set the data because retrieving the two window properties requires two blocking round trips to the X server and redrawing of the screen to display the new values, while obtaining ownership of XsearchSelection only requires one blocking round trip (the mandatory check of XGetSelectionOwner()).

 

Since the version property is modified separately, programs may not manage to retrieve the data before somebody else modifies the data in preparation for sending a new PropertyNotify event.  This is not dangerous, however, because XChangeProperty() is atomic, so the receivers will simply get data that is closer to being current.  If the new owner doesn't support the previous owner's version, the receiver will get the "correct," outdated data. Either way, another PropertyNotify event will already be in the queue, and this will force the receiver to update to the correct data.  Note that such rapid changes are very unlikely since they are triggered by user actions which are orders of magnitude slower than the typical network.  Repeated, redundant updating will therefore happen very rarely, if at all.

 

An alternate protocol would be to modify only a version property and have each receiver request the contents of the XsearchSelection.  In an environment with many programs that support the XSearch protocol, this puts an unnecessarily large load on the network.  Define NV to be the number of XSearch protocol versions and NR to be the number of receivers.  Retrieving a selection requires seven packets per receiver, while the current method requires only NV packets to set XsearchDataV*, and two packets per receiver.  (This ignores the packet to set XsearchVersion, the packet to each receiver containing the PropertyNotify event, and the two packets per receiver to retrieve XsearchVersion.  These packets are required by both protocols.)  As long as NV+2*NR < 7*NR, the protocol that is used by XSearch requires significantly less network traffic.  It also puts far less load on the source program since the source does not have to respond to SelectionRequest events.

 

<< Previous | Next >>

 

bottom of page