From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Simple optimization for read_avail_input() Date: 07 Feb 2004 01:12:36 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1076110264 23345 80.91.224.253 (6 Feb 2004 23:31:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2004 23:31:04 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Feb 07 00:30:56 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApFR2-0005GS-00 for ; Sat, 07 Feb 2004 00:30:56 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApFR0-0000AZ-00 for ; Sat, 07 Feb 2004 00:30:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ApFK5-00053u-VC for emacs-devel@quimby.gnus.org; Fri, 06 Feb 2004 18:23:45 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ApFJ7-0004nQ-S1 for emacs-devel@gnu.org; Fri, 06 Feb 2004 18:22:45 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ApFIa-0004j3-9F for emacs-devel@gnu.org; Fri, 06 Feb 2004 18:22:44 -0500 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ApF9R-0004A3-Qw for emacs-devel@gnu.org; Fri, 06 Feb 2004 18:12:45 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepa.post.tele.dk (Postfix) with SMTP id 1A6CB4800B1; Sat, 7 Feb 2004 00:12:44 +0100 (CET) Original-To: "Dmitry Antipov" In-Reply-To: Original-Lines: 45 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19778 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19778 "Dmitry Antipov" writes: > Kim F. Storm wrote: > > > Nice idea, but in its current form it fails because the buf array is allocated on > > the stack. It may work to just declare it static though. > > Bups. I agree. But, in any case, we should avoid to zero 40k each time when read_avail_input() is called. I agree, this is wasteful. > It's not quite clear for me why this array should be so large (4k), btw. > > > I think it's ok, if we can guarantee that read_avail_input is never called > > recursively (I haven't checked). > > It happens at least 1 time sometimes after creating X frame. Is it the same as expected ? I don't know. > > > But I really wonder why it is necessary to initialize the array at all. > > IMHO it's necessary. For example, if read_socket_hook is NULL, buf[i].x and buf[i].y > are untouched. But they are Lisp_Objects, and if Fgarbage_collect() happens immediately > after kbd_buffer_store_event() (from read_avail_input()), we will got invalid Lisp_Objects > for mark_object() from mark_kboards (). I can reproduce this situation sometimes (when > my fingers are blazingly fast :-)). > The same for X events - not all of them touches x and y. I wasn't advocating for never initializing input_events -- I would just postpone the initialization until we actually use one of those input_events, i.e. also before we do kbd_buffer_store_event... > > > BTW, it definitely is unnecessary to init the whole array if > > read_socket_hook is NULL; we could just init the first nread > > elements in that case. > > Agree. For XTread_socket and others, we probably should do EVENT_INIT when really needed. It's the same principle... -- Kim F. Storm http://www.cua.dk