AGOCG logo
Graphics Multimedia VR Visualisation Contents
Training Reports Workshops Briefings Index

Remote Viewing of PostScript on X displays
National Information on Software and Services

Introduction

NISS has recently been looking at remote viewing of PostScript docu- ments using GhostView and GhostScript to X servers, in particular Xsun from the MIT version of X11R5 and eXceed from Hummingbird Communications. X11R6 is not expected to directly make a great deal of difference to this, but the "X Remote" work in progress will do. They have identified a number of changes which can speed this up, particularly in the start- up time. A simple (8 line) patch to Ghostscript 2.6.1 can reduce the amount of traffic generated by up to 33% although the normal reduction is a lot less than this. Use of the -monochrome switch to Ghostview reduces the amount of traffic needed to set up the display by 16kbytes. If the document is only monochrome this is wasted. Standard techniques such as reducing the number of fonts which have to be loaded are also worthwhile.

Colour

X goes to great length to make access to the hardware support for colour on the X server as device independent as possible. However this independence is not without cost. When ghostscript starts it attempts to allocate a number of colours. The number depends on the hardware, but is typically 123 (53-2) on a colour display, this being 532. This allows for 5 bits for each of Red, Green and Blue, and assumes that colours for black and white have already been allocated. As each colour request requires 16 bytes to request, and 32 bytes to acknowledge, this colour setup requires the transfer of nearly 6,000 bytes. It is wasted if the document only requires monochrome! Worse still is that each acknowledgement is needed before the next request can be made, so each of these requests and acknowledgements travels in a separate TCP/IP packet, adding nearly another 10,000 bytes of overhead if standard headers are used. This takes about 2 seconds to transmit on a 64kbps line. A better solution would be to delay allocating the colours until either the first use, or better still until each of the 123 extra colours is required. This would retain the flexibility of the current scheme with no penalty for documents which do not require it.

X Resources

X enables advanced users to customise their environment to a very high degree. In the case of ghostscript, this complexity caused an additional problem. It was decided to use the Xt toolkit to parse the database - a sensible choice. However unfortunately the code to do this parsing left a great deal to be desired. If the "unidiff" in the Figure is applied to the file gdevxini.c it will improve the code significantly. This is not the best code, but is the minimal change. If an up-to-date version of the patch program which understands "uni-diff" format patches, then it can be applied by hand. All that is needed is to add the lines which start with a + sign in the correct place (around lines 300 to 320) but obviously without the + sign (see figure).
                                             
@@ -301,15 +301,24 @@
     /* Get X Resources.  Use the toolkit for this. */
     XtToolkitInitialize();
app_con =XtCreateApplicationContext();
+#ifdef READ_TWICE
+ /* Read the environment a second time */
dpy = XtOpenDisplay(app_con, NULL, "ghostscript", "Ghostscript",
NULL, 0, &zero, NULL);
+#else
+ XtDisplayInitialize(app_con, xdev->dpy, "ghostscript", "Ghostscript",
+ NULL, 0, &zero, NULL);
+ dpy = xdev->dpy;
+#endif
toplevel = XtAppCreateShell(NULL, "Ghostscript",
applicationShellWidgetClass, dpy, NULL, 0);
XtGetApplicationResources(toplevel, (XtPointer) xdev,
resources, XtNumber(resources), NULL, 0);
XtDestroyWidget(toplevel);
+#ifdef READ_TWICE
XtCloseDisplay(dpy);
XtDestroyApplicationContext(app_con);
+#endif
gdev_x_setup_colors(xdev);
gdev_x_setup_fontmap(xdev);

Figure: Patch to avoid double read of X resource database

Fonts

In the standard applications defaults for ghostview, it uses two fonts -adobe-newcentury schoolbook-medium-r-normal--* 140-*-*-p-*-iso8859-1 and -adobe-courier-medium-r-normal--*-140 *-*-m-*-iso8859-1 in addition to the cursor font. Normally it only uses the second of these. If these fonts are not already loaded, then information about them has to be down-loaded. This can be avoided by specifying alternative fonts in the X resource database.

Timings for eXceed

A typical set of timings for eXceed, running on both a 486DX33 and a 486DX266 connected over a local ethernet, both with and without the - monochrome_switch_are:
                DX33     DX266
normal       	5.4      4.2
-monochrome   	4.0      3.4
speedup       	26%      19%

Availability

A text and PostScript version of this document, and a text version of the patch file are available from the directory: /NISS/Postscript on the host: ftp.niss.ac.uk or from: /alex/uk/ac/niss/ftp/NISS/Postscript using the NISS Alex service.


Icarus Sparry
University of Bath
I.Sparry@uk.ac.bath