all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Strange shell mode performance
@ 2020-10-14 10:49 Herman, Géza
  2020-10-14 17:32 ` Stefan Monnier
  2020-10-21  1:27 ` Robert Thorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Herman, Géza @ 2020-10-14 10:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I'm experiencing strange shell (comint) mode performance. If I cat a 10 
MB file, it takes 1:20 to cat it. Emacs uses only 30% cpu. But, if I 
press enter after I send the cat command, it speeds up, and it only 
takes 8 sec (emacs cpu usage goes up to 100%).

Same thing: if I execute "seq 100000" in a small emacs window, it takes 
~3 seconds. But, if I press enter after executing seq, it takes only 0.4 
sec (this is not 100% reproducible, sometimes pressing enter doesn't 
make a difference).
(I executed comint-clear-buffer before measurements)

It happens with 26.3 and ~3-week-old master branch as well, without any 
extra config (emacs -Q).

Any ideas what causes this? Would it be possible to always have the 
better performance without needing to press enter?

Thanks,
Geza



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange shell mode performance
  2020-10-14 10:49 Strange shell mode performance Herman, Géza
@ 2020-10-14 17:32 ` Stefan Monnier
  2020-10-21  1:27 ` Robert Thorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2020-10-14 17:32 UTC (permalink / raw)
  To: help-gnu-emacs

> Any ideas what causes this?  Would it be possible to always have the better
> performance without needing to press enter?

I suggest you `M-x report-emacs-bug` since it seems to be
a performance bug (that doesn't guarantee that it will be fixed, tho:
it's sometimes quite difficult to fix those problems).


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange shell mode performance
  2020-10-14 10:49 Strange shell mode performance Herman, Géza
  2020-10-14 17:32 ` Stefan Monnier
@ 2020-10-21  1:27 ` Robert Thorpe
  2020-10-21 10:27   ` Herman, Géza
  1 sibling, 1 reply; 4+ messages in thread
From: Robert Thorpe @ 2020-10-21  1:27 UTC (permalink / raw)
  To: Herman Géza; +Cc: help-gnu-emacs

I suspect that this is about memory allocation.

I've noticed strange things like this before with large shell buffers.
I don't think that pressing enter is really what makes the difference.

I expect it's the memory that Emacs has allocated.  When you have a
small shell buffer you're usually reusing memory that has already been
allocated to Emacs.  That's because Emacs is constantly allocating and
deallocating memory within it's own memory management.  AFAIK it never
actually gives memory back to the OS (modern OSes don't really need that anyway).

However, when the size of the shell buffer rises above the largest size
that the Emacs process have ever been things change.  Then new memory
has to be allocated to Emacs.

I may be wrong about this though, it was ages since I looked at the
code.

BR,
Robert Thorpe

Herman, Géza <geza.herman@gmail.com> writes:

> Hi all,
>
> I'm experiencing strange shell (comint) mode performance. If I cat a 10 
> MB file, it takes 1:20 to cat it. Emacs uses only 30% cpu. But, if I 
> press enter after I send the cat command, it speeds up, and it only 
> takes 8 sec (emacs cpu usage goes up to 100%).
>
> Same thing: if I execute "seq 100000" in a small emacs window, it takes 
> ~3 seconds. But, if I press enter after executing seq, it takes only 0.4 
> sec (this is not 100% reproducible, sometimes pressing enter doesn't 
> make a difference).
> (I executed comint-clear-buffer before measurements)
>
> It happens with 26.3 and ~3-week-old master branch as well, without any 
> extra config (emacs -Q).
>
> Any ideas what causes this? Would it be possible to always have the 
> better performance without needing to press enter?
>
> Thanks,
> Geza



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange shell mode performance
  2020-10-21  1:27 ` Robert Thorpe
@ 2020-10-21 10:27   ` Herman, Géza
  0 siblings, 0 replies; 4+ messages in thread
From: Herman, Géza @ 2020-10-21 10:27 UTC (permalink / raw)
  To: Robert Thorpe; +Cc: help-gnu-emacs

The bug is caused by process-adaptive-read-buffering.

I analyzed the issue. For my use case, I made shell ~60x faster by 
simple modifications (details: 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44007).

On 2020-10-21 03:27, Robert Thorpe wrote:
> I suspect that this is about memory allocation.
>
> I've noticed strange things like this before with large shell buffers.
> I don't think that pressing enter is really what makes the difference.
>
> I expect it's the memory that Emacs has allocated.  When you have a
> small shell buffer you're usually reusing memory that has already been
> allocated to Emacs.  That's because Emacs is constantly allocating and
> deallocating memory within it's own memory management.  AFAIK it never
> actually gives memory back to the OS (modern OSes don't really need that anyway).
>
> However, when the size of the shell buffer rises above the largest size
> that the Emacs process have ever been things change.  Then new memory
> has to be allocated to Emacs.
>
> I may be wrong about this though, it was ages since I looked at the
> code.
>
> BR,
> Robert Thorpe
>
> Herman, Géza <geza.herman@gmail.com> writes:
>
>> Hi all,
>>
>> I'm experiencing strange shell (comint) mode performance. If I cat a 10
>> MB file, it takes 1:20 to cat it. Emacs uses only 30% cpu. But, if I
>> press enter after I send the cat command, it speeds up, and it only
>> takes 8 sec (emacs cpu usage goes up to 100%).
>>
>> Same thing: if I execute "seq 100000" in a small emacs window, it takes
>> ~3 seconds. But, if I press enter after executing seq, it takes only 0.4
>> sec (this is not 100% reproducible, sometimes pressing enter doesn't
>> make a difference).
>> (I executed comint-clear-buffer before measurements)
>>
>> It happens with 26.3 and ~3-week-old master branch as well, without any
>> extra config (emacs -Q).
>>
>> Any ideas what causes this? Would it be possible to always have the
>> better performance without needing to press enter?
>>
>> Thanks,
>> Geza




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-21 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-14 10:49 Strange shell mode performance Herman, Géza
2020-10-14 17:32 ` Stefan Monnier
2020-10-21  1:27 ` Robert Thorpe
2020-10-21 10:27   ` Herman, Géza

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.