GNU bug report logs - #32728
Emacs slow when reading process output

Previous Next

Package: emacs;

Reported by: "Benninghofen, Benjamin Dr." <benjamin.benninghofen <at> airbus.com>

Date: Thu, 13 Sep 2018 15:14:02 UTC

Severity: normal

Merged with 32729

Full log


Message #51 received at 32728 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: layer <at> franz.com, 32729 <at> debbugs.gnu.org, benjamin.benninghofen <at> airbus.com,
 32728 <at> debbugs.gnu.org
Subject: Re: bug#32729: Xemacs 23 times as fast as GNU Emacs
Date: Mon, 14 Oct 2019 12:15:09 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: benjamin.benninghofen <at> airbus.com,  layer <at> franz.com,
>   32729 <at> debbugs.gnu.org,  32728 <at> debbugs.gnu.org
> Date: Mon, 14 Oct 2019 10:36:11 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > I don't understand what would trigger these callbacks, and how do you
> > specify the region in advance, without knowing what will be inserted.
> 
> accept_process_output inserts the data into the buffer and then calls
> the callback with the region in question.  Well,
> read_and_dispose_of_process_output, I guess...

Filter functions are called even if the Lisp program never calls
accept-process-output, so your proposal doesn't seem to be equivalent
to what we have now, right?

OTOH, if one has to call accept-process-output, then why do we need
callbacks?  Just extend accept-process-output to call a function with
the received output.  No?

> > Without understanding this, I don't think I see the utility, and most
> > important: why this would be faster.
> 
> It would avoid creating (and garbaging) the strings.

I'm not sure I see how.

The way it works now is that we get the process output as a C string;
we then decode it and make a Lisp string from the result of decoding;
and then we invoke the filter with that Lisp string.  (If the filter
is nil, we invoke internal-default-process-filter instead, but it
still gets the text as a string.)

Which part(s) of this will be avoided under your proposal?

> > Btw, unlike what I originally implied, the default filter also
> > receives a Lisp string, so the question why by default reading dd
> > output is so much faster than when you define a non-default filter
> > function still stands.
> 
> Oh!  That is curious indeed.  Are the Lisp_Object strings somehow
> ... special here when they never leave C land?

No, I don't think so.

> The speed differential is completely repeatable...  hm...  Is the
> only difference that gc isn't given a chance to run in the
> non-filter case?

You could test that hypothesis by setting gc-cons-threshold to a very
high value.

Bottom line: I think we must understand better what takes the time in
your last test case, before we discuss solutions.  I'd start by
profiling that with "M-x profiler-start".




This bug report was last modified 5 years and 300 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.