[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] cache color info for remote X sessions [Was: Emacs 21/X11 genera

From: Ami Fischman
Subject: [patch] cache color info for remote X sessions [Was: Emacs 21/X11 generating unbelieveable network traffic]
Date: Sat, 05 Oct 2002 17:21:48 -0700
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2.50 (i686-pc-linux-gnu)

Following up on a couple of recent threads, I decided to add caching to the
X Color lookup code in emacs.  The way I ended up doing it was creating a
general purpose cache linked-list, and wrapping each of XAllocColor,
XQueryColor, and XQueryColors in a function that first looks for the
requested data in the linked list before issuing the X call.  Results are
quite good.  Some arbitrary timings follow.  All times over an ssh -XC link
with lbxproxy running on the remote end.  The "stock" emacs has a version
string of:  GNU Emacs 21.1.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll
bars) of 2001-10-22 on zion.  Times are presented for this stock emacs and
for a current CVS emacs configured --without-xim and with color caching,
and for each of those, with and without my ~/.emacs file (which loads a
whole bunch of libraries).

without ~/.emacs (-q):
Std emacs 21.1
    0.24user 0.05system 0:45.31elapsed
emacs-cvs --without-xim, with color caching:
    0.25user 0.03system 0:29.80elapsed

with ~/.emacs:
    0.96user 0.22system 1:04.65elapsed
emacs-cvs --without-xim, with color caching:
    0.94user 0.15system 0:32.40elapsed

As you can see, the big improvement is in the loading of libraries -- where
the stock emacs goes from 45s to 69s, the caching emacs goes up less than 3

Another obvious thing to cache would be the font data that emacs can
request, although it is much less clear to me how to cache the XExtData
list that is potentially contained in an XFontStruct (namely, how do you
know how big the private data is?  If anyone has any suggestions here, I'd
like to hear them).

This new functionality is provided via two new files (xcache.[ch]), adding
xcache.o to the XOBJ variable in src/Makefile, adding -DUSE_XCACHE to the
ALL_CFLAGS in the Makefile, and the following small patch to xterm.c:

Index: xterm.h
RCS file: /cvsroot/emacs/emacs/src/xterm.h,v
retrieving revision 1.136
diff -r1.136 xterm.h
< #endif
> #ifdef USE_XCACHE
> #include "xcache.h"
> #endif /* USE_XCACHE */
> #endif /* USE_X_TOOLKIT */

xcache.[ch] are attached.  

I'd be interested to hear any feedback you might have on this.

  Ami Fischman

Attachment: xcache.c
Description: Binary data

Attachment: xcache.h
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]