From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ami Fischman Newsgroups: gmane.emacs.devel Subject: Re: [patch] cache color info for remote X sessions [Was: Emacs 21/X11 generating unbelieveable network traffic] Date: Mon, 07 Oct 2002 08:35:59 -0700 Sender: emacs-devel-admin@gnu.org Message-ID: References: <20021006012932.GA9183@gnu.org> <200210071453.g97Erqu24465@rum.cs.yale.edu> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1034005182 28040 127.0.0.1 (7 Oct 2002 15:39:42 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 7 Oct 2002 15:39:42 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17yZyv-0007Hz-00 for ; Mon, 07 Oct 2002 17:39:41 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17yam3-0000x8-00 for ; Mon, 07 Oct 2002 18:30:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17yZwV-0008LR-00; Mon, 07 Oct 2002 11:37:11 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17yZvT-0006oL-00 for emacs-devel@gnu.org; Mon, 07 Oct 2002 11:36:07 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17yZvO-0006gf-00 for emacs-devel@gnu.org; Mon, 07 Oct 2002 11:36:06 -0400 Original-Received: from main.gmane.org ([80.91.224.249]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17yZvO-0006fU-00 for emacs-devel@gnu.org; Mon, 07 Oct 2002 11:36:02 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 17yZur-00071c-00 for ; Mon, 07 Oct 2002 17:35:29 +0200 Original-To: emacs-devel@gnu.org X-Injected-Via-Gmane: http://gmane.org/ Original-Received: from news by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 17yZuq-00071T-00 for ; Mon, 07 Oct 2002 17:35:28 +0200 Original-Path: not-for-mail Original-Lines: 41 Original-NNTP-Posting-Host: 12-228-169-213.client.attbi.com Original-X-Trace: main.gmane.org 1034004928 26997 12.228.169.213 (7 Oct 2002 15:35:28 GMT) Original-X-Complaints-To: usenet@main.gmane.org Original-NNTP-Posting-Date: Mon, 7 Oct 2002 15:35:28 +0000 (UTC) Mail-Copies-To: nobody User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2.50 (i686-pc-linux-gnu) Cancel-Lock: sha1:dukJ6+2MYG69+uPxJ0ySPjNUiLQ= Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:8441 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:8441 "Stefan Monnier" writes: [...] > Yuck! At least use alloca. Disallowing re-entrance is always a bad idea. I agree with the first and third statements. But, I was unaware that emacs had threading support (in fact, I was under the impression that it was highly NON re-entrant, which is why, for instance, running lisp routines in the background of an emacs session is not possible). I've converted to use alloca (it's just the two buffers), and it works just as well. But, if there's a possibility that these routines will be used in a re-entrant manner, I should add a mutex lock to the cache. Is this really a possibility, or were you just expressing a distaste for non-re-entrant code on principle? > By the way, is the cached answer always the same as the one we would have > goten without the cache ? For AllocColor, yes. For XQueryColor{,s}, no. > IF not, what is the potential impact ? The worst that can happen is that an old RGB set would be returned for a pixel value (rather than the new one), and thus that the wrong color will be shown in emacs. > Can/should we invalidate the cache sometimes to avoid/reduce those > problems ? "should" -> yes. "Can" is trickier. In order for an old cache entry to be "wrong", the X server will have to allocate a colormap entry once, then dealloc it, then allocate another color in that space. Which really comes down to the X server having very few colormap entries and an app that asks for a lot. I don't think emacs will be running into this problem soon (although, testing with xpms/pngs might be instructive here). -- Ami Fischman usenet@fischman.org