unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Simple optimization for read_avail_input()
Date: 07 Feb 2004 01:12:36 +0100	[thread overview]
Message-ID: <m38yjfsq6j.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <E1Ap8aH-000LqG-00.dmitry-antipov-mail-ru@f7.mail.ru>

"Dmitry Antipov" <dmitry.antipov@mail.ru> 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 <storm@cua.dk> http://www.cua.dk

       reply	other threads:[~2004-02-07  0:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Ap8aH-000LqG-00.dmitry-antipov-mail-ru@f7.mail.ru>
2004-02-07  0:12 ` Kim F. Storm [this message]
2004-01-30 15:57 Simple optimization for read_avail_input() Dmitry Antipov
2004-02-03 14:17 ` Kim F. Storm
2004-02-17 23:51 ` Kim F. Storm
2004-02-20  0:31   ` Kim F. Storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m38yjfsq6j.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).